Skip to content

Commit 6662051

Browse files
authored
Merge pull request #327 from scratchfoundation/eslint-9-scratch-12
Update to eslint v9 and eslint-config-scratch v12
2 parents 893c679 + e333f9c commit 6662051

File tree

243 files changed

+23625
-20047
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

243 files changed

+23625
-20047
lines changed

package-lock.json

Lines changed: 21890 additions & 18363 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/scratch-gui/.eslintignore

Lines changed: 0 additions & 5 deletions
This file was deleted.

packages/scratch-gui/.eslintrc.js

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
import {eslintConfigScratch} from 'eslint-config-scratch';
2+
import {globalIgnores} from 'eslint/config';
3+
import globals from 'globals';
4+
import importPlugin from 'eslint-plugin-import';
5+
import path from 'path';
6+
7+
export default eslintConfigScratch.defineConfig(
8+
eslintConfigScratch.legacy.base,
9+
importPlugin.flatConfigs.errors,
10+
{
11+
files: ['*.{js,cjs,mjs,ts}', 'scripts/**/*.{js,cjs,mjs,ts}'],
12+
extends: [eslintConfigScratch.legacy.node],
13+
languageOptions: {
14+
globals: globals.node
15+
},
16+
rules: {
17+
'no-console': 'off'
18+
},
19+
settings: {
20+
// TODO: figure out why this is needed...
21+
// probably something with eslint-plugin-import's parser or resolver
22+
'import/core-modules': [
23+
'eslint/config'
24+
]
25+
}
26+
},
27+
{
28+
files: ['{src,test}/**/*.{js,cjs,mjs,jsx,ts,tsx}'],
29+
extends: [
30+
eslintConfigScratch.legacy.es6,
31+
eslintConfigScratch.legacy.react,
32+
eslintConfigScratch.legacy.typescript
33+
],
34+
languageOptions: {
35+
globals: {
36+
...globals.browser,
37+
process: 'readonly'
38+
},
39+
parserOptions: {
40+
projectService: false,
41+
tsconfigRootDir: import.meta.dirname,
42+
project: [
43+
'tsconfig.json',
44+
'tsconfig.test.json'
45+
]
46+
}
47+
},
48+
settings: {
49+
'react': {
50+
version: 'detect'
51+
},
52+
'import/resolver': {
53+
webpack: {
54+
config: path.resolve(import.meta.dirname, 'webpack.config.js')
55+
}
56+
}
57+
},
58+
rules: {
59+
// BEGIN: these caused trouble after upgrading eslint-plugin-react from 7.24.0 to 7.33.2
60+
'react/forbid-prop-types': 'warn',
61+
'react/no-unknown-property': 'warn',
62+
// END: these caused trouble after upgrading eslint-plugin-react from 7.24.0 to 7.33.2
63+
64+
// we should probably just fix these...
65+
'arrow-parens': 'warn',
66+
'react/no-deprecated': 'warn',
67+
'require-atomic-updates': 'warn',
68+
'@typescript-eslint/no-unused-vars': ['warn', {
69+
args: 'after-used',
70+
caughtErrors: 'none', // TODO: use caughtErrorsPattern instead
71+
varsIgnorePattern: '^_'
72+
}],
73+
'@typescript-eslint/no-use-before-define': 'warn',
74+
'@typescript-eslint/prefer-promise-reject-errors': 'warn'
75+
}
76+
},
77+
{
78+
files: ['test/**/*.{js,cjs,mjs,jsx,ts,tsx}'],
79+
languageOptions: {
80+
globals: {
81+
...globals.jest,
82+
...globals.node
83+
}
84+
},
85+
rules: {
86+
'max-len': [
87+
'warn',
88+
// settings copied from eslint-config-scratch.legacy.base
89+
{
90+
code: 120,
91+
tabWidth: 4,
92+
ignoreUrls: true
93+
}
94+
],
95+
'react/prop-types': 'off' // don't worry about prop types in tests
96+
}
97+
},
98+
{
99+
files: ['{src,test}/**/*.{ts,tsx}'],
100+
rules: {
101+
// TODO: get TS parsing to work with eslint-plugin-import
102+
'import/named': 'off'
103+
}
104+
},
105+
{
106+
// disable some checks for these generated files
107+
files: ['{src,test}/**/types.d.ts'],
108+
rules: {
109+
'@stylistic/indent': 'off'
110+
}
111+
},
112+
{
113+
files: [
114+
'src/lib/libraries/extensions/index.jsx',
115+
'src/lib/libraries/decks/*.js'
116+
],
117+
rules: {
118+
// the way these files are built makes duplicate imports the natural way to do things
119+
'no-duplicate-imports': 'off'
120+
}
121+
},
122+
{
123+
files: ['test/unit/util/define-dynamic-block.test.js'],
124+
settings: {
125+
// TODO: figure out why this is needed...
126+
// probably something with eslint-plugin-import's parser or resolver
127+
'import/core-modules': [
128+
'@scratch/scratch-vm/src/extension-support/block-type'
129+
]
130+
}
131+
},
132+
globalIgnores([
133+
'build/**/*',
134+
'dist/**/*',
135+
'node_modules/**/*'
136+
])
137+
);

