Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 0 additions & 88 deletions .eslintrc.json

This file was deleted.

120 changes: 120 additions & 0 deletions eslint.config.js
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'
Comment on lines +69 to +70
Copy link
Collaborator Author

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

},
},
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
Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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',
Copy link
Collaborator Author

@gkjohnson gkjohnson Dec 4, 2025

Choose a reason for hiding this comment

The 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'
}
}
];
25 changes: 14 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Collaborator Author

@gkjohnson gkjohnson Dec 4, 2025

Choose a reason for hiding this comment

The 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 eslint . so the whole project is validated.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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",
Expand Down Expand Up @@ -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",
Expand Down
Loading