Skip to content

Commit c44071d

Browse files
authored
upgrade eslint (#7322)
1 parent cff1ab4 commit c44071d

9 files changed

+253
-134
lines changed

.eslintignore

-6
This file was deleted.

eslint.config.mjs

+123
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
import cypress from 'eslint-plugin-cypress';
2+
import reactHooks from 'eslint-plugin-react-hooks';
3+
import { fixupPluginRules } from '@eslint/compat';
4+
import globals from 'globals';
5+
import babelParser from '@babel/eslint-parser';
6+
import path from 'node:path';
7+
import { fileURLToPath } from 'node:url';
8+
import js from '@eslint/js';
9+
import { FlatCompat } from '@eslint/eslintrc';
10+
11+
const __filename = fileURLToPath(import.meta.url);
12+
const __dirname = path.dirname(__filename);
13+
const compat = new FlatCompat({
14+
baseDirectory: __dirname,
15+
recommendedConfig: js.configs.recommended,
16+
allConfig: js.configs.all,
17+
});
18+
19+
export default [
20+
{
21+
ignores: [
22+
'**/dist/',
23+
'**/examples/',
24+
'src/content/loaders/_*.mdx',
25+
'src/content/plugins/_*.mdx',
26+
'.github/**/*.md',
27+
'**/README.md',
28+
],
29+
},
30+
...compat.extends(
31+
'eslint:recommended',
32+
'plugin:react/recommended',
33+
'prettier'
34+
),
35+
{
36+
plugins: {
37+
cypress,
38+
'react-hooks': fixupPluginRules(reactHooks),
39+
},
40+
41+
languageOptions: {
42+
globals: {
43+
...globals.browser,
44+
...globals.node,
45+
...globals.jest,
46+
...cypress.environments.globals.globals,
47+
},
48+
49+
parser: babelParser,
50+
},
51+
52+
settings: {
53+
react: {
54+
version: 'detect',
55+
},
56+
},
57+
58+
rules: {
59+
'no-console': 'off',
60+
semi: ['error', 'always'],
61+
quotes: ['error', 'single'],
62+
'no-duplicate-imports': 'error',
63+
'react/jsx-uses-react': 'off',
64+
'react/react-in-jsx-scope': 'off',
65+
'react-hooks/rules-of-hooks': 'error',
66+
'react-hooks/exhaustive-deps': 'warn',
67+
68+
'react/no-unknown-property': [
69+
'error',
70+
{
71+
ignore: ['watch', 'align'],
72+
},
73+
],
74+
},
75+
},
76+
{
77+
files: ['src/**/*.jsx'],
78+
},
79+
...compat.extends('plugin:mdx/recommended').map((config) => ({
80+
...config,
81+
files: ['**/*.mdx'],
82+
})),
83+
{
84+
files: ['**/*.mdx'],
85+
86+
languageOptions: {
87+
globals: {
88+
Badge: true,
89+
StackBlitzPreview: true,
90+
},
91+
},
92+
93+
settings: {
94+
'mdx/code-blocks': true,
95+
},
96+
97+
rules: {
98+
semi: ['off'],
99+
},
100+
},
101+
{
102+
files: ['**/*.mdx/*.{js,javascript}'],
103+
104+
rules: {
105+
indent: ['error', 2],
106+
107+
quotes: [
108+
'error',
109+
'single',
110+
{
111+
allowTemplateLiterals: true,
112+
},
113+
],
114+
115+
'no-undef': 'off',
116+
'no-unused-vars': 'off',
117+
'no-constant-condition': 'off',
118+
'no-useless-escape': 'off',
119+
'no-dupe-keys': 'off',
120+
'no-duplicate-imports': 'off',
121+
},
122+
},
123+
];

package.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@
7575
"@babel/plugin-proposal-class-properties": "^7.17.12",
7676
"@babel/preset-env": "^7.24.8",
7777
"@babel/preset-react": "^7.24.7",
78+
"@eslint/compat": "^1.1.1",
79+
"@eslint/eslintrc": "^3.1.0",
80+
"@eslint/js": "^9.7.0",
7881
"@mdx-js/loader": "^3.0.1",
7982
"@mdx-js/react": "^3.0.1",
8083
"@octokit/auth-action": "^5.1.1",
@@ -90,14 +93,15 @@
9093
"directory-tree": "^3.5.2",
9194
"directory-tree-webpack-plugin": "^1.0.3",
9295
"duplexer": "^0.1.1",
93-
"eslint": "^8.57.0",
96+
"eslint": "^9.7.0",
9497
"eslint-config-prettier": "^9.1.0",
9598
"eslint-plugin-cypress": "^3.3.0",
9699
"eslint-plugin-mdx": "^3.1.5",
97100
"eslint-plugin-react": "^7.35.0",
98101
"eslint-plugin-react-hooks": "^4.6.2",
99102
"front-matter": "^4.0.2",
100103
"github-slugger": "^2.0.0",
104+
"globals": "^15.8.0",
101105
"html-webpack-plugin": "^5.5.4",
102106
"http-server": "^14.1.1",
103107
"husky": "^9.1.1",

src/utilities/fetch-package-repos.mjs

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ async function main() {
7979
} else {
8080
console.warn(e.message);
8181
}
82+
// eslint-disable-next-line no-unused-vars
8283
} catch (e2) {
8384
throw e;
8485
}

src/utilities/fetch-supporters.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ const getAllNodes = async (graphqlQuery, getNodes) => {
113113
remaining = 100;
114114
}
115115
// Handling pagination if necessary
116-
// eslint-disable-next-line
116+
117117
while (true) {
118118
if (remaining === 0) {
119119
console.log(`Rate limit exceeded. Sleeping until ${new Date(reset)}.`);

src/utilities/process-readme.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ function linkFixerFactory(sourceUrl) {
8383
function getMatches(string, regex) {
8484
const matches = [];
8585
let match;
86-
// eslint-disable-next-line
86+
8787
while ((match = regex.exec(string))) {
8888
matches.push(match);
8989
}

src/utilities/test-local-storage.js

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module.exports = function () {
99
try {
1010
localStorage.setItem(test, test);
1111
localStorage.removeItem(test);
12+
// eslint-disable-next-line no-unused-vars
1213
} catch (e) {
1314
return false;
1415
}

webpack.ssg.mjs

-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ const contentTree = JSON.parse(fs.readFileSync('./src/_content.json', 'utf8'));
1313

1414
// Load Common Configuration
1515
import common from './webpack.common.mjs';
16-
import { fileURLToPath } from 'url';
17-
const __filename = fileURLToPath(import.meta.url);
1816

1917
// content tree to path array
2018
const paths = [...flattenContentTree(contentTree), '/app-shell'];

0 commit comments

Comments
 (0)