Skip to content

upgrade eslint to v9 #7322

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

Merged
merged 1 commit into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .eslintignore

This file was deleted.

123 changes: 123 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
import cypress from 'eslint-plugin-cypress';
import reactHooks from 'eslint-plugin-react-hooks';
import { fixupPluginRules } from '@eslint/compat';
import globals from 'globals';
import babelParser from '@babel/eslint-parser';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import js from '@eslint/js';
import { FlatCompat } from '@eslint/eslintrc';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

export default [
{
ignores: [
'**/dist/',
'**/examples/',
'src/content/loaders/_*.mdx',
'src/content/plugins/_*.mdx',
'.github/**/*.md',
'**/README.md',
],
},
...compat.extends(
'eslint:recommended',
'plugin:react/recommended',
'prettier'
),
{
plugins: {
cypress,
'react-hooks': fixupPluginRules(reactHooks),
},

languageOptions: {
globals: {
...globals.browser,
...globals.node,
...globals.jest,
...cypress.environments.globals.globals,
},

parser: babelParser,
},

settings: {
react: {
version: 'detect',
},
},

rules: {
'no-console': 'off',
semi: ['error', 'always'],
quotes: ['error', 'single'],
'no-duplicate-imports': 'error',
'react/jsx-uses-react': 'off',
'react/react-in-jsx-scope': 'off',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',

'react/no-unknown-property': [
'error',
{
ignore: ['watch', 'align'],
},
],
},
},
{
files: ['src/**/*.jsx'],
},
...compat.extends('plugin:mdx/recommended').map((config) => ({
...config,
files: ['**/*.mdx'],
})),
{
files: ['**/*.mdx'],

languageOptions: {
globals: {
Badge: true,
StackBlitzPreview: true,
},
},

settings: {
'mdx/code-blocks': true,
},

rules: {
semi: ['off'],
},
},
{
files: ['**/*.mdx/*.{js,javascript}'],

rules: {
indent: ['error', 2],

quotes: [
'error',
'single',
{
allowTemplateLiterals: true,
},
],

'no-undef': 'off',
'no-unused-vars': 'off',
'no-constant-condition': 'off',
'no-useless-escape': 'off',
'no-dupe-keys': 'off',
'no-duplicate-imports': 'off',
},
},
];
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@
"@babel/plugin-proposal-class-properties": "^7.17.12",
"@babel/preset-env": "^7.24.8",
"@babel/preset-react": "^7.24.7",
"@eslint/compat": "^1.1.1",
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.7.0",
"@mdx-js/loader": "^3.0.1",
"@mdx-js/react": "^3.0.1",
"@octokit/auth-action": "^5.1.1",
Expand All @@ -90,14 +93,15 @@
"directory-tree": "^3.5.2",
"directory-tree-webpack-plugin": "^1.0.3",
"duplexer": "^0.1.1",
"eslint": "^8.57.0",
"eslint": "^9.7.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-cypress": "^3.3.0",
"eslint-plugin-mdx": "^3.1.5",
"eslint-plugin-react": "^7.35.0",
"eslint-plugin-react-hooks": "^4.6.2",
"front-matter": "^4.0.2",
"github-slugger": "^2.0.0",
"globals": "^15.8.0",
"html-webpack-plugin": "^5.5.4",
"http-server": "^14.1.1",
"husky": "^9.1.1",
Expand Down
1 change: 1 addition & 0 deletions src/utilities/fetch-package-repos.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ async function main() {
} else {
console.warn(e.message);
}
// eslint-disable-next-line no-unused-vars
} catch (e2) {
throw e;
}
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/fetch-supporters.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const getAllNodes = async (graphqlQuery, getNodes) => {
remaining = 100;
}
// Handling pagination if necessary
// eslint-disable-next-line
while (true) {
if (remaining === 0) {
console.log(`Rate limit exceeded. Sleeping until ${new Date(reset)}.`);
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/process-readme.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function linkFixerFactory(sourceUrl) {
function getMatches(string, regex) {
const matches = [];
let match;
// eslint-disable-next-line
while ((match = regex.exec(string))) {
matches.push(match);
}
Expand Down
1 change: 1 addition & 0 deletions src/utilities/test-local-storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module.exports = function () {
try {
localStorage.setItem(test, test);
localStorage.removeItem(test);
// eslint-disable-next-line no-unused-vars
} catch (e) {
return false;
}
Expand Down
2 changes: 0 additions & 2 deletions webpack.ssg.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ const contentTree = JSON.parse(fs.readFileSync('./src/_content.json', 'utf8'));

// Load Common Configuration
import common from './webpack.common.mjs';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);

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