@4mbl/lint 0.16.0 → 1.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/README.md +32 -12
- package/bin/cli.js +25 -0
- package/package.json +12 -7
- package/src/base.ts +134 -0
- package/src/next.ts +77 -30
- package/src/node.ts +15 -14
- package/src/react.ts +69 -27
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @4mbl/lint
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 2c338b1: fix(lint): re-export `OxlintConfig` to make config portable
|
|
8
|
+
|
|
9
|
+
## 1.0.0-beta.0
|
|
10
|
+
|
|
11
|
+
### Major Changes
|
|
12
|
+
|
|
13
|
+
- c65e34e: Add CLI to allow default arguments and easier tool migration in the future
|
|
14
|
+
- c65e34e: Migrate from eslint to oxlint
|
|
15
|
+
|
|
3
16
|
## 0.16.0
|
|
4
17
|
|
|
5
18
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -2,12 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
> Linting configuration for various environments.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
- [Usage](#usage)
|
|
6
|
+
- [Running `lint` CLI wrapper](#running-lint-cli-wrapper)
|
|
7
|
+
- [Running `oxlint` directly](#running-oxlint-directly)
|
|
8
|
+
- [Available templates](#available-templates)
|
|
9
|
+
- [Versioning](#versioning)
|
|
8
10
|
|
|
9
11
|
---
|
|
10
12
|
|
|
13
|
+
> [!NOTE]
|
|
14
|
+
> This package currently uses [oxlint](https://www.npmjs.com/package/oxlint) as the underlying linting tool. That may change in a future major release.
|
|
15
|
+
|
|
11
16
|
## Usage
|
|
12
17
|
|
|
13
18
|
Install the [`@4mbl/lint`](https://www.npmjs.com/package/@4mbl/lint) package.
|
|
@@ -16,27 +21,44 @@ Install the [`@4mbl/lint`](https://www.npmjs.com/package/@4mbl/lint) package.
|
|
|
16
21
|
npm install -D @4mbl/lint
|
|
17
22
|
```
|
|
18
23
|
|
|
19
|
-
Create a `
|
|
24
|
+
Create a `oxlint.config.ts` file for your package. If you are using a monorepo, create a `oxlint.config.ts` for each package in the monorepo.
|
|
20
25
|
|
|
21
26
|
```js
|
|
22
|
-
import
|
|
27
|
+
import defineConfig from '@4mbl/lint/next'; // <-- change `next` to the desired template
|
|
23
28
|
|
|
24
|
-
export default defineConfig(
|
|
29
|
+
export default defineConfig();
|
|
25
30
|
```
|
|
26
31
|
|
|
27
|
-
|
|
32
|
+
### Running `lint` CLI wrapper
|
|
33
|
+
|
|
34
|
+
This is the recommended way as it abstracts away the underlying linting package and allows us to change it in the future. While we try to keep the CLI wrapper interface stable between possible tooling changes, it is inevitable to have breaking changes if the underlying tooling changes.
|
|
35
|
+
|
|
36
|
+
Set a script that uses the linting CLI wrapper in your `package.json`. While it may be tempting to just call `lint` directly in CI or locally, it is recommended to use a script as it allows additional arguments to be passed to the CLI wrapper.
|
|
28
37
|
|
|
29
38
|
```shell
|
|
30
|
-
npm pkg set scripts.lint="
|
|
39
|
+
npm pkg set scripts.lint="lint"
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
The CLI wrapper uses the `src` directory by default and the following arguments:
|
|
43
|
+
|
|
44
|
+
- `--max-warnings=0`
|
|
45
|
+
- `--report-unused-disable-directives`
|
|
46
|
+
|
|
47
|
+
These arguments can be overridden by passing them explicitly to the CLI wrapper.
|
|
48
|
+
|
|
49
|
+
### Running `oxlint` directly
|
|
50
|
+
|
|
51
|
+
```shell
|
|
52
|
+
npm pkg set scripts.lint="oxlint src"
|
|
31
53
|
```
|
|
32
54
|
|
|
33
55
|
You may need to explicitly allow the underlying linting packages to be used by your scripts.
|
|
34
56
|
|
|
35
|
-
For example, when using pnpm, you need to set `publicHoistPattern` in your `pnpm-workspace.yaml
|
|
57
|
+
For example, when using pnpm, you need to set `publicHoistPattern` in your `pnpm-workspace.yaml`.
|
|
36
58
|
|
|
37
59
|
```yaml
|
|
38
60
|
publicHoistPattern:
|
|
39
|
-
-
|
|
61
|
+
- oxlint
|
|
40
62
|
```
|
|
41
63
|
|
|
42
64
|
## Available templates
|
|
@@ -49,8 +71,6 @@ These are the currently available config templates.
|
|
|
49
71
|
|
|
50
72
|
## Versioning
|
|
51
73
|
|
|
52
|
-
_Until v1.0.0 is released, breaking changes may be introduced in minor releases without prior warnings._
|
|
53
|
-
|
|
54
74
|
The package follows the following versioning scheme: `X.Y.Z`.
|
|
55
75
|
|
|
56
76
|
- `X` - Reserved for linting provider changes as those might cause wider backwards compatibility issues.
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { spawnSync } from 'node:child_process';
|
|
4
|
+
|
|
5
|
+
const args = process.argv.slice(2);
|
|
6
|
+
|
|
7
|
+
const hasPath = args.some((a) => !a.startsWith('-'));
|
|
8
|
+
const hasMaxWarn = args.some((a) => a.startsWith('--max-warnings'));
|
|
9
|
+
const hasReportUnused = args.some((a) =>
|
|
10
|
+
a.startsWith('--report-unused-disable-directives'),
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
const finalArgs = [
|
|
14
|
+
...(hasPath ? [] : ['src']),
|
|
15
|
+
...(hasMaxWarn ? [] : ['--max-warnings=0']),
|
|
16
|
+
...(hasReportUnused ? [] : ['--report-unused-disable-directives']),
|
|
17
|
+
...args,
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
const result = spawnSync('oxlint', finalArgs, {
|
|
21
|
+
stdio: 'inherit',
|
|
22
|
+
shell: true,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
process.exit(result.status ?? 1);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@4mbl/lint",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-beta.1",
|
|
4
4
|
"description": "Linting configuration for various environments.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "4mbl",
|
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
"./node": "./src/node.ts",
|
|
12
12
|
"./react": "./src/react.ts"
|
|
13
13
|
},
|
|
14
|
+
"bin": {
|
|
15
|
+
"lint": "./bin/cli.js"
|
|
16
|
+
},
|
|
14
17
|
"files": [
|
|
15
18
|
"src",
|
|
16
19
|
"package.json",
|
|
@@ -26,16 +29,18 @@
|
|
|
26
29
|
"lint"
|
|
27
30
|
],
|
|
28
31
|
"dependencies": {
|
|
29
|
-
"@eslint/js": "^10.0.1",
|
|
30
|
-
"eslint": "^10.0.2",
|
|
31
|
-
"eslint-config-next": "^16.1.6",
|
|
32
|
-
"eslint-config-prettier": "^10.1.8",
|
|
33
32
|
"eslint-plugin-react-compiler": "19.1.0-rc.2",
|
|
34
33
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
35
34
|
"eslint-plugin-react-refresh": "^0.5.2",
|
|
36
35
|
"globals": "^17.4.0",
|
|
37
36
|
"jiti": "^2.6.1",
|
|
38
|
-
"
|
|
37
|
+
"oxlint": "^1.56.0",
|
|
38
|
+
"oxlint-tsgolint": "^0.17.0"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@4mbl/tsconfig": "4.4.0"
|
|
39
42
|
},
|
|
40
|
-
"scripts": {
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "tsc --noEmit"
|
|
45
|
+
}
|
|
41
46
|
}
|
package/src/base.ts
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { defineConfig, type OxlintConfig } from 'oxlint';
|
|
2
|
+
|
|
3
|
+
type BaseOptions = {
|
|
4
|
+
uiPath: string;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
// const DEFAULT_OPTIONS: BaseOptions = {};
|
|
8
|
+
|
|
9
|
+
export default function (_options?: Partial<BaseOptions>) {
|
|
10
|
+
// const opts = { ...DEFAULT_OPTIONS, ...options };
|
|
11
|
+
|
|
12
|
+
return defineConfig({
|
|
13
|
+
plugins: ['typescript', 'unicorn'],
|
|
14
|
+
jsPlugins: [],
|
|
15
|
+
categories: {
|
|
16
|
+
correctness: 'off',
|
|
17
|
+
},
|
|
18
|
+
env: {
|
|
19
|
+
builtin: true,
|
|
20
|
+
},
|
|
21
|
+
options: {
|
|
22
|
+
typeAware: true,
|
|
23
|
+
},
|
|
24
|
+
rules: {
|
|
25
|
+
'constructor-super': 'error',
|
|
26
|
+
'for-direction': 'error',
|
|
27
|
+
'getter-return': 'error',
|
|
28
|
+
'no-async-promise-executor': 'error',
|
|
29
|
+
'no-case-declarations': 'error',
|
|
30
|
+
'no-class-assign': 'error',
|
|
31
|
+
'no-compare-neg-zero': 'error',
|
|
32
|
+
'no-cond-assign': 'error',
|
|
33
|
+
'no-const-assign': 'error',
|
|
34
|
+
'no-constant-binary-expression': 'error',
|
|
35
|
+
'no-constant-condition': 'error',
|
|
36
|
+
'no-control-regex': 'error',
|
|
37
|
+
'no-debugger': 'error',
|
|
38
|
+
'no-delete-var': 'error',
|
|
39
|
+
'no-dupe-class-members': 'error',
|
|
40
|
+
'no-dupe-else-if': 'error',
|
|
41
|
+
'no-dupe-keys': 'error',
|
|
42
|
+
'no-duplicate-case': 'error',
|
|
43
|
+
'no-empty': 'error',
|
|
44
|
+
'no-empty-character-class': 'error',
|
|
45
|
+
'no-empty-pattern': 'error',
|
|
46
|
+
'no-empty-static-block': 'error',
|
|
47
|
+
'no-ex-assign': 'error',
|
|
48
|
+
'no-extra-boolean-cast': 'error',
|
|
49
|
+
'no-fallthrough': 'error',
|
|
50
|
+
'no-func-assign': 'error',
|
|
51
|
+
'no-global-assign': 'error',
|
|
52
|
+
'no-import-assign': 'error',
|
|
53
|
+
'no-invalid-regexp': 'error',
|
|
54
|
+
'no-irregular-whitespace': 'error',
|
|
55
|
+
'no-loss-of-precision': 'error',
|
|
56
|
+
'no-misleading-character-class': 'error',
|
|
57
|
+
'no-new-native-nonconstructor': 'error',
|
|
58
|
+
'no-nonoctal-decimal-escape': 'error',
|
|
59
|
+
'no-obj-calls': 'error',
|
|
60
|
+
'no-prototype-builtins': 'error',
|
|
61
|
+
'no-redeclare': 'error',
|
|
62
|
+
'no-regex-spaces': 'error',
|
|
63
|
+
'no-self-assign': 'error',
|
|
64
|
+
'no-setter-return': 'error',
|
|
65
|
+
'no-shadow-restricted-names': 'error',
|
|
66
|
+
'no-sparse-arrays': 'error',
|
|
67
|
+
'no-this-before-super': 'error',
|
|
68
|
+
'no-undef': 'error',
|
|
69
|
+
'no-unreachable': 'error',
|
|
70
|
+
'no-unsafe-finally': 'error',
|
|
71
|
+
'no-unsafe-negation': 'error',
|
|
72
|
+
'no-unsafe-optional-chaining': 'error',
|
|
73
|
+
'no-unused-labels': 'error',
|
|
74
|
+
'no-unused-private-class-members': 'error',
|
|
75
|
+
'no-unused-vars': 'warn',
|
|
76
|
+
'no-useless-backreference': 'error',
|
|
77
|
+
'no-useless-catch': 'error',
|
|
78
|
+
'no-useless-escape': 'error',
|
|
79
|
+
'no-with': 'error',
|
|
80
|
+
'require-yield': 'error',
|
|
81
|
+
'use-isnan': 'error',
|
|
82
|
+
'valid-typeof': 'error',
|
|
83
|
+
'@typescript-eslint/ban-ts-comment': 'error',
|
|
84
|
+
'no-array-constructor': 'error',
|
|
85
|
+
'@typescript-eslint/no-duplicate-enum-values': 'error',
|
|
86
|
+
'@typescript-eslint/no-empty-object-type': 'error',
|
|
87
|
+
'@typescript-eslint/no-explicit-any': 'error',
|
|
88
|
+
'@typescript-eslint/no-extra-non-null-assertion': 'error',
|
|
89
|
+
'@typescript-eslint/no-misused-new': 'error',
|
|
90
|
+
'@typescript-eslint/no-namespace': 'error',
|
|
91
|
+
'@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
|
|
92
|
+
'@typescript-eslint/no-require-imports': 'error',
|
|
93
|
+
'@typescript-eslint/no-this-alias': 'error',
|
|
94
|
+
'@typescript-eslint/no-unnecessary-type-constraint': 'error',
|
|
95
|
+
'@typescript-eslint/no-unsafe-declaration-merging': 'error',
|
|
96
|
+
'@typescript-eslint/no-unsafe-function-type': 'error',
|
|
97
|
+
'no-unused-expressions': 'warn',
|
|
98
|
+
'@typescript-eslint/no-wrapper-object-types': 'error',
|
|
99
|
+
'@typescript-eslint/prefer-as-const': 'error',
|
|
100
|
+
'@typescript-eslint/prefer-namespace-keyword': 'error',
|
|
101
|
+
'@typescript-eslint/triple-slash-reference': 'error',
|
|
102
|
+
},
|
|
103
|
+
overrides: [
|
|
104
|
+
{
|
|
105
|
+
files: ['**/*.{ts,tsx,mts,cts}'],
|
|
106
|
+
rules: {
|
|
107
|
+
'constructor-super': 'off',
|
|
108
|
+
'getter-return': 'off',
|
|
109
|
+
'no-class-assign': 'off',
|
|
110
|
+
'no-const-assign': 'off',
|
|
111
|
+
'no-dupe-class-members': 'off',
|
|
112
|
+
'no-dupe-keys': 'off',
|
|
113
|
+
'no-func-assign': 'off',
|
|
114
|
+
'no-import-assign': 'off',
|
|
115
|
+
'no-new-native-nonconstructor': 'off',
|
|
116
|
+
'no-obj-calls': 'off',
|
|
117
|
+
'no-redeclare': 'off',
|
|
118
|
+
'no-setter-return': 'off',
|
|
119
|
+
'no-this-before-super': 'off',
|
|
120
|
+
'no-undef': 'off',
|
|
121
|
+
'no-unreachable': 'off',
|
|
122
|
+
'no-unsafe-negation': 'off',
|
|
123
|
+
'no-var': 'error',
|
|
124
|
+
'no-with': 'off',
|
|
125
|
+
'prefer-const': 'error',
|
|
126
|
+
'prefer-rest-params': 'error',
|
|
127
|
+
'prefer-spread': 'error',
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
],
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export type { OxlintConfig };
|
package/src/next.ts
CHANGED
|
@@ -1,34 +1,81 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import nextTs from 'eslint-config-next/typescript';
|
|
5
|
-
import prettier from 'eslint-config-prettier/flat';
|
|
6
|
-
import * as reactCompiler from 'eslint-plugin-react-compiler';
|
|
7
|
-
import reactHooks from 'eslint-plugin-react-hooks';
|
|
8
|
-
import { type Config, defineConfig, globalIgnores } from 'eslint/config';
|
|
9
|
-
import tseslint from 'typescript-eslint';
|
|
1
|
+
import { defineConfig, type OxlintConfig } from 'oxlint';
|
|
2
|
+
import react, { type ReactOptions } from './react.ts';
|
|
3
|
+
import reactRefresh from 'eslint-plugin-react-refresh';
|
|
10
4
|
|
|
11
|
-
|
|
5
|
+
type NextOptions = ReactOptions & {
|
|
6
|
+
/**
|
|
7
|
+
* Sets the parent directory of UI components to ignore them in react-refresh.
|
|
8
|
+
* This allows multiple exports from the same file, which is common when using libraries like class-variance-authority.
|
|
9
|
+
*
|
|
10
|
+
* Set to `null` to disable react-refresh suppression for UI components.
|
|
11
|
+
*
|
|
12
|
+
* Defaults to `src/components/ui/`.
|
|
13
|
+
*/
|
|
14
|
+
uiPath: string | null;
|
|
15
|
+
};
|
|
12
16
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
{
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
...nextVitals,
|
|
24
|
-
...nextTs,
|
|
25
|
-
reactHooks.configs.flat.recommended,
|
|
26
|
-
reactCompiler.configs.recommended,
|
|
27
|
-
{
|
|
17
|
+
const DEFAULT_OPTIONS: NextOptions = { uiPath: 'src/components/ui/' };
|
|
18
|
+
|
|
19
|
+
export default function (options?: Partial<NextOptions>) {
|
|
20
|
+
const opts = { ...DEFAULT_OPTIONS, ...options };
|
|
21
|
+
|
|
22
|
+
return defineConfig({
|
|
23
|
+
extends: [react(options)],
|
|
24
|
+
plugins: ['nextjs'],
|
|
28
25
|
rules: {
|
|
29
|
-
'
|
|
26
|
+
'@next/next/google-font-display': 'warn',
|
|
27
|
+
'@next/next/google-font-preconnect': 'warn',
|
|
28
|
+
'@next/next/next-script-for-ga': 'warn',
|
|
29
|
+
'@next/next/no-async-client-component': 'warn',
|
|
30
|
+
'@next/next/no-before-interactive-script-outside-document': 'warn',
|
|
31
|
+
'@next/next/no-css-tags': 'warn',
|
|
32
|
+
'@next/next/no-head-element': 'warn',
|
|
33
|
+
'@next/next/no-html-link-for-pages': 'error',
|
|
34
|
+
'@next/next/no-page-custom-font': 'warn',
|
|
35
|
+
'@next/next/no-styled-jsx-in-document': 'warn',
|
|
36
|
+
'@next/next/no-sync-scripts': 'error',
|
|
37
|
+
'@next/next/no-title-in-document-head': 'warn',
|
|
38
|
+
'@next/next/no-typos': 'warn',
|
|
39
|
+
'@next/next/no-unwanted-polyfillio': 'warn',
|
|
40
|
+
'@next/next/inline-script-id': 'error',
|
|
41
|
+
'@next/next/no-assign-module-variable': 'error',
|
|
42
|
+
'@next/next/no-document-import-in-page': 'error',
|
|
43
|
+
'@next/next/no-duplicate-head': 'error',
|
|
44
|
+
'@next/next/no-head-import-in-document': 'error',
|
|
45
|
+
'@next/next/no-script-component-in-head': 'error',
|
|
30
46
|
},
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
47
|
+
ignorePatterns: ['.next/**', 'out/**', 'build/**', 'next-env.d.ts'],
|
|
48
|
+
overrides: [
|
|
49
|
+
// ignores warnings for special exports in page and layout files
|
|
50
|
+
// https://github.com/ArnaudBarre/eslint-plugin-react-refresh?tab=readme-ov-file#next-config
|
|
51
|
+
{
|
|
52
|
+
files: ['**/*.{js,jsx,mjs,ts,tsx,mts,cts}'],
|
|
53
|
+
rules: {
|
|
54
|
+
'react-refresh-js/only-export-components': [
|
|
55
|
+
'error',
|
|
56
|
+
{
|
|
57
|
+
allowExportNames: (reactRefresh.configs.next.rules as any)[
|
|
58
|
+
'react-refresh/only-export-components'
|
|
59
|
+
][1]['allowExportNames'],
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
opts.uiPath === null
|
|
65
|
+
? { files: [], rules: {} }
|
|
66
|
+
: {
|
|
67
|
+
files: [
|
|
68
|
+
`${opts.uiPath}/**/*.{js,jsx,mjs,ts,tsx,mts,cts}`.replaceAll(
|
|
69
|
+
'//',
|
|
70
|
+
'/',
|
|
71
|
+
),
|
|
72
|
+
],
|
|
73
|
+
rules: {
|
|
74
|
+
'react-refresh-js/only-export-components': 'off',
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export type { OxlintConfig };
|
package/src/node.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export default
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { defineConfig, type OxlintConfig } from 'oxlint';
|
|
2
|
+
import base from './base.ts';
|
|
3
|
+
|
|
4
|
+
type NodeOptions = {};
|
|
5
|
+
|
|
6
|
+
// const DEFAULT_OPTIONS: NodeOptions = {};
|
|
7
|
+
|
|
8
|
+
export default function (_options?: Partial<NodeOptions>) {
|
|
9
|
+
// const opts = { ...DEFAULT_OPTIONS, ...options };
|
|
10
|
+
return defineConfig({
|
|
11
|
+
extends: [base()],
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type { OxlintConfig };
|
package/src/react.ts
CHANGED
|
@@ -1,34 +1,76 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import reactHooks from 'eslint-plugin-react-hooks';
|
|
4
|
-
import reactRefresh from 'eslint-plugin-react-refresh';
|
|
5
|
-
import { defineConfig, globalIgnores, type Config } from 'eslint/config';
|
|
6
|
-
import globals from 'globals';
|
|
7
|
-
import tseslint from 'typescript-eslint';
|
|
1
|
+
import { defineConfig, type OxlintConfig } from 'oxlint';
|
|
2
|
+
import base from './base.ts';
|
|
8
3
|
|
|
9
|
-
export
|
|
4
|
+
export type ReactOptions = {};
|
|
10
5
|
|
|
11
|
-
|
|
12
|
-
js.configs.recommended,
|
|
13
|
-
tseslint.configs.recommended,
|
|
6
|
+
// const DEFAULT_OPTIONS: ReactOptions = {};
|
|
14
7
|
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
export default function (_options?: Partial<ReactOptions>) {
|
|
9
|
+
// const opts = { ...DEFAULT_OPTIONS, ...options };
|
|
17
10
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
11
|
+
return defineConfig({
|
|
12
|
+
extends: [base()],
|
|
13
|
+
plugins: ['react'],
|
|
14
|
+
jsPlugins: [
|
|
15
|
+
{ name: 'react-hooks-js', specifier: 'eslint-plugin-react-hooks' },
|
|
16
|
+
{ name: 'react-refresh-js', specifier: 'eslint-plugin-react-refresh' },
|
|
17
|
+
{ name: 'react-compiler-js', specifier: 'eslint-plugin-react-compiler' },
|
|
18
|
+
],
|
|
25
19
|
rules: {
|
|
26
|
-
'react-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
'react-hooks-js/rules-of-hooks': 'error',
|
|
21
|
+
'react-hooks-js/exhaustive-deps': 'warn',
|
|
22
|
+
'react-hooks-js/set-state-in-effect': 'warn',
|
|
23
|
+
'react-refresh-js/only-export-components': 'error',
|
|
24
|
+
'react-compiler-js/react-compiler': 'error',
|
|
30
25
|
},
|
|
31
|
-
|
|
26
|
+
overrides: [
|
|
27
|
+
{
|
|
28
|
+
files: ['**/*.{js,jsx,mjs,ts,tsx,mts,cts}'],
|
|
29
|
+
rules: {
|
|
30
|
+
'react/display-name': 'error',
|
|
31
|
+
'react/jsx-key': 'error',
|
|
32
|
+
'react/jsx-no-comment-textnodes': 'error',
|
|
33
|
+
'react/jsx-no-duplicate-props': 'error',
|
|
34
|
+
'react/jsx-no-target-blank': 'off',
|
|
35
|
+
'react/jsx-no-undef': 'error',
|
|
36
|
+
'react/no-children-prop': 'error',
|
|
37
|
+
'react/no-danger-with-children': 'error',
|
|
38
|
+
// "react/no-deprecated": "error", // not implemented yet in oxlint
|
|
39
|
+
'react/no-direct-mutation-state': 'error',
|
|
40
|
+
'react/no-find-dom-node': 'error',
|
|
41
|
+
'react/no-is-mounted': 'error',
|
|
42
|
+
'react/no-render-return-value': 'error',
|
|
43
|
+
'react/no-string-refs': 'error',
|
|
44
|
+
'react/no-unescaped-entities': 'error',
|
|
45
|
+
'react/no-unknown-property': 'off',
|
|
46
|
+
'react/no-unsafe': 'off',
|
|
47
|
+
'react/react-in-jsx-scope': 'off',
|
|
48
|
+
'react/require-render-return': 'error',
|
|
49
|
+
'import/no-anonymous-default-export': 'warn',
|
|
50
|
+
'jsx-a11y/alt-text': ['warn', { elements: ['img'], img: ['Image'] }],
|
|
51
|
+
'jsx-a11y/aria-props': 'warn',
|
|
52
|
+
'jsx-a11y/aria-proptypes': 'warn',
|
|
53
|
+
'jsx-a11y/aria-unsupported-elements': 'warn',
|
|
54
|
+
'jsx-a11y/role-has-required-aria-props': 'warn',
|
|
55
|
+
'jsx-a11y/role-supports-aria-props': 'warn',
|
|
56
|
+
},
|
|
57
|
+
globals: {
|
|
58
|
+
AudioWorkletGlobalScope: 'readonly',
|
|
59
|
+
AudioWorkletProcessor: 'readonly',
|
|
60
|
+
currentFrame: 'readonly',
|
|
61
|
+
currentTime: 'readonly',
|
|
62
|
+
registerProcessor: 'readonly',
|
|
63
|
+
sampleRate: 'readonly',
|
|
64
|
+
WorkletGlobalScope: 'readonly',
|
|
65
|
+
},
|
|
66
|
+
plugins: ['import', 'jsx-a11y'],
|
|
67
|
+
env: {
|
|
68
|
+
browser: true,
|
|
69
|
+
node: true,
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
});
|
|
74
|
+
}
|
|
32
75
|
|
|
33
|
-
|
|
34
|
-
]) satisfies Config[];
|
|
76
|
+
export type { OxlintConfig };
|