Skip to content

Commit 8391aed

Browse files
brijeshb42Brijesh BittuJanpot
authored
[code-infra] Bring eslint configuration from core and bump to v9 (#344)
Co-authored-by: Brijesh Bittu <[email protected]> Co-authored-by: MUI bot <[email protected]>
1 parent 3d1cc49 commit 8391aed

File tree

64 files changed

+4061
-1597
lines changed

Some content is hidden

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

64 files changed

+4061
-1597
lines changed

.eslintrc.js

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

.github/workflows/scripts/prs/checkTargetBranchLabel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// @ts-check
22
const vBranchRegex = /^v\d{1,3}\.x$/;
3-
const transferLabels = ['cherry-pick'];
3+
// const transferLabels = ['cherry-pick'];
44

55
/**
66
* @param {Object} params

.github/workflows/scripts/prs/checkTypeLabel.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
// @ts-check
22
const createEnumerationFromArray = (stringArray) =>
33
stringArray.length > 1
4-
? stringArray
4+
? `${stringArray
55
.slice(0, -1)
66
.map((s) => `\`${s}\``)
7-
.join(', ') +
8-
' or ' +
9-
`\`${stringArray.slice(-1)}\``
7+
.join(', ')} or \`${stringArray.slice(-1)}\``
108
: stringArray.map((s) => `\`${s}\``).join('');
119

1210
const typeLabels = [
@@ -48,7 +46,7 @@ module.exports = async ({ core, context, github }) => {
4846
?.map((label) => label.name)
4947
.filter((labelName) => labelRegex.test(labelName));
5048

51-
const { data: prComments } = await github.rest.issues.listComments({
49+
await github.rest.issues.listComments({
5250
owner,
5351
repo,
5452
issue_number: pullNumber,

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"eslint.useFlatConfig": true
3+
}

apps/code-infra-dashboard/functions/circle-ci-artifacts.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable import/prefer-default-export */
21
import type { Handler } from '@netlify/functions';
32
import zlib from 'zlib';
43
import util from 'util';

apps/tools-public/toolpad/resources/bundleSizeQueries.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable import/prefer-default-export */
21
import axios from 'axios';
32

43
function getMainBundleLabel(bundleId: string): string {

apps/tools-public/toolpad/resources/queryAbout.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable import/prefer-default-export */
21
function flip(data) {
32
return Object.fromEntries(Object.entries(data).map(([key, value]) => [value, key]));
43
}

apps/tools-public/toolpad/resources/queryGitHubSearchAPI.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable import/prefer-default-export */
21
import { rawRequest } from 'graphql-request';
32

43
export async function queryGitHubSearchAPI(queryInput = '', type = 'ISSUE') {

apps/tools-public/toolpad/resources/queryJoyUIMonthlyDownloads.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable import/prefer-default-export */
21
import { formatDatePart, getDateString, getMonthKey } from './queryHeadlessLibrariesDownloads';
32

43
const prepareData = (inData) => {

apps/tools-public/toolpad/resources/queryLabelsActivity.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable import/prefer-default-export */
21
import { request } from 'graphql-request';
32

43
interface LabelTimelineItem {

apps/tools-public/toolpad/resources/queryPRs.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable import/prefer-default-export */
21
import { request } from 'graphql-request';
32

43
interface PullRequest {

apps/tools-public/toolpad/resources/queryPRswithoutReviewer.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable import/prefer-default-export */
21
import { request } from 'graphql-request';
32

43
export async function queryPRswithoutReviewer() {

apps/tools-public/toolpad/resources/updateMuiPaidSupport.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable import/prefer-default-export */
21
import dayjs from 'dayjs';
32
import { sheets } from '@googleapis/sheets';
43
import { JWT } from 'google-auth-library';

eslint.config.mjs

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import { includeIgnoreFile } from '@eslint/compat';
2+
import { defineConfig } from 'eslint/config';
3+
import * as path from 'node:path';
4+
import { fileURLToPath } from 'node:url';
5+
import {
6+
createBaseConfig,
7+
createTestConfig,
8+
EXTENSION_TEST_FILE,
9+
} from '@mui/internal-code-infra/eslint';
10+
11+
const filename = fileURLToPath(import.meta.url);
12+
const dirname = path.dirname(filename);
13+
14+
export default defineConfig(
15+
includeIgnoreFile(path.join(dirname, '.gitignore')),
16+
includeIgnoreFile(path.join(dirname, '.eslintignore')),
17+
{
18+
name: 'Base config',
19+
extends: createBaseConfig({
20+
baseDirectory: dirname,
21+
}),
22+
rules: {
23+
// No time for this
24+
'react/prop-types': 'off',
25+
'jsx-a11y/control-has-associated-label': 'off',
26+
'jsx-a11y/no-autofocus': 'off',
27+
},
28+
settings: {
29+
'import/resolver': {
30+
typescript: {
31+
project: ['tsconfig.json'],
32+
},
33+
},
34+
},
35+
},
36+
{
37+
files: [
38+
// matching the pattern of the test runner
39+
`**/*${EXTENSION_TEST_FILE}`,
40+
],
41+
extends: createTestConfig(),
42+
},
43+
{
44+
files: ['apps/**/*'],
45+
rules: {
46+
'react/jsx-one-expression-per-line': 'off',
47+
},
48+
},
49+
{
50+
files: ['packages/bundle-size-checker/**/*'],
51+
rules: {
52+
// Allow .js file extensions in import statements for ESM compatibility
53+
'import/extensions': [
54+
'error',
55+
'ignorePackages',
56+
{
57+
js: 'always',
58+
mjs: 'always',
59+
},
60+
],
61+
},
62+
},
63+
);

package.json

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,40 +16,37 @@
1616
"release:publish": "tsx scripts/publish.mjs",
1717
"pkg-pr-new-packages": "pnpm ls -r --parseable --depth -1 -F \"./packages/**\""
1818
},
19-
"devDependencies": {
19+
"pnpm": {
20+
"packageExtensions": {
21+
"@eslint/config-helpers@*": {
22+
"peerDependencies": {
23+
"eslint": "*"
24+
},
25+
"peerDependenciesMeta": {
26+
"eslint": {
27+
"optional": true
28+
}
29+
}
30+
}
31+
}
32+
},
33+
"dependencies": {
2034
"@actions/core": "^1.10.1",
2135
"@actions/github": "^6.0.0",
36+
"@eslint/compat": "^1.3.0",
2237
"@mui/internal-bundle-size-checker": "workspace:*",
23-
"@mui/monorepo": "https://github.com/mui/material-ui.git#010de4505361345951824d905d1508d6f258ba67",
38+
"@mui/internal-code-infra": "workspace:*",
2439
"@tsconfig/node22": "^22.0.2",
2540
"@types/node": "^24.0.3",
2641
"@types/semver": "^7.7.0",
2742
"@typescript-eslint/eslint-plugin": "7.12.0",
2843
"@typescript-eslint/parser": "7.12.0",
29-
"eslint": "8.57.0",
30-
"eslint-config-airbnb": "19.0.4",
31-
"eslint-config-airbnb-typescript": "18.0.0",
32-
"eslint-config-prettier": "9.1.0",
33-
"eslint-import-resolver-typescript": "^4.3.4",
34-
"eslint-plugin-filenames": "1.3.2",
35-
"eslint-plugin-import": "2.29.1",
36-
"eslint-plugin-jsx-a11y": "6.8.0",
37-
"eslint-plugin-material-ui": "workspace:*",
38-
"eslint-plugin-mocha": "10.4.3",
39-
"eslint-plugin-react": "7.34.2",
40-
"eslint-plugin-react-compiler": "latest",
41-
"eslint-plugin-react-hooks": "4.6.2",
42-
"eslint-plugin-testing-library": "^6.2.2",
43-
"eslint-plugin-typescript-enum": "2.1.0",
44+
"eslint": "^9.29.0",
4445
"lerna": "^8.2.2",
45-
"prettier": "^3.3.3",
46-
"pretty-quick": "^4.0.0",
46+
"prettier": "^3.5.3",
47+
"pretty-quick": "^4.2.2",
4748
"tsx": "^4.20.3",
4849
"typescript": "^5.8.3",
49-
"vitest": "^3.1.3"
50-
},
51-
"dependencies": {
52-
"@next/eslint-plugin-next": "^14.2.4",
5350
"execa": "^7.2.0",
5451
"semver": "^7.7.2",
5552
"vitest": "^3.1.3"

packages/babel-plugin-minify-errors/__fixtures__/.eslintrc.js renamed to packages/babel-plugin-minify-errors/__fixtures__/eslint.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = {
1+
export default {
22
rules: {
33
// keeps test simple
44
'no-unreachable': 'off',

packages/babel-plugin-minify-errors/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"@types/babel__core": "^7.20.5",
2727
"@types/babel__helper-module-imports": "^7.18.3",
2828
"@types/find-package-json": "^1.2.6",
29-
"babel-plugin-tester": "^11.0.4",
29+
"babel-plugin-tester": "^12.0.0",
3030
"chai": "^4.5.0"
3131
},
3232
"peerDependencies": {

packages/babel-plugin-resolve-imports/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"@types/chai": "^4.3.20",
2626
"@types/node": "^20.17.46",
2727
"@types/resolve": "^1.20.6",
28-
"babel-plugin-tester": "^11.0.4",
28+
"babel-plugin-tester": "^12.0.0",
2929
"chai": "^4.5.0"
3030
},
3131
"peerDependencies": {

packages/bundle-size-checker/.eslintrc.cjs

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

packages/bundle-size-checker/src/cli.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import path from 'path';
44
import os from 'os';
55
import fs from 'fs/promises';
66
import yargs from 'yargs';
7-
import Piscina from 'piscina';
7+
import { Piscina } from 'piscina';
88
import micromatch from 'micromatch';
99
import { loadConfig } from './configLoader.js';
1010
import { uploadSnapshot } from './uploadSnapshot.js';

packages/bundle-size-checker/src/renderMarkdownReport.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable testing-library/render-result-naming-convention */
12
import { vi, describe, it, expect, beforeEach } from 'vitest';
23
import { renderMarkdownReport } from './renderMarkdownReport.js';
34
import * as fetchSnapshotModule from './fetchSnapshot.js';

packages/code-infra/.npmignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
__fixtures__
2+
*.tsbuildinfo
3+
*.test.mjs

packages/code-infra/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# @mui/internal-code-infra
2+
3+
Build scripts and configs to be used across MUI repos.

packages/code-infra/package.json

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
{
2+
"name": "@mui/internal-code-infra",
3+
"version": "0.0.1",
4+
"description": "Infra scripts and configs to be used across MUI repos.",
5+
"type": "module",
6+
"repository": {
7+
"type": "git",
8+
"url": "https://github.com/mui/mui-public.git",
9+
"directory": "packages/mui-internal-code-infra"
10+
},
11+
"sideEffects": false,
12+
"exports": {
13+
"./package.json": "./package.json",
14+
"./prettier": {
15+
"default": "./src/prettier.mjs"
16+
},
17+
"./eslint": {
18+
"default": "./src/eslint/index.mjs"
19+
}
20+
},
21+
"scripts": {
22+
"typescript": "tsc -p tsconfig.json",
23+
"test": "pnpm -w test --project @mui/internal-code-infra"
24+
},
25+
"dependencies": {
26+
"@eslint/eslintrc": "^3.3.1",
27+
"eslint-config-airbnb": "^19.0.4",
28+
"eslint-config-airbnb-base": "^15.0.0",
29+
"eslint-config-prettier": "^10.1.5",
30+
"eslint-import-resolver-typescript": "^4.4.3",
31+
"eslint-module-utils": "^2.12.1",
32+
"eslint-plugin-import": "^2.32.0",
33+
"eslint-plugin-jsx-a11y": "^6.10.2",
34+
"eslint-plugin-mocha": "^11.1.0",
35+
"eslint-plugin-react": "^7.37.5",
36+
"eslint-plugin-react-compiler": "^19.1.0-rc.2",
37+
"eslint-plugin-react-hooks": "^6.0.0-rc.1",
38+
"eslint-plugin-testing-library": "^7.5.3",
39+
"@next/eslint-plugin-next": "^15.0.0",
40+
"globals": "^16.2.0",
41+
"minimatch": "^10.0.3",
42+
"typescript-eslint": "^8.35.0"
43+
},
44+
"peerDependencies": {
45+
"eslint": "^9.0.0",
46+
"prettier": "^3.0.0"
47+
},
48+
"peerDependenciesMeta": {
49+
"eslint": {
50+
"optional": true
51+
},
52+
"prettier": {
53+
"optional": true
54+
}
55+
},
56+
"devDependencies": {
57+
"@next/eslint-plugin-next": "^15.3.3",
58+
"@types/eslint-plugin-jsx-a11y": "^6.10.0",
59+
"@types/estree": "^1.0.8",
60+
"@types/estree-jsx": "^1.0.5",
61+
"@typescript-eslint/parser": "^8.35.0",
62+
"@typescript-eslint/rule-tester": "^8.35.0",
63+
"eslint": "^9.29.0",
64+
"prettier": "^3.5.3",
65+
"typescript-eslint": "^8.35.0"
66+
},
67+
"files": [
68+
"build",
69+
"src",
70+
"README.md",
71+
"LICENSE"
72+
],
73+
"publishConfig": {
74+
"access": "public"
75+
}
76+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { FlatCompat } from '@eslint/eslintrc';
2+
import * as tseslint from 'typescript-eslint';
3+
4+
/**
5+
* @param {Object} options - Configuration options.
6+
* @param {string} [options.baseDirectory] - The base directory for the configuration.
7+
* @returns {import('eslint').Linter.Config[]}
8+
*/
9+
export function createAirbnbConfig({ baseDirectory } = {}) {
10+
if (!baseDirectory) {
11+
throw new Error('"baseDirectory" option is required for Airbnb configuration.');
12+
}
13+
const compat = new FlatCompat({
14+
baseDirectory,
15+
});
16+
const airbnbConfig = compat.extends('eslint-config-airbnb');
17+
return /** @type {import('eslint').Linter.Config[]} */ (tseslint.config(airbnbConfig));
18+
}

0 commit comments

Comments
 (0)