Skip to content

Commit

Permalink
Migrate to new flat config for eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
dpilafian committed Aug 9, 2024
1 parent 99c1111 commit 7edbb9d
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 34 deletions.
20 changes: 20 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// @ts-check

import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';

export default [
eslint.configs.recommended,
...tseslint.configs.strictTypeChecked,
{ ignores: ['**/*.js'] },
{
languageOptions: { parserOptions: { projectService: true } },
rules: {
'@typescript-eslint/no-confusing-void-expression': 'off', //prefer clean arrow functions
'@typescript-eslint/no-floating-promises': 'off', //annimations may be fire-and-forget
'@typescript-eslint/no-non-null-assertion': 'off', //ts cannot always discern if value exists
'@typescript-eslint/restrict-template-expressions': 'off', //numbers in templates are natural
'@typescript-eslint/unbound-method': 'off', //do not use 'this'
},
},
];
2 changes: 1 addition & 1 deletion hello-world/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"dependencies": {
"jshint": "~2.13",
"puppeteer": "~22.10",
"puppeteer": "~23.0",
"puppeteer-browser-ready": "~1.3"
}
}
41 changes: 11 additions & 30 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,32 +41,13 @@
"mocha": true,
"node": true
},
"eslintConfig": {
"ignorePatterns": [
"build",
"dist",
"node_modules"
],
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"rules": {
"@typescript-eslint/no-non-null-assertion": "off"
}
},
"runScriptsConfig": {
"clean": [
"rimraf build dist"
],
"lint": [
"jshint . --exclude-path .gitignore",
"eslint --max-warnings 0 . --ext .ts"
"eslint --max-warnings 0"
],
"build": [
"tsc",
Expand All @@ -79,32 +60,32 @@
"test": "mocha spec/*.spec.js --timeout 7000 --retries 1"
},
"peerDependencies": {
"puppeteer": "^15 || ^16 || ^17 || ^18 || ^19.7 || ^20 || ^21 || ^22.8"
"puppeteer": "^15 || ^16 || ^17 || ^18 || ^19.7 || ^20 || ^21 || ^22.8 || ^23"
},
"dependencies": {
"express": "~4.19",
"http-terminator": "~3.2",
"node-html-parser": "~6.1"
},
"devDependencies": {
"@eslint/js": "~9.3",
"@eslint/js": "~9.8",
"@types/express": "~4.17",
"@types/mocha": "~10.0",
"@types/node": "~20.12",
"@types/node": "~22.1",
"@types/ws": "~8.5",
"add-dist-header": "~1.4",
"assert-deep-strict-equal": "~1.2",
"copy-file-util": "~1.2",
"copy-folder-util": "~1.1",
"eslint": "8.57.0",
"eslint": "~9.8",
"jshint": "~2.13",
"mocha": "~10.4",
"mocha": "~10.7",
"open": "~10.1",
"puppeteer": "~22.10",
"rimraf": "~5.0",
"run-scripts-util": "~1.2",
"typescript": "~5.4",
"typescript-eslint": "~7.11",
"puppeteer": "~23.0",
"rimraf": "~6.0",
"run-scripts-util": "~1.3",
"typescript": "~5.5",
"typescript-eslint": "~8.0",
"w3c-html-validator": "~1.8"
}
}
7 changes: 4 additions & 3 deletions puppeteer-browser-ready.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ const browserReady = {
const settings = { ...defaults, ...options };
const log = (label: string, msg?: string | number | boolean | null) => settings.verbose &&
console.log(' ', Date.now() % 100000, label + ':', msg);
const rootInfo = (root: HTMLElement) => root.constructor.name + '/' + root.firstChild?.toString();
const rootInfo = (root: HTMLElement) =>
`${root.constructor.name}/${root.firstChild?.toString().trim()}`;
const web = async (browser: Browser): Promise<Web> => {
log('Connected', browser.isConnected());
try {
Expand All @@ -107,8 +108,8 @@ const browserReady = {
};
return web;
},
async close(web: Web): Promise<Web> {
if (web && web.browser)
async close(web: Web | null): Promise<Web | null> {
if (web?.browser)
await web.browser.close();
return web;
},
Expand Down

0 comments on commit 7edbb9d

Please sign in to comment.