Skip to content

Commit 6a5bc2a

Browse files
committed
ESLint temp
1 parent be8abe5 commit 6a5bc2a

File tree

13 files changed

+200
-944
lines changed

13 files changed

+200
-944
lines changed

apps/demo/eslint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createConfig, detectOpts } from '../../eslint.config.base.js';
1+
import { createConfig, detectOpts } from '@h5web/eslint-config';
22

33
const opts = detectOpts(import.meta.dirname);
44

apps/storybook/eslint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createConfig, detectOpts } from '../../eslint.config.base.js';
1+
import { createConfig, detectOpts } from '@h5web/eslint-config';
22

33
const opts = detectOpts(import.meta.dirname);
44

eslint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createConfig, detectOpts } from './eslint.config.base.js';
1+
import { createConfig, detectOpts } from '@h5web/eslint-config';
22

33
const opts = detectOpts(import.meta.dirname);
44

package.json

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,30 +40,15 @@
4040
"postversion": "git push && git push --tags"
4141
},
4242
"devDependencies": {
43+
"@h5web/eslint-config": "workspace:*",
4344
"@simonsmith/cypress-image-snapshot": "9.1.0",
44-
"@stylistic/eslint-plugin-js": "2.13.0",
4545
"@testing-library/cypress": "10.0.2",
4646
"@types/node": "^22.12.0",
47-
"@vitest/eslint-plugin": "1.1.25",
48-
"confusing-browser-globals": "1.0.11",
4947
"cypress": "13.17.0",
5048
"cypress-wait-for-stable-dom": "0.1.0",
5149
"eslint": "9.18.0",
52-
"eslint-plugin-import": "2.31.0",
53-
"eslint-plugin-jsx-a11y": "6.10.2",
54-
"eslint-plugin-promise": "7.2.1",
55-
"eslint-plugin-react": "7.37.4",
56-
"eslint-plugin-react-hooks": "5.1.0",
57-
"eslint-plugin-regexp": "2.7.0",
58-
"eslint-plugin-simple-import-sort": "12.1.1",
59-
"eslint-plugin-storybook": "0.11.2",
60-
"eslint-plugin-testing-library": "7.1.1",
61-
"eslint-plugin-unicorn": "56.0.1",
62-
"globals": "15.14.0",
63-
"lodash": "4.17.21",
6450
"prettier": "3.4.2",
6551
"typescript": "5.7.3",
66-
"typescript-eslint": "8.20.0",
6752
"vitest": "2.1.8",
6853
"vitest-fail-on-console": "0.7.1",
6954
"wait-on": "8.0.2"

packages/app/eslint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createConfig, detectOpts } from '../../eslint.config.base.js';
1+
import { createConfig, detectOpts } from '@h5web/eslint-config';
22

33
const opts = detectOpts(import.meta.dirname);
44

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { createConfig, detectOpts } from './index.js';
2+
3+
const opts = detectOpts(import.meta.dirname);
4+
5+
const config = [
6+
...createConfig(opts),
7+
{
8+
name: 'h5web/eslint-config/ignores',
9+
ignores: [],
10+
},
11+
];
12+
13+
export default config;
Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@ import _ from 'lodash';
1919
import tseslint from 'typescript-eslint';
2020

2121
const DEFAULT_OPTS = {
22-
typescript: false,
22+
cypress: false,
23+
cypressTestingLibrary: false,
2324
react: false,
25+
reactTestingLibrary: false,
26+
rollup: false,
2427
storybook: false,
28+
typescript: false,
29+
vite: false,
2530
vitest: false,
26-
cypress: false,
27-
reactTestingLibrary: false,
28-
cypressTestingLibrary: false,
2931
};
3032

3133
export function detectOpts(projectDir) {
@@ -39,28 +41,39 @@ export function detectOpts(projectDir) {
3941
]);
4042

4143
return {
42-
typescript: deps.has('typescript') && fs.existsSync(tsconfigPath),
44+
cypress: deps.has('cypress'),
45+
cypressTestingLibrary: deps.has('@testing-library/cypress'),
4346
react: deps.has('react'),
47+
reactTestingLibrary: deps.has('@testing-library/react'),
48+
rollup: deps.has('rollup'),
4449
storybook: deps.has('storybook'),
50+
typescript: deps.has('typescript') && fs.existsSync(tsconfigPath),
51+
vite: deps.has('vite'),
4552
vitest: deps.has('vitest'),
46-
cypress: deps.has('cypress'),
47-
reactTestingLibrary: deps.has('@testing-library/react'),
48-
cypressTestingLibrary: deps.has('@testing-library/cypress'),
4953
};
5054
}
5155

