From 56ef745952babf10317b51a0868b97d1cf1eac06 Mon Sep 17 00:00:00 2001 From: Teal Dulcet Date: Wed, 1 May 2024 06:04:54 -0700 Subject: [PATCH] Updated ESLint config for v9. --- .eslintignore | 3 - .eslintrc.json | 123 ----------------------------------- .github/workflows/ci.yml | 6 +- README.md | 2 +- eslint.config.cjs | 135 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 140 insertions(+), 129 deletions(-) delete mode 100644 .eslintignore delete mode 100644 .eslintrc.json create mode 100644 eslint.config.cjs diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index ea23334..0000000 --- a/.eslintignore +++ /dev/null @@ -1,3 +0,0 @@ -common/modules/*/* -!common/modules/data/* -browser-polyfill.js diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index 0438c5b..0000000 --- a/.eslintrc.json +++ /dev/null @@ -1,123 +0,0 @@ -{ - "root": true, - "env": { - "browser": true, - "es2022": true, - "webextensions": true - }, - "extends": "eslint:recommended", - "parserOptions": { - "ecmaVersion": "latest", - "sourceType": "module", - "ecmaFeatures": { - "impliedStrict": true - } - }, - "rules": { - "indent": ["error", "tab", { "SwitchCase": 1 }], - // "linebreak-style": ["error", "unix"], - "quotes": ["warn", "double", { "avoidEscape": true }], - "semi": ["error", "always"], - - "array-callback-return": "error", - "no-await-in-loop": "error", - "no-constant-binary-expression": "error", - "no-promise-executor-return": "error", - "no-self-compare": "error", - "no-template-curly-in-string": "error", - "no-unmodified-loop-condition": "error", - "no-unreachable-loop": "error", - "no-use-before-define": "error", - - "consistent-return": "error", - "curly": "error", - "default-param-last": "warn", - "dot-notation": "error", - "eqeqeq": ["error", "smart"], - "func-names": "warn", - // "init-declarations": "warn", - "no-array-constructor": "error", - "no-caller": "warn", - // "no-confusing-arrow": "warn", - "no-continue": "warn", - "no-else-return": "warn", - "no-eval": "error", - "no-extend-native": "warn", - "no-extra-bind": "warn", - "no-extra-label": "warn", - "no-floating-decimal": "warn", - "no-implicit-coercion": "warn", - "no-implied-eval": "error", - "no-invalid-this": "warn", - "no-lonely-if": "warn", - "no-loop-func": "error", - "no-negated-condition": "warn", - "no-new": "warn", - "no-new-func": "error", - "no-new-object": "error", - "no-new-wrappers": "error", - "no-octal-escape": "warn", - "no-return-assign": "warn", - "no-return-await": "warn", - "no-undef-init": "warn", - "no-undefined": "warn", - "no-unneeded-ternary": "warn", - "no-unused-expressions": "error", - "no-useless-call": "warn", - "no-useless-computed-key": "warn", - "no-useless-concat": "warn", - "no-useless-rename": "warn", - "no-useless-return": "warn", - "no-var": "warn", - "object-shorthand": "warn", - "operator-assignment": "warn", - "prefer-arrow-callback": "warn", - "prefer-const": ["error", { "destructuring": "all" }], - "prefer-exponentiation-operator": "warn", - // "prefer-named-capture-group": "warn", - "prefer-numeric-literals": "warn", - "prefer-object-has-own": "warn", - "prefer-object-spread": "warn", - "prefer-regex-literals": "warn", - "prefer-rest-params": "error", - "prefer-spread": "error", - "prefer-template": "warn", - "quote-props": ["error", "as-needed"], - "require-await": "warn", - "require-unicode-regexp": "warn", - "spaced-comment": "warn", - // "strict": "warn", - "symbol-description": "error", - "yoda": "error", - - "arrow-parens": "warn", - "arrow-spacing": "warn", - "block-spacing": "warn", - "brace-style": "error", - "comma-dangle": "warn", - "comma-spacing": "warn", - "comma-style": "warn", - "computed-property-spacing": "warn", - "func-call-spacing": "warn", - "key-spacing": "warn", - "keyword-spacing": "warn", - "no-extra-parens": "warn", - "no-multi-spaces": "warn", - "no-trailing-spaces": "warn", - "no-whitespace-before-property": "warn", - "rest-spread-spacing": "warn", - "semi-spacing": "warn", - "semi-style": "error", - "space-before-blocks": "warn", - // "space-before-function-paren": ["warn", "never"], - "space-in-parens": "warn", - "space-infix-ops": "warn", - "space-unary-ops": "warn", - "switch-colon-spacing": "warn", - "template-curly-spacing": "warn", - - // Deprecated: https://eslint.org/blog/2018/11/jsdoc-end-of-life/ - "require-jsdoc": "error" - // "valid-jsdoc": "error" - } -} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7a01fc8..c31a2b5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,9 +15,11 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 - name: Install - run: npm install -g eslint + run: npm install -g eslint @eslint/js globals - name: Script - run: eslint --report-unused-disable-directives . + run: | + export NODE_PATH=$(npm root -g) + eslint . continue-on-error: true TSC: diff --git a/README.md b/README.md index 7baef70..b13c379 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Actions Status](https://github.com/tdulcet/Colab-Autorun-and-Connect/workflows/CI/badge.svg?branch=master)](https://github.com/tdulcet/Colab-Autorun-and-Connect/actions) +[![Actions Status](https://github.com/tdulcet/Colab-Autorun-and-Connect/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/tdulcet/Colab-Autorun-and-Connect/actions/workflows/ci.yml) # Colab Autorun and Connect Automatically connect, reconnect and optionally run the first cell of notebooks in Google Colab diff --git a/eslint.config.cjs b/eslint.config.cjs new file mode 100644 index 0000000..d0dbe3e --- /dev/null +++ b/eslint.config.cjs @@ -0,0 +1,135 @@ +// export NODE_PATH=$(npm root -g) + +const js = require("@eslint/js"); +const globals = require("globals"); + +module.exports = [ + js.configs.recommended, + { + languageOptions: { + parserOptions: { + ecmaVersion: "latest", + sourceType: "module", + ecmaFeatures: { impliedStrict: true } + }, + globals: { + ...globals.browser, + ...globals.es2024, + ...globals.webextensions + } + }, + rules: { + indent: ["error", "tab", { SwitchCase: 1 }], + // "linebreak-style": ["error", "unix"], + quotes: ["warn", "double", { avoidEscape: true }], + semi: ["error", "always"], + + "array-callback-return": "error", + "no-await-in-loop": "error", + "no-promise-executor-return": "error", + "no-self-compare": "error", + "no-template-curly-in-string": "error", + "no-unmodified-loop-condition": "error", + "no-unreachable-loop": "error", + "no-use-before-define": "error", + "no-useless-assignment": "error", + + "consistent-return": "error", + curly: "error", + "default-param-last": "warn", + "dot-notation": "error", + eqeqeq: ["error", "smart"], + "func-names": "warn", + // "init-declarations": "warn", + "logical-assignment-operators": [ + "warn", + "always", + { enforceForIfStatements: true } + ], + "no-array-constructor": "error", + "no-caller": "warn", + // "no-confusing-arrow": "warn", + "no-continue": "warn", + "no-else-return": "warn", + "no-eval": "error", + "no-extend-native": "warn", + "no-extra-bind": "warn", + "no-extra-label": "warn", + "no-floating-decimal": "warn", + "no-implicit-coercion": "warn", + "no-implied-eval": "error", + "no-invalid-this": "warn", + "no-lonely-if": "warn", + "no-loop-func": "error", + "no-negated-condition": "warn", + "no-new": "warn", + "no-new-func": "error", + "no-object-constructor": "error", + "no-new-wrappers": "error", + "no-octal-escape": "warn", + "no-return-assign": "warn", + "no-return-await": "warn", + "no-undef-init": "warn", + "no-undefined": "warn", + "no-unneeded-ternary": "warn", + "no-unused-expressions": "error", + "no-useless-call": "warn", + "no-useless-computed-key": "warn", + "no-useless-concat": "warn", + "no-useless-rename": "warn", + "no-useless-return": "warn", + "no-var": "warn", + "object-shorthand": "warn", + "operator-assignment": "warn", + "prefer-arrow-callback": "warn", + "prefer-const": ["error", { destructuring: "all" }], + "prefer-destructuring": "warn", + "prefer-exponentiation-operator": "warn", + // "prefer-named-capture-group": "warn", + "prefer-numeric-literals": "warn", + "prefer-object-has-own": "warn", + "prefer-object-spread": "warn", + "prefer-regex-literals": "warn", + "prefer-rest-params": "error", + "prefer-spread": "error", + "prefer-template": "warn", + "quote-props": ["error", "as-needed"], + "require-await": "warn", + "require-unicode-regexp": "warn", + "spaced-comment": "warn", + // "strict": "warn", + "symbol-description": "error", + yoda: "error", + + "arrow-parens": "warn", + "arrow-spacing": "warn", + "block-spacing": "warn", + "brace-style": "error", + "comma-dangle": "warn", + "comma-spacing": "warn", + "comma-style": "warn", + "computed-property-spacing": "warn", + "func-call-spacing": "warn", + "key-spacing": "warn", + "keyword-spacing": "warn", + "no-extra-parens": "warn", + "no-multi-spaces": "warn", + "no-trailing-spaces": "warn", + "no-whitespace-before-property": "warn", + "rest-spread-spacing": "warn", + "semi-spacing": "warn", + "semi-style": "error", + "space-before-blocks": "warn", + // "space-before-function-paren": ["warn", "never"], + "space-in-parens": "warn", + "space-infix-ops": "warn", + "space-unary-ops": "warn", + "switch-colon-spacing": "warn", + "template-curly-spacing": "warn" + + // "require-jsdoc": "error" + // "require-jsdoc": "error" + } + }, + { ignores: ["common/modules/*/*", "!common/modules/data/*", "browser-polyfill.js"] } +];