-
Notifications
You must be signed in to change notification settings - Fork 75
Update to eslint v9 and eslint-config-scratch v12 #327
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: develop
Are you sure you want to change the base?
Changes from all commits
e315e7f
e600f6e
a41bfff
4c95981
1906ac4
4a655f5
64a358a
43c2233
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
import {eslintConfigScratch} from 'eslint-config-scratch'; | ||
import {globalIgnores} from 'eslint/config'; | ||
import globals from 'globals'; | ||
import importPlugin from 'eslint-plugin-import'; | ||
import path from 'path'; | ||
|
||
export default eslintConfigScratch.defineConfig( | ||
eslintConfigScratch.legacy.base, | ||
importPlugin.flatConfigs.errors, | ||
{ | ||
files: ['*.{js,cjs,mjs,ts}', 'scripts/**/*.{js,cjs,mjs,ts}'], | ||
extends: [eslintConfigScratch.legacy.node], | ||
languageOptions: { | ||
globals: globals.node | ||
}, | ||
rules: { | ||
'no-console': 'off' | ||
}, | ||
settings: { | ||
// TODO: figure out why this is needed... | ||
// probably something with eslint-plugin-import's parser or resolver | ||
'import/core-modules': [ | ||
'eslint/config' | ||
] | ||
} | ||
}, | ||
{ | ||
files: ['{src,test}/**/*.{js,cjs,mjs,jsx,ts,tsx}'], | ||
extends: [ | ||
eslintConfigScratch.legacy.es6, | ||
eslintConfigScratch.legacy.react, | ||
eslintConfigScratch.legacy.typescript | ||
], | ||
languageOptions: { | ||
globals: { | ||
...globals.browser, | ||
process: 'readonly' | ||
}, | ||
parserOptions: { | ||
projectService: false, | ||
tsconfigRootDir: import.meta.dirname, | ||
project: [ | ||
'tsconfig.json', | ||
'tsconfig.test.json' | ||
] | ||
} | ||
}, | ||
settings: { | ||
'react': { | ||
version: 'detect' | ||
}, | ||
'import/resolver': { | ||
webpack: { | ||
config: path.resolve(import.meta.dirname, 'webpack.config.js') | ||
} | ||
} | ||
}, | ||
rules: { | ||
// BEGIN: these caused trouble after upgrading eslint-plugin-react from 7.24.0 to 7.33.2 | ||
'react/forbid-prop-types': 'warn', | ||
'react/no-unknown-property': 'warn', | ||
// END: these caused trouble after upgrading eslint-plugin-react from 7.24.0 to 7.33.2 | ||
|
||
// we should probably just fix these... | ||
'arrow-parens': 'warn', | ||
'react/no-deprecated': 'warn', | ||
'require-atomic-updates': 'warn', | ||
'@typescript-eslint/no-unused-vars': ['warn', { | ||
args: 'after-used', | ||
caughtErrors: 'none', // TODO: use caughtErrorsPattern instead | ||
varsIgnorePattern: '^_' | ||
}], | ||
'@typescript-eslint/no-use-before-define': 'warn', | ||
'@typescript-eslint/prefer-promise-reject-errors': 'warn' | ||
} | ||
}, | ||
{ | ||
files: ['test/**/*.{js,cjs,mjs,jsx,ts,tsx}'], | ||
languageOptions: { | ||
globals: { | ||
...globals.jest, | ||
...globals.node | ||
} | ||
}, | ||
rules: { | ||
'max-len': [ | ||
'warn', | ||
// settings copied from eslint-config-scratch.legacy.base | ||
{ | ||
code: 120, | ||
tabWidth: 4, | ||
ignoreUrls: true | ||
} | ||
], | ||
'react/prop-types': 'off' // don't worry about prop types in tests | ||
} | ||
}, | ||
{ | ||
files: ['{src,test}/**/*.{ts,tsx}'], | ||
rules: { | ||
// TODO: get TS parsing to work with eslint-plugin-import | ||
'import/named': 'off' | ||
} | ||
}, | ||
{ | ||
// disable some checks for these generated files | ||
files: ['{src,test}/**/types.d.ts'], | ||
rules: { | ||
'@stylistic/indent': 'off' | ||
} | ||
}, | ||
{ | ||
files: [ | ||
'src/lib/libraries/extensions/index.jsx', | ||
'src/lib/libraries/decks/*.js' | ||
], | ||
rules: { | ||
// the way these files are built makes duplicate imports the natural way to do things | ||
'no-duplicate-imports': 'off' | ||
} | ||
}, | ||
{ | ||
files: ['test/unit/util/define-dynamic-block.test.js'], | ||
settings: { | ||
// TODO: figure out why this is needed... | ||
// probably something with eslint-plugin-import's parser or resolver | ||
'import/core-modules': [ | ||
'@scratch/scratch-vm/src/extension-support/block-type' | ||
] | ||
} | ||
}, | ||
globalIgnores([ | ||
'build/**/*', | ||
'dist/**/*', | ||
'node_modules/**/*' | ||
]) | ||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,7 +51,7 @@ | |
"start": "webpack serve", | ||
"test": "npm run test:lint && npm run test:unit && npm run test:integration", | ||
"test:integration": "cross-env JEST_JUNIT_OUTPUT_NAME=integration-tests-results.xml jest --maxWorkers=4 test[\\\\/]integration", | ||
"test:lint": "eslint . --ext .js,.jsx,.ts,.tsx", | ||
"test:lint": "eslint", | ||
"test:unit": "cross-env JEST_JUNIT_OUTPUT_NAME=unit-tests-results.xml jest test[\\\\/]unit", | ||
"test:smoke": "jest --runInBand test[\\\\/]smoke", | ||
"watch": "webpack --watch" | ||
|
@@ -117,8 +117,8 @@ | |
"scratch-storage": "4.0.229", | ||
"startaudiocontext": "1.2.1", | ||
"style-loader": "4.0.0", | ||
"to-style": "1.3.3", | ||
"text-encoding": "0.7.0", | ||
"to-style": "1.3.3", | ||
"wav-encoder": "1.3.0", | ||
"xhr": "2.6.0" | ||
}, | ||
|
@@ -131,29 +131,27 @@ | |
"devDependencies": { | ||
"@babel/cli": "7.28.3", | ||
"@babel/core": "7.28.4", | ||
"@babel/eslint-parser": "7.28.4", | ||
"@babel/preset-env": "7.28.3", | ||
"@babel/preset-react": "7.27.1", | ||
"@types/jest": "^25.2.3", | ||
"@types/prop-types": "15.7.15", | ||
"@types/react-modal": "3.16.3", | ||
"@typescript-eslint/eslint-plugin": "8.7.0", | ||
"@typescript-eslint/parser": "8.7.0", | ||
"babel-core": "7.0.0-bridge.0", | ||
"babel-loader": "9.2.1", | ||
"buffer": "^6.0.3", | ||
"cheerio": "1.0.0-rc.3", | ||
"cross-env": "7.0.3", | ||
"enzyme": "3.11.0", | ||
"enzyme-adapter-react-16": "1.15.8", | ||
"eslint": "8.57.1", | ||
"eslint-config-scratch": "9.0.9", | ||
"eslint-import-resolver-webpack": "0.11.1", | ||
"eslint-plugin-import": "2.32.0", | ||
"eslint-plugin-jest": "22.21.0", | ||
"eslint-plugin-react": "7.37.5", | ||
"eslint": "9.35.0", | ||
"eslint-config-scratch": "^12.0.0", | ||
"eslint-import-resolver-webpack": "^0.13.10", | ||
"eslint-plugin-import": "^2.32.0", | ||
"eslint-plugin-react": "^7.37.5", | ||
"file-loader": "6.2.0", | ||
"gh-pages": "3.2.3", | ||
"html-webpack-plugin": "5.6.4", | ||
"jest": "21.2.1", | ||
"jest": "^25.5.4", | ||
"jest-junit": "7.0.0", | ||
"mkdirp": "1.0.4", | ||
"raf": "3.4.1", | ||
|
@@ -165,7 +163,7 @@ | |
"selenium-webdriver": "3.6.0", | ||
"semantic-release": "19.0.5", | ||
"stream-browserify": "3.0.0", | ||
"ts-jest": "21.2.4", | ||
"ts-jest": "^25.5.1", | ||
"ts-loader": "9.5.4", | ||
"url-loader": "4.1.1", | ||
"web-audio-test-api": "0.5.2", | ||
|
@@ -200,7 +198,8 @@ | |
"moduleNameMapper": { | ||
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)\\??$": "<rootDir>/test/__mocks__/fileMock.js", | ||
"\\.(css|less)$": "<rootDir>/test/__mocks__/styleMock.js", | ||
"editor-msgs(\\.js)?$": "<rootDir>/test/__mocks__/editor-msgs-mock.js" | ||
"editor-msgs(\\.js)?$": "<rootDir>/test/__mocks__/editor-msgs-mock.js", | ||
"^@scratch/scratch-svg-renderer$": "<rootDir>/../scratch-svg-renderer/src/" | ||
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. Just curious - why did we end up needing this for svg-renderer, but not for e.g. -vm |
||
}, | ||
"moduleFileExtensions": [ | ||
"ts", | ||
|
This file was deleted.
This file was deleted.
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.
I was surprised to find that I had to update
jest
andts-jest
to get this all to work. I'm not sure exactly what the interaction was, but once I updated all theeslint
-related things,jest
started to fail with a parse error.