-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated ESLint to v9.12.0 & migrated to a flat config file (#4162)
In some of the translation features I was using optional chaining & eslint would toss errors saying it was invalid despite it working. This led me to exploring the config to find the [yaml config we used was depreciated](https://eslint.org/docs/latest/use/configure/configuration-files-deprecated). This PR updates to a newer version of eslint & migrates the config to the [flat file version](https://eslint.org/docs/latest/use/configure/configuration-files#configuration-file) (and now optional chaining is recognized 🥳). Some code changes that came with the updated linting: - [As of ES6](https://262.ecma-international.org/6.0/#sec-strict-mode-code) modules are always in strict mode, thus `"use strict"` isn't needed - Removed unused var - Removed unneeded `eslint-disable` comment There are also a ton of JSDoc warnings now - I was going to remove them but I think JSDoc is actually a weak point in our code documentation so maybe the in-terminal annoyances will be a good reminder to do a quick write up
- Loading branch information
Showing
29 changed files
with
657 additions
and
359 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
import globals from "globals"; | ||
import path from "node:path"; | ||
import { fileURLToPath } from "node:url"; | ||
import js from "@eslint/js"; | ||
import jsdoc from "eslint-plugin-jsdoc"; | ||
import { FlatCompat } from "@eslint/eslintrc"; | ||
|
||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = path.dirname(__filename); | ||
const compat = new FlatCompat({ | ||
baseDirectory: __dirname, | ||
recommendedConfig: js.configs.recommended, | ||
allConfig: js.configs.all, | ||
}); | ||
|
||
export default [ | ||
{ | ||
ignores: ["**/*.min.js", "**/esm/*.js"], | ||
}, | ||
...compat.extends("eslint:recommended", "prettier"), | ||
jsdoc.configs["flat/recommended"], | ||
{ | ||
languageOptions: { | ||
globals: { | ||
...globals.browser, | ||
...globals.commonjs, | ||
jQuery: true, | ||
}, | ||
}, | ||
|
||
plugins: { | ||
jsdoc, | ||
}, | ||
|
||
rules: { | ||
"array-bracket-spacing": ["error", "never"], | ||
"block-scoped-var": "error", | ||
"comma-spacing": "error", | ||
"comma-style": ["error", "last"], | ||
"computed-property-spacing": ["error", "never"], | ||
curly: ["error", "all"], | ||
"eol-last": "error", | ||
eqeqeq: ["error", "smart"], | ||
"guard-for-in": "error", | ||
|
||
"key-spacing": [ | ||
"error", | ||
{ | ||
beforeColon: false, | ||
afterColon: true, | ||
}, | ||
], | ||
|
||
"keyword-spacing": [ | ||
"error", | ||
{ | ||
before: true, | ||
after: true, | ||
}, | ||
], | ||
|
||
"linebreak-style": ["error", "unix"], | ||
|
||
"lines-around-comment": [ | ||
"error", | ||
{ | ||
beforeBlockComment: true, | ||
afterBlockComment: false, | ||
}, | ||
], | ||
|
||
"new-parens": "error", | ||
"no-array-constructor": "error", | ||
"no-caller": "error", | ||
"no-catch-shadow": "error", | ||
"no-eval": "error", | ||
"no-extend-native": "error", | ||
"no-extra-bind": "error", | ||
"no-extra-parens": ["error", "functions"], | ||
"no-implied-eval": "error", | ||
"no-iterator": "error", | ||
"no-label-var": "error", | ||
"no-labels": "error", | ||
"no-lone-blocks": "error", | ||
"no-loop-func": "error", | ||
"no-multi-spaces": "error", | ||
"no-multi-str": "error", | ||
"no-native-reassign": "error", | ||
"no-nested-ternary": "error", | ||
"no-new-func": "error", | ||
"no-new-object": "error", | ||
"no-new-wrappers": "error", | ||
"no-octal-escape": "error", | ||
"no-process-exit": "error", | ||
"no-proto": "error", | ||
"no-return-assign": "error", | ||
"no-script-url": "error", | ||
"no-sequences": "error", | ||
"no-shadow-restricted-names": "error", | ||
"no-spaced-func": "error", | ||
"no-trailing-spaces": "error", | ||
"no-undef-init": "error", | ||
"no-undefined": "error", | ||
"no-unused-expressions": "error", | ||
|
||
"no-unused-vars": [ | ||
"error", | ||
{ | ||
vars: "all", | ||
args: "none", | ||
}, | ||
], | ||
|
||
"no-with": "error", | ||
"one-var": ["error", "never"], | ||
semi: ["error", "always"], | ||
|
||
"semi-spacing": [ | ||
"error", | ||
{ | ||
before: false, | ||
after: true, | ||
}, | ||
], | ||
|
||
"space-before-blocks": ["error", "always"], | ||
|
||
"space-before-function-paren": [ | ||
"error", | ||
{ | ||
anonymous: "always", | ||
named: "never", | ||
}, | ||
], | ||
|
||
"space-in-parens": ["error", "never"], | ||
"space-infix-ops": "error", | ||
|
||
"space-unary-ops": [ | ||
"error", | ||
{ | ||
words: true, | ||
nonwords: false, | ||
}, | ||
], | ||
|
||
"spaced-comment": ["error", "always"], | ||
strict: ["error", "function"], | ||
yoda: ["error", "never"], | ||
"max-nested-callbacks": ["warn", 3], | ||
"jsdoc/require-description": "warn", | ||
"jsdoc/tag-lines": ["off", "never"], | ||
}, | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.