packages/scratch-gui/package.json

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"start": "webpack serve",
5252
"test": "npm run test:lint && npm run test:unit && npm run test:integration",
5353
"test:integration": "cross-env JEST_JUNIT_OUTPUT_NAME=integration-tests-results.xml jest --maxWorkers=4 test[\\\\/]integration",
54-
"test:lint": "eslint . --ext .js,.jsx,.ts,.tsx",
54+
"test:lint": "eslint",
5555
"test:unit": "cross-env JEST_JUNIT_OUTPUT_NAME=unit-tests-results.xml jest test[\\\\/]unit",
5656
"test:smoke": "jest --runInBand test[\\\\/]smoke",
5757
"watch": "webpack --watch"
@@ -60,12 +60,12 @@
6060
"@mediapipe/face_detection": "0.4.1646425229",
6161
"@microbit/microbit-universal-hex": "0.2.2",
6262
"@radix-ui/react-context-menu": "^2.2.5",
63-
"@testing-library/user-event": "^14.6.1",
6463
"@scratch/scratch-render": "11.6.0",
6564
"@scratch/scratch-svg-renderer": "11.6.0",
6665
"@scratch/scratch-vm": "11.6.0",
6766
"@tensorflow-models/face-detection": "^1.0.3",
6867
"@tensorflow/tfjs": "^4.22.0",
68+
"@testing-library/user-event": "^14.6.1",
6969
"arraybuffer-loader": "1.0.8",
7070
"autoprefixer": "9.8.8",
7171
"balance-text": "3.3.1",
@@ -123,8 +123,8 @@
123123
"scratch-storage": "4.1.16",
124124
"startaudiocontext": "1.2.1",
125125
"style-loader": "4.0.0",
126-
"to-style": "1.3.3",
127126
"text-encoding": "0.7.0",
127+
"to-style": "1.3.3",
128128
"wav-encoder": "1.3.0",
129129
"xhr": "2.6.0"
130130
},
@@ -137,29 +137,27 @@
137137
"devDependencies": {
138138
"@babel/cli": "7.28.3",
139139
"@babel/core": "7.28.4",
140-
"@babel/eslint-parser": "7.28.4",
141140
"@babel/preset-env": "7.28.3",
142141
"@babel/preset-react": "7.27.1",
143142
"@testing-library/jest-dom": "^5.16.5",
144143
"@testing-library/react": "^14.0.0",
144+
"@types/jest": "^25.2.3",
145145
"@types/prop-types": "15.7.15",
146146
"@types/react-modal": "3.16.3",
147-
"@typescript-eslint/eslint-plugin": "8.7.0",
148-
"@typescript-eslint/parser": "8.7.0",
149147
"babel-core": "7.0.0-bridge.0",
150148
"babel-loader": "9.2.1",
149+
"buffer": "^6.0.3",
151150
"cheerio": "1.1.2",
152151
"cross-env": "7.0.3",
153-
"eslint": "8.57.1",
154-
"eslint-config-scratch": "9.0.9",
155-
"eslint-import-resolver-webpack": "0.11.1",
156-
"eslint-plugin-import": "2.32.0",
157-
"eslint-plugin-jest": "22.21.0",
158-
"eslint-plugin-react": "7.37.5",
152+
"eslint": "9.37.0",
153+
"eslint-config-scratch": "^12.0.8",
154+
"eslint-import-resolver-webpack": "^0.13.10",
155+
"eslint-plugin-import": "^2.32.0",
156+
"eslint-plugin-react": "^7.37.5",
159157
"file-loader": "6.2.0",
160158
"gh-pages": "3.2.3",
161159
"html-webpack-plugin": "5.6.4",
162-
"jest": "21.2.1",
160+
"jest": "^25.5.4",
163161
"jest-junit": "7.0.0",
164162
"mkdirp": "1.0.4",
165163
"raf": "3.4.1",
@@ -171,7 +169,7 @@
171169
"selenium-webdriver": "3.6.0",
172170
"semantic-release": "19.0.5",
173171
"stream-browserify": "3.0.0",
174-
"ts-jest": "21.2.4",
172+
"ts-jest": "^25.5.1",
175173
"ts-loader": "9.5.4",
176174
"url-loader": "4.1.1",
177175
"web-audio-test-api": "0.5.2",

packages/scratch-gui/scripts/.eslintrc.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

packages/scratch-gui/src/.eslintrc.js

Lines changed: 0 additions & 60 deletions
This file was deleted.

packages/scratch-gui/src/components/extension-button/extension-button.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const messages = defineMessages({
3333
});
3434

3535
const localStorageAvailable =
36-
'localStorage' in window && window.localStorage !== null;
36+
'localStorage' in window && window.localStorage !== null;
3737

3838
// Default to true to make sure we don't end up showing the feature
3939
// callouts multiple times if localStorage isn't available.

packages/scratch-gui/src/components/library-item/library-item.jsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import internetConnectionIconURL from './internet-connection.svg';
1515

1616
import {PLATFORM} from '../../lib/platform.js';
1717

18-
/* eslint-disable react/prefer-stateless-function */
18+
1919
class LibraryItemComponent extends React.PureComponent {
2020
constructor (props) {
2121
super(props);
@@ -178,7 +178,6 @@ class LibraryItemComponent extends React.PureComponent {
178178
);
179179
}
180180
}
181-
/* eslint-enable react/prefer-stateless-function */
182181

183182

184183
LibraryItemComponent.propTypes = {

packages/scratch-gui/src/components/library/library.jsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {getLocalStorageValue, setLocalStorageValue} from '../../lib/local-storag
2121
import styles from './library.css';
2222

2323
const localStorageAvailable =
24-
'localStorage' in window && window.localStorage !== null;
24+
'localStorage' in window && window.localStorage !== null;
2525

2626
const messages = defineMessages({
2727
filterPlaceholder: {
@@ -211,7 +211,7 @@ class LibraryComponent extends React.Component {
211211
this.driver.destroy();
212212
this.driver = null;
213213
}
214-
214+
215215
if (this.animationFrameId) {
216216
window.cancelAnimationFrame(this.animationFrameId);
217217
}
@@ -225,18 +225,18 @@ class LibraryComponent extends React.Component {
225225
if (this.driver) {
226226
this.driver.refresh();
227227
}
228-
228+
229229
this.animationFrameId = null;
230230
});
231231
}
232232
handleSelect (id) {
233233
const selectedItem = this.getFilteredData().find(item => this.constructKey(item) === id);
234-
234+
235235
if (this.state.shouldShowFaceSensingCallout && selectedItem.extensionId === 'faceSensing') {
236236
if (!this.driver) {
237237
return;
238238
}
239-
239+
240240
setHasUsedFaceSensing(this.props.username);
241241
this.setState({
242242
shouldShowFaceSensingCallout: false
@@ -468,7 +468,7 @@ class LibraryComponent extends React.Component {
468468

469469
LibraryComponent.propTypes = {
470470
data: PropTypes.arrayOf(
471-
/* eslint-disable react/no-unused-prop-types, lines-around-comment */
471+
472472
// An item in the library
473473
PropTypes.shape({
474474
// @todo remove md5/rawURL prop from library, refactor to use storage
@@ -479,7 +479,7 @@ LibraryComponent.propTypes = {
479479
]),
480480
rawURL: PropTypes.string
481481
})
482-
/* eslint-enable react/no-unused-prop-types, lines-around-comment */
482+
483483
),
484484
filterable: PropTypes.bool,
485485
withCategories: PropTypes.bool,

0 commit comments

Comments
 (0)