-
Notifications
You must be signed in to change notification settings - Fork 83
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
Changes from all commits
8848cd9
b68101d
f338321
be57b1a
8d0b946
30770e4
5d7ca43
b1dcab2
517717f
24116e1
c0b97ba
3795ddb
e56dc93
e333f9c
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/**/*' | ||
]) | ||
); |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,7 @@ | |
import styles from './library.css'; | ||
|
||
const localStorageAvailable = | ||
'localStorage' in window && window.localStorage !== null; | ||
'localStorage' in window && window.localStorage !== null; | ||
|
||
const messages = defineMessages({ | ||
filterPlaceholder: { | ||
|
@@ -67,10 +67,10 @@ | |
const ALL_TAG = {tag: 'all', intlLabel: messages.allTag}; | ||
const tagListPrefix = [ALL_TAG]; | ||
|
||
/** | ||
Check warning on line 70 in packages/scratch-gui/src/components/library/library.jsx
|
||
* Find the AssetType which corresponds to a particular file extension. For example, 'png' => AssetType.ImageBitmap. | ||
* @param {string} fileExtension - the file extension to look up. | ||
* @returns {AssetType} - the AssetType corresponding to the extension, if any. | ||
Check warning on line 73 in packages/scratch-gui/src/components/library/library.jsx
|
||
*/ | ||
const getAssetTypeForFileExtension = function (fileExtension) { | ||
const compareOptions = { | ||
|
@@ -86,7 +86,7 @@ | |
} | ||
}; | ||
|
||
/** | ||
Check warning on line 89 in packages/scratch-gui/src/components/library/library.jsx
|
||
* Figure out one or more icon(s) for a library item. | ||
* If it's an animated thumbnail, this will return an array of `imageSource`. | ||
* Otherwise it'll return just one `imageSource`. | ||
|
@@ -211,7 +211,7 @@ | |
this.driver.destroy(); | ||
this.driver = null; | ||
} | ||
|
||
if (this.animationFrameId) { | ||
window.cancelAnimationFrame(this.animationFrameId); | ||
} | ||
|
@@ -225,18 +225,18 @@ | |
if (this.driver) { | ||
this.driver.refresh(); | ||
} | ||
|
||
this.animationFrameId = null; | ||
}); | ||
} | ||
handleSelect (id) { | ||
const selectedItem = this.getFilteredData().find(item => this.constructKey(item) === id); | ||
|
||
if (this.state.shouldShowFaceSensingCallout && selectedItem.extensionId === 'faceSensing') { | ||
if (!this.driver) { | ||
return; | ||
} | ||
|
||
setHasUsedFaceSensing(this.props.username); | ||
this.setState({ | ||
shouldShowFaceSensingCallout: false | ||
|
@@ -468,7 +468,7 @@ | |
|
||
LibraryComponent.propTypes = { | ||
data: PropTypes.arrayOf( | ||
/* eslint-disable react/no-unused-prop-types, lines-around-comment */ | ||
// An item in the library | ||
PropTypes.shape({ | ||
// @todo remove md5/rawURL prop from library, refactor to use storage | ||
|
@@ -479,7 +479,7 @@ | |
]), | ||
rawURL: PropTypes.string | ||
}) | ||
/* eslint-enable react/no-unused-prop-types, lines-around-comment */ | ||
), | ||
filterable: PropTypes.bool, | ||
withCategories: PropTypes.bool, | ||
|
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.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 figured it out, at least partially:
[email protected]
requirestypescript@^2.4.1
, but@typescript-eslint/eslint-plugin
requirestypescript>=4.8.4 <6.0.0
. Npm "helpfully" resolves this by (among other things) providing a newerjest-cli
toscratch-gui
than the[email protected]
thatscratch-gui/package.json
asks for. Bringing in a newer version of Jest introduces several new requirements that seem to be met by properly updatingjest
andts-jest
.There are still a few holes in my understanding here, like why npm makes available a version of
jest
that doesn't matchpackage.json
instead of throwing an error, but I'm at least closer to understanding it 😅