From 75b198ef84a08a52c71e7d13e2b974ada94bd632 Mon Sep 17 00:00:00 2001 From: dpilafian Date: Wed, 14 Aug 2024 00:16:12 -0700 Subject: [PATCH] Convert to new flat config for eslint --- eslint.config.js | 22 ++++++++++++++++++++++ package.json | 43 ++++++++++++------------------------------- 2 files changed, 34 insertions(+), 31 deletions(-) create mode 100644 eslint.config.js diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..76686d1 --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,22 @@ +// @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 minimal arrow functions + '@typescript-eslint/no-floating-promises': 'off', //annimations may be fire-and-forget + '@typescript-eslint/no-misused-promises': 'off', //annimations may be fire-and-forget + '@typescript-eslint/no-non-null-assertion': 'off', //ts cannot always know value exists + '@typescript-eslint/restrict-template-expressions': 'off', //numbers in templates are natural + '@typescript-eslint/unbound-method': 'off', //safer to not use 'this' + '@typescript-eslint/use-unknown-in-catch-callback-variable': 'off', //clarity over theoretical exceptions + }, + }, + ]; diff --git a/package.json b/package.json index 9a0aa57..0a3bf9d 100644 --- a/package.json +++ b/package.json @@ -44,32 +44,13 @@ "node": true, "mocha": 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 src --ext .ts" + "eslint --max-warnings 0" ], "build": [ "tsc", @@ -98,28 +79,28 @@ "examples": "npm test && node spec/examples.js" }, "devDependencies": { - "@eslint/js": "~9.3", - "@fortawesome/fontawesome-free": "~6.5", - "@types/node": "~20.12", + "@eslint/js": "~9.9", + "@fortawesome/fontawesome-free": "~6.6", + "@types/node": "~22.2", "add-dist-header": "~1.4", "assert-deep-strict-equal": "~1.2", "copy-file-util": "~1.2", "copy-folder-util": "~1.1", "csso-cli": "~4.0", "dna-engine": "~3.2", - "eslint": "8.57.0", + "eslint": "~9.9", "esm-to-plain-js": "~1.1", "fetch-json": "~3.3", "jsdom": "~24.1", "jshint": "~2.13", - "mocha": "~10.4", + "mocha": "~10.7", "replacer-util": "~1.3", - "rimraf": "~5.0", - "run-scripts-util": "~1.2", - "typescript": "~5.4", - "typescript-eslint": "~7.11", - "uglify-js": "~3.17", + "rimraf": "~6.0", + "run-scripts-util": "~1.3", + "typescript": "~5.5", + "typescript-eslint": "~8.1", + "uglify-js": "~3.19", "w3c-html-validator": "~1.8", - "web-ignition": "~2.1" + "web-ignition": "~2.2" } }