-
-
Notifications
You must be signed in to change notification settings - Fork 36.1k
Dev: Migrate to ESLint 9, flat config #32471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from 4 commits
93eedb1
d1d8d20
0a951b1
b5fed08
14188cd
7b79d99
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| import js from '@eslint/js'; | ||
| import globals from 'globals'; | ||
| import mdcs from 'eslint-config-mdcs'; | ||
| import compat from 'eslint-plugin-compat'; | ||
| import html from 'eslint-plugin-html'; | ||
| import importPlugin from 'eslint-plugin-import'; | ||
| import jsdoc from 'eslint-plugin-jsdoc'; | ||
|
|
||
| export default [ | ||
| // files to ignore | ||
| { | ||
| name: 'files to ignore', | ||
| ignores: [ | ||
| '**/node_modules/**', | ||
| '**/build/**', | ||
| '**/libs/**', | ||
| '**/ifc/**', | ||
| '**/prettify.js', | ||
| '**/prettify/**', | ||
| '**/3rdparty/**', | ||
| '**/shapefile.js', | ||
| '**/vendor/**', | ||
| '**/fuse/**' | ||
| ] | ||
| }, | ||
|
|
||
| // recommended | ||
| js.configs.recommended, | ||
| // jsdoc.configs['flat/recommended'], | ||
|
|
||
| // base rules | ||
| { | ||
| name: 'base rules', | ||
| files: [ '**/*.js', '**/*.html' ], | ||
| plugins: { | ||
| html, | ||
| import: importPlugin, | ||
| compat, | ||
| jsdoc | ||
| }, | ||
| languageOptions: { | ||
| ecmaVersion: 2018, | ||
| sourceType: 'module', | ||
| globals: { | ||
| ...globals.browser, | ||
| ...globals.node, | ||
| ...globals.es2017, | ||
| __THREE_DEVTOOLS__: 'readonly', | ||
| potpack: 'readonly', | ||
| fflate: 'readonly', | ||
| Stats: 'readonly', | ||
| XRWebGLBinding: 'readonly', | ||
| XRWebGLLayer: 'readonly', | ||
| GPUShaderStage: 'readonly', | ||
| GPUBufferUsage: 'readonly', | ||
| GPUTextureUsage: 'readonly', | ||
| GPUTexture: 'readonly', | ||
| GPUMapMode: 'readonly', | ||
| QUnit: 'readonly', | ||
| Ammo: 'readonly', | ||
| XRRigidTransform: 'readonly', | ||
| XRMediaBinding: 'readonly', | ||
| CodeMirror: 'readonly', | ||
| esprima: 'readonly', | ||
| jsonlint: 'readonly', | ||
| VideoFrame: 'readonly', | ||
| VideoDecoder: 'readonly', | ||
| Float16Array: 'readonly', | ||
| BigInt: 'readonly', | ||
| BigUint64Array: 'readonly' | ||
| }, | ||
| }, | ||
| settings: { | ||
| polyfills: [ | ||
| 'WebGL2RenderingContext' | ||
| ], | ||
| jsdoc: { | ||
| preferredTypes: { | ||
| Any: 'any', | ||
| Boolean: 'boolean', | ||
| Number: 'number', | ||
| object: 'Object', | ||
| String: 'string' | ||
| }, | ||
| tagNamePreference: { | ||
| returns: 'return', | ||
| augments: 'augments', | ||
| extends: 'augments' | ||
| }, | ||
| }, | ||
| }, | ||
| rules: { | ||
| ...mdcs.rules, | ||
| ...compat.configs.recommended.rules, | ||
| 'no-throw-literal': 'error', | ||
| 'quotes': [ 'error', 'single' ], | ||
| 'prefer-const': [ 'error', { | ||
| destructuring: 'any', | ||
| ignoreReadBeforeAssign: false | ||
| } ], | ||
| 'no-irregular-whitespace': 'error', | ||
| 'no-duplicate-imports': 'error', | ||
| 'prefer-spread': 'error', | ||
|
|
||
| 'no-useless-escape': 'off', | ||
| 'no-case-declarations': 'off', | ||
| 'no-cond-assign': 'off', | ||
| 'getter-return': 'off', | ||
| 'no-async-promise-executor': 'off', | ||
| 'no-empty': 'off', | ||
|
Comment on lines
+104
to
+109
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I turned these off because they seemed to be new rules and were causing lint errors / warnings. It may be worth considering adjusting the codebase and turning these on. |
||
|
|
||
| // 'jsdoc/check-types': 'error', | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When this is enabled there are some errors in the JSDoc comments that are caught. I'll leave it to another contribution to re-enable and fix these. It may be worth enabling the JSDoc "recommended" settings above to see if there are any rules worth keeping from there, too. |
||
| 'jsdoc/require-returns': 'off', | ||
| 'jsdoc/require-returns-type': 'error', | ||
| 'jsdoc/require-param-description': 'off', | ||
| 'jsdoc/require-returns-description': 'off', | ||
| 'jsdoc/require-param-type': 'error' | ||
| } | ||
| } | ||
| ]; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,14 +53,14 @@ | |
| "preview": "concurrently --names \"ROLLUP,HTTP\" -c \"bgBlue.bold,bgGreen.bold\" \"rollup -c utils/build/rollup.config.js -w -m inline\" \"servez -p 8080\"", | ||
| "preview-ssl": "concurrently --names \"ROLLUP,HTTPS\" -c \"bgBlue.bold,bgGreen.bold\" \"rollup -c utils/build/rollup.config.js -w -m inline\" \"servez -p 8080 --ssl\"", | ||
| "lint-core": "eslint src", | ||
| "lint-addons": "eslint examples/jsm --ext .js --ignore-pattern libs --ignore-pattern ifc", | ||
| "lint-examples": "eslint examples --ext .html", | ||
| "lint-docs": "eslint docs --ignore-pattern prettify.js", | ||
| "lint-editor": "eslint editor --ignore-pattern libs", | ||
| "lint-playground": "eslint playground --ignore-pattern libs", | ||
| "lint-manual": "eslint manual --ignore-pattern 3rdparty --ignore-pattern prettify.js --ignore-pattern shapefile.js", | ||
| "lint-test": "eslint test --ignore-pattern vendor", | ||
| "lint-utils": "eslint utils --ignore-pattern prettify --ignore-pattern fuse", | ||
| "lint-addons": "eslint examples/jsm", | ||
| "lint-examples": "eslint examples", | ||
| "lint-docs": "eslint docs", | ||
| "lint-editor": "eslint editor", | ||
| "lint-playground": "eslint playground", | ||
| "lint-manual": "eslint manual", | ||
| "lint-test": "eslint test", | ||
| "lint-utils": "eslint utils", | ||
|
Comment on lines
-56
to
+63
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since ignore patterns are included in the config, now, it's possible we can merge these commands together and let the user specify any sub folder checks themselves. I can look into adding these back if they're preferred, though. My "lint" scripts are set to
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Mugen87 I see you've 👍 the comment - do you want me to change anything here? |
||
| "lint": "npm run lint-core", | ||
| "lint-fix": "npm run lint-core -- --fix && npm run lint-addons -- --fix && npm run lint-examples -- --fix && npm run lint-docs -- --fix && npm run lint-editor -- --fix && npm run lint-playground -- --fix && npm run lint-manual -- --fix && npm run lint-test -- --fix && npm run lint-utils -- --fix", | ||
| "test-unit": "qunit test/unit/three.source.unit.js", | ||
|
|
@@ -94,14 +94,17 @@ | |
| }, | ||
| "homepage": "https://threejs.org/", | ||
| "devDependencies": { | ||
| "@eslint/js": "^9.0.0", | ||
| "@rollup/plugin-node-resolve": "^16.0.0", | ||
| "@rollup/plugin-terser": "^0.4.0", | ||
| "concurrently": "^9.0.0", | ||
| "eslint": "^8.37.0", | ||
| "eslint": "^9.0.0", | ||
| "eslint-config-mdcs": "^5.0.0", | ||
| "eslint-plugin-compat": "^6.0.0", | ||
| "eslint-plugin-html": "^8.0.0", | ||
| "eslint-plugin-import": "^2.27.5", | ||
| "eslint-plugin-html": "^8.1.3", | ||
| "eslint-plugin-import": "^2.32.0", | ||
| "eslint-plugin-jsdoc": "^61.4.1", | ||
| "globals": "^16.5.0", | ||
| "jimp": "^1.6.0", | ||
| "jsdoc": "^4.0.5", | ||
| "magic-string": "^0.30.0", | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These lines have been newly added