-
Notifications
You must be signed in to change notification settings - Fork 24
[code-infra] Bring eslint configuration from core and bump to v9 #344
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
65af21f
50ba1d1
177341c
e9a38f1
6c37967
5c6c6a7
cbed7a0
8e38a0c
2c927bb
dec1337
0995a43
02f377b
8325712
ecc1732
411a3e5
91558b2
f809e3e
1ed5382
8ebc51c
fc981ad
1951e21
0e81f96
166e6ba
25602c5
3184c51
ce9fc86
662ac60
87a8b6e
9ecb7aa
25e0ca8
2abae5e
80e0f7a
3459f4b
17df0d4
0d01b02
6c49f14
9f1eda1
0195e3c
097bbf0
3951914
2f85ab7
639e12f
60b8151
d506e27
3d86cb1
44868b5
c13e40a
535cd45
e909514
03067f8
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,3 @@ | ||
{ | ||
"eslint.useFlatConfig": true | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { includeIgnoreFile } from '@eslint/compat'; | ||
import { defineConfig } from 'eslint/config'; | ||
import * as path from 'node:path'; | ||
import { fileURLToPath } from 'node:url'; | ||
import { | ||
createBaseConfig, | ||
createTestConfig, | ||
EXTENSION_TEST_FILE, | ||
} from '@mui/internal-code-infra/eslint'; | ||
|
||
const filename = fileURLToPath(import.meta.url); | ||
const dirname = path.dirname(filename); | ||
|
||
export default defineConfig( | ||
includeIgnoreFile(path.join(dirname, '.gitignore')), | ||
includeIgnoreFile(path.join(dirname, '.eslintignore')), | ||
{ | ||
name: 'Base config', | ||
extends: createBaseConfig({ | ||
baseDirectory: dirname, | ||
}), | ||
rules: { | ||
// No time for this | ||
'react/prop-types': 'off', | ||
'jsx-a11y/control-has-associated-label': 'off', | ||
'jsx-a11y/no-autofocus': 'off', | ||
}, | ||
settings: { | ||
'import/resolver': { | ||
typescript: { | ||
project: ['tsconfig.json'], | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
files: [ | ||
// matching the pattern of the test runner | ||
`**/*${EXTENSION_TEST_FILE}`, | ||
], | ||
extends: createTestConfig(), | ||
}, | ||
{ | ||
files: ['apps/**/*'], | ||
rules: { | ||
'react/jsx-one-expression-per-line': 'off', | ||
}, | ||
}, | ||
{ | ||
files: ['packages/bundle-size-checker/**/*'], | ||
rules: { | ||
// Allow .js file extensions in import statements for ESM compatibility | ||
'import/extensions': [ | ||
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. Would it make sense to make the default so that in .mjs/.mts files extensions are required? |
||
'error', | ||
'ignorePackages', | ||
{ | ||
js: 'always', | ||
mjs: 'always', | ||
}, | ||
], | ||
}, | ||
}, | ||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module.exports = { | ||
export default { | ||
rules: { | ||
// keeps test simple | ||
'no-unreachable': 'off', | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
__fixtures__ | ||
*.tsbuildinfo | ||
*.test.mjs |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# @mui/internal-code-infra | ||
|
||
Build scripts and configs to be used across MUI repos. |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,76 @@ | ||||||
{ | ||||||
"name": "@mui/internal-code-infra", | ||||||
"version": "0.0.1", | ||||||
LukasTy marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
"description": "Infra scripts and configs to be used across MUI repos.", | ||||||
"type": "module", | ||||||
"repository": { | ||||||
"type": "git", | ||||||
"url": "https://github.com/mui/mui-public.git", | ||||||
"directory": "packages/mui-internal-code-infra" | ||||||
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.
Suggested change
|
||||||
}, | ||||||
"sideEffects": false, | ||||||
"exports": { | ||||||
"./package.json": "./package.json", | ||||||
"./prettier": { | ||||||
"default": "./src/prettier.mjs" | ||||||
}, | ||||||
"./eslint": { | ||||||
"default": "./src/eslint/index.mjs" | ||||||
} | ||||||
}, | ||||||
"scripts": { | ||||||
"typescript": "tsc -p tsconfig.json", | ||||||
"test": "pnpm -w test --project @mui/internal-code-infra" | ||||||
}, | ||||||
"dependencies": { | ||||||
"@eslint/eslintrc": "^3.3.1", | ||||||
"eslint-config-airbnb": "^19.0.4", | ||||||
"eslint-config-airbnb-base": "^15.0.0", | ||||||
"eslint-config-prettier": "^10.1.5", | ||||||
"eslint-import-resolver-typescript": "^4.4.3", | ||||||
"eslint-module-utils": "^2.12.1", | ||||||
"eslint-plugin-import": "^2.32.0", | ||||||
"eslint-plugin-jsx-a11y": "^6.10.2", | ||||||
"eslint-plugin-mocha": "^11.1.0", | ||||||
"eslint-plugin-react": "^7.37.5", | ||||||
"eslint-plugin-react-compiler": "^19.1.0-rc.2", | ||||||
"eslint-plugin-react-hooks": "^6.0.0-rc.1", | ||||||
"eslint-plugin-testing-library": "^7.5.3", | ||||||
"@next/eslint-plugin-next": "^15.0.0", | ||||||
"globals": "^16.2.0", | ||||||
"minimatch": "^10.0.3", | ||||||
"typescript-eslint": "^8.35.0" | ||||||
}, | ||||||
"peerDependencies": { | ||||||
"eslint": "^9.0.0", | ||||||
"prettier": "^3.0.0" | ||||||
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 assume that 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. It is not needed because in the repo, you don't directly import it or try to use it in some way. It is already configured for you. |
||||||
}, | ||||||
"peerDependenciesMeta": { | ||||||
"eslint": { | ||||||
"optional": true | ||||||
}, | ||||||
"prettier": { | ||||||
"optional": true | ||||||
} | ||||||
}, | ||||||
"devDependencies": { | ||||||
"@next/eslint-plugin-next": "^15.3.3", | ||||||
"@types/eslint-plugin-jsx-a11y": "^6.10.0", | ||||||
"@types/estree": "^1.0.8", | ||||||
"@types/estree-jsx": "^1.0.5", | ||||||
"@typescript-eslint/parser": "^8.35.0", | ||||||
"@typescript-eslint/rule-tester": "^8.35.0", | ||||||
"eslint": "^9.29.0", | ||||||
"prettier": "^3.5.3", | ||||||
"typescript-eslint": "^8.35.0" | ||||||
}, | ||||||
"files": [ | ||||||
"build", | ||||||
"src", | ||||||
"README.md", | ||||||
"LICENSE" | ||||||
], | ||||||
"publishConfig": { | ||||||
"access": "public" | ||||||
} | ||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { FlatCompat } from '@eslint/eslintrc'; | ||
import * as tseslint from 'typescript-eslint'; | ||
|
||
/** | ||
* @param {Object} options - Configuration options. | ||
* @param {string} [options.baseDirectory] - The base directory for the configuration. | ||
* @returns {import('eslint').Linter.Config[]} | ||
*/ | ||
export function createAirbnbConfig({ baseDirectory } = {}) { | ||
if (!baseDirectory) { | ||
throw new Error('"baseDirectory" option is required for Airbnb configuration.'); | ||
} | ||
const compat = new FlatCompat({ | ||
baseDirectory, | ||
}); | ||
const airbnbConfig = compat.extends('eslint-config-airbnb'); | ||
return /** @type {import('eslint').Linter.Config[]} */ (tseslint.config(airbnbConfig)); | ||
} |
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.
can't we just remove? Or does this have a function?
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.
Looks like a leftover. 🙈