5256
// eslint-disable-next-line complexity
5357
export function createConfig(opts = {}) {
5458
const {
55-
typescript: withTypeScript,
59+
cypress: withCypress,
60+
cypressTestingLibrary: withCypressTestingLibrary,
5661
react: withReact,
62+
reactTestingLibrary: withReactTestingLibrary,
63+
rollup: withRollup,
5764
storybook: withStorybook,
65+
typescript: withTypeScript,
66+
vite: withVite,
5867
vitest: withVitest,
59-
cypress: withCypress,
60-
reactTestingLibrary: withReactTestingLibrary,
61-
cypressTestingLibrary: withCypressTestingLibrary,
6268
} = { ...DEFAULT_OPTS, ...opts };
6369

70+
const nodeFiles = [
71+
'**/eslint.*.{js,ts}',
72+
withCypress && '**/cypress.*.{js,ts}',
73+
withRollup && '**/rollup.*.{js,ts}',
74+
withVite && '**/vite.*.{js,ts}',
75+
];
76+
6477
return tseslint.config(
6578
_.compact([
6679
withTypeScript && {
@@ -93,8 +106,19 @@ export function createConfig(opts = {}) {
93106
},
94107
{
95108
/**
96-
* Configure browser globals on files we're confident aren't meant to run
97-
* in a non-browser environment.
109+
* Configure Node globals on files we're confident are meant to run
110+
* in a Node environment.
111+
*/
112+
name: 'h5web/defaults/globals-node',
113+
files: nodeFiles.filter((entry) => !!entry),
114+
languageOptions: {
115+
globals: { ...globals.node },
116+
},
117+
},
118+
{
119+
/**
120+
* Configure browser globals on files we're confident are meant to run
121+
* in a browser environment.
98122
*/
99123
name: 'h5web/defaults/globals-browser',
100124
files: ['**/*.{jsx,tsx}'],
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"name": "@h5web/eslint-config",
3+
"version": "14.0.0",
4+
"description": "ESLint config for H5Web",
5+
"author": "European Synchrotron Radiation Facility",
6+
"license": "MIT",
7+
"repository": {
8+
"type": "git",
9+
"url": "https://github.com/silx-kit/h5web"
10+
},
11+
"type": "module",
12+
"files": [
13+
"dist"
14+
],
15+
"main": "index.js",
16+
"scripts": {
17+
"lint": "pnpm \"/^lint:/\"",
18+
"lint:eslint": "eslint --max-warnings=0",
19+
"lint:tsc": "tsc"
20+
},
21+
"peerDependencies": {
22+
"eslint": "9.18.0",
23+
"typescript": ">=5"
24+
},
25+
"devDependencies": {
26+
"@stylistic/eslint-plugin-js": "2.13.0",
27+
"@types/node": "^22.12.0",
28+
"@vitest/eslint-plugin": "1.1.25",
29+
"confusing-browser-globals": "1.0.11",
30+
"eslint": "9.18.0",
31+
"eslint-plugin-import": "2.31.0",
32+
"eslint-plugin-jsx-a11y": "6.10.2",
33+
"eslint-plugin-promise": "7.2.1",
34+
"eslint-plugin-react": "7.37.4",
35+
"eslint-plugin-react-hooks": "5.1.0",
36+
"eslint-plugin-regexp": "2.7.0",
37+
"eslint-plugin-simple-import-sort": "12.1.1",
38+
"eslint-plugin-storybook": "0.11.2",
39+
"eslint-plugin-testing-library": "7.1.1",
40+
"eslint-plugin-unicorn": "56.0.1",
41+
"globals": "15.14.0",
42+
"lodash": "4.17.21",
43+
"typescript": "5.7.3",
44+
"typescript-eslint": "8.20.0"
45+
}
46+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
"include": ["*"]
4+
}

packages/h5wasm/eslint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createConfig, detectOpts } from '../../eslint.config.base.js';
1+
import { createConfig, detectOpts } from '@h5web/eslint-config';
22

33
const opts = detectOpts(import.meta.dirname);
44

0 commit comments

Comments
 (0)