Skip to content

Commit b1c8cff

Browse files
committed
chore: update to eslint v9
1 parent 38041ff commit b1c8cff

File tree

4 files changed

+460
-404
lines changed

4 files changed

+460
-404
lines changed

.eslintrc.json

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

eslint.config.mjs

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
import { defineConfig, globalIgnores } from 'eslint/config';
2+
import react from 'eslint-plugin-react';
3+
// import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
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 json from '@eslint/json';
9+
import js from '@eslint/js';
10+
import stylisticJs from '@stylistic/eslint-plugin-js';
11+
import { FlatCompat } from '@eslint/eslintrc';
12+
13+
const __filename = fileURLToPath(import.meta.url);
14+
const __dirname = path.dirname(__filename);
15+
const compat = new FlatCompat({
16+
baseDirectory: __dirname,
17+
recommendedConfig: js.configs.recommended,
18+
allConfig: js.configs.all,
19+
});
20+
21+
export default defineConfig([
22+
// ignoring for now, many unformatted files
23+
// eslintPluginPrettierRecommended,
24+
{
25+
plugins: {
26+
json,
27+
'@stylistic/js': stylisticJs,
28+
},
29+
},
30+
{
31+
files: ['**/*.json'],
32+
language: 'json/json',
33+
rules: {
34+
'json/no-duplicate-keys': 'error',
35+
},
36+
},
37+
38+
{
39+
files: ['**/*.js'],
40+
plugins: {
41+
js,
42+
},
43+
extends: ['js/recommended'],
44+
rules: {
45+
'no-unused-vars': 'warn',
46+
'no-undef': 'warn',
47+
},
48+
},
49+
{
50+
files: ['**/*.{js,jsx,mjs,cjs,ts,tsx}'],
51+
plugins: {
52+
react,
53+
},
54+
languageOptions: {
55+
parserOptions: {
56+
ecmaFeatures: {
57+
jsx: true,
58+
},
59+
},
60+
globals: {
61+
...globals.browser, // causes error
62+
...globals.node,
63+
...globals.commonjs,
64+
},
65+
},
66+
settings: {
67+
react: {
68+
version: 'detect',
69+
},
70+
},
71+
rules: {
72+
'no-async-promise-executor': 'off',
73+
'react/jsx-uses-react': 'error',
74+
'react/jsx-uses-vars': 'error',
75+
'react/prop-types': 'off',
76+
// ignoring for now, many long lines
77+
// '@stylistic/js/max-len': ['error', { code: 100 }],
78+
},
79+
},
80+
{
81+
files: ['test/**/*.{js,mjs,cjs,ts}'],
82+
languageOptions: {
83+
globals: {
84+
...globals.mocha,
85+
},
86+
},
87+
},
88+
// {
89+
// extends: compat.extends('prettier', 'plugin:json/recommended'),
90+
91+
// plugins: {
92+
// react,
93+
// prettier,
94+
// },
95+
96+
// languageOptions: {
97+
// globals: {
98+
// ...globals.node,
99+
// // causes error:
100+
// // TypeError: Key "languageOptions": Key "globals": Global "AudioWorkletGlobalScope " has leading or trailing whitespace.
101+
// // ...globals.browser,
102+
// ...globals.commonjs,
103+
// ...globals.mocha,
104+
// },
105+
106+
// parser: babelParser,
107+
// ecmaVersion: 12,
108+
// sourceType: 'module',
109+
110+
// parserOptions: {
111+
// requireConfigFile: false,
112+
113+
// ecmaFeatures: {
114+
// jsx: true,
115+
// modules: true,
116+
// },
117+
118+
// babelOptions: {
119+
// presets: ['@babel/preset-react'],
120+
// },
121+
// },
122+
// },
123+
// },
124+
]);

0 commit comments

Comments
 (0)