@jay-es/oxlint-config 0.1.0
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/LICENSE +21 -0
- package/README.md +90 -0
- package/dist/eslint-all.js +188 -0
- package/dist/eslint-recommended.js +66 -0
- package/dist/index.d.mts +20 -0
- package/dist/index.mjs +86 -0
- package/dist/typescript-all.js +151 -0
- package/dist/typescript-disable-type-checked.js +63 -0
- package/dist/typescript-eslint-recommended.js +25 -0
- package/dist/typescript-recommended-type-checked-only.js +52 -0
- package/dist/typescript-recommended-type-checked.js +72 -0
- package/dist/typescript-recommended.js +45 -0
- package/dist/typescript-strict-type-checked-only.js +91 -0
- package/dist/typescript-strict-type-checked.js +124 -0
- package/dist/typescript-strict.js +58 -0
- package/dist/typescript-stylistic-type-checked-only.js +33 -0
- package/dist/typescript-stylistic-type-checked.js +46 -0
- package/dist/typescript-stylistic.js +38 -0
- package/package.json +53 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 jay-es
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# @jay-es/oxlint-config
|
|
2
|
+
|
|
3
|
+
Ready-to-use [oxlint](https://oxc.rs/docs/guide/usage/linter.html) configs generated from popular ESLint configs (`@eslint/js`, `typescript-eslint`, ...), filtered down to only the rules oxlint actually supports.
|
|
4
|
+
|
|
5
|
+
Each source config is mechanically filtered against oxlint's own [configuration schema](https://github.com/oxc-project/oxc/blob/main/npm/oxlint/configuration_schema.json), so unsupported rules are dropped and rule names are rewritten to oxlint's naming convention (e.g. `@typescript-eslint/no-explicit-any` → `typescript/no-explicit-any`).
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
Each config is published as a subpath export. Import the `rules` object and spread it into your `.oxlintrc.json` (or `oxlint.config.ts`) `rules` field.
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { rules as recommended } from "@jay-es/oxlint-config/eslint-recommended";
|
|
13
|
+
import { rules as tsRecommended } from "@jay-es/oxlint-config/typescript-recommended";
|
|
14
|
+
|
|
15
|
+
export default {
|
|
16
|
+
rules: {
|
|
17
|
+
...recommended,
|
|
18
|
+
...tsRecommended,
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Available configs
|
|
24
|
+
|
|
25
|
+
### [`@eslint/js`](https://www.npmjs.com/package/@eslint/js)
|
|
26
|
+
|
|
27
|
+
| Config | Source |
|
|
28
|
+
| -------------------- | --------------------------------------------------------------------------------------------------------- |
|
|
29
|
+
| `eslint-recommended` | [`recommended`](https://github.com/eslint/eslint/blob/main/packages/js/src/configs/eslint-recommended.js) |
|
|
30
|
+
| `eslint-all` | [`all`](https://github.com/eslint/eslint/blob/main/packages/js/src/configs/eslint-all.js) |
|
|
31
|
+
|
|
32
|
+
### [`typescript-eslint`](https://typescript-eslint.io/users/configs/)
|
|
33
|
+
|
|
34
|
+
| Config | Source |
|
|
35
|
+
| ------------------------------------------ | --------------------------------------------------------------------------------------------------------- |
|
|
36
|
+
| `typescript-eslint-recommended` | [`eslintRecommended`](https://typescript-eslint.io/users/configs/#eslint-recommended) |
|
|
37
|
+
| `typescript-recommended` | [`recommended`](https://typescript-eslint.io/users/configs/#recommended) |
|
|
38
|
+
| `typescript-recommended-type-checked` | [`recommendedTypeChecked`](https://typescript-eslint.io/users/configs/#recommended-type-checked) |
|
|
39
|
+
| `typescript-recommended-type-checked-only` | [`recommendedTypeCheckedOnly`](https://typescript-eslint.io/users/configs/#recommended-type-checked-only) |
|
|
40
|
+
| `typescript-strict` | [`strict`](https://typescript-eslint.io/users/configs/#strict) |
|
|
41
|
+
| `typescript-strict-type-checked` | [`strictTypeChecked`](https://typescript-eslint.io/users/configs/#strict-type-checked) |
|
|
42
|
+
| `typescript-strict-type-checked-only` | [`strictTypeCheckedOnly`](https://typescript-eslint.io/users/configs/#strict-type-checked-only) |
|
|
43
|
+
| `typescript-stylistic` | [`stylistic`](https://typescript-eslint.io/users/configs/#stylistic) |
|
|
44
|
+
| `typescript-stylistic-type-checked` | [`stylisticTypeChecked`](https://typescript-eslint.io/users/configs/#stylistic-type-checked) |
|
|
45
|
+
| `typescript-stylistic-type-checked-only` | [`stylisticTypeCheckedOnly`](https://typescript-eslint.io/users/configs/#stylistic-type-checked-only) |
|
|
46
|
+
| `typescript-all` | [`all`](https://typescript-eslint.io/users/configs/#all) |
|
|
47
|
+
| `typescript-disable-type-checked` | [`disableTypeChecked`](https://typescript-eslint.io/users/configs/#disable-type-checked) |
|
|
48
|
+
|
|
49
|
+
More plugins (react-hooks, import, unicorn, ...) are planned.
|
|
50
|
+
|
|
51
|
+
## Advanced: building your own filtered config
|
|
52
|
+
|
|
53
|
+
If you want to filter a config from a plugin this package doesn't cover yet, you can use the exported utilities directly:
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
import { filterSupportedRules, mergeFlatConfigRules } from "@jay-es/oxlint-config";
|
|
57
|
+
|
|
58
|
+
// Works with a plain rules object...
|
|
59
|
+
const rules = filterSupportedRules({ "no-unused-vars": "error" });
|
|
60
|
+
|
|
61
|
+
// ...or an ESLint flat config array (rules are merged in order first).
|
|
62
|
+
const merged = mergeFlatConfigRules(someFlatConfigArray);
|
|
63
|
+
const filtered = filterSupportedRules(merged);
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Development
|
|
67
|
+
|
|
68
|
+
- Install dependencies:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
pnpm install
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
- Regenerate the configs in `dist/`:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
pnpm run generate
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
- Run the unit tests:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
pnpm run test
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
- Build the library:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
pnpm run build
|
|
90
|
+
```
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
// Source: @eslint/js all config
|
|
2
|
+
|
|
3
|
+
export const rules = {
|
|
4
|
+
"accessor-pairs": "error",
|
|
5
|
+
"array-callback-return": "error",
|
|
6
|
+
"arrow-body-style": "error",
|
|
7
|
+
"block-scoped-var": "error",
|
|
8
|
+
"capitalized-comments": "error",
|
|
9
|
+
"class-methods-use-this": "error",
|
|
10
|
+
"complexity": "error",
|
|
11
|
+
"constructor-super": "error",
|
|
12
|
+
"curly": "error",
|
|
13
|
+
"default-case": "error",
|
|
14
|
+
"default-case-last": "error",
|
|
15
|
+
"default-param-last": "error",
|
|
16
|
+
"eqeqeq": "error",
|
|
17
|
+
"for-direction": "error",
|
|
18
|
+
"func-name-matching": "error",
|
|
19
|
+
"func-names": "error",
|
|
20
|
+
"func-style": "error",
|
|
21
|
+
"getter-return": "error",
|
|
22
|
+
"grouped-accessor-pairs": "error",
|
|
23
|
+
"guard-for-in": "error",
|
|
24
|
+
"id-length": "error",
|
|
25
|
+
"id-match": "error",
|
|
26
|
+
"init-declarations": "error",
|
|
27
|
+
"logical-assignment-operators": "error",
|
|
28
|
+
"max-classes-per-file": "error",
|
|
29
|
+
"max-depth": "error",
|
|
30
|
+
"max-lines": "error",
|
|
31
|
+
"max-lines-per-function": "error",
|
|
32
|
+
"max-nested-callbacks": "error",
|
|
33
|
+
"max-params": "error",
|
|
34
|
+
"max-statements": "error",
|
|
35
|
+
"new-cap": "error",
|
|
36
|
+
"no-alert": "error",
|
|
37
|
+
"no-array-constructor": "error",
|
|
38
|
+
"no-async-promise-executor": "error",
|
|
39
|
+
"no-await-in-loop": "error",
|
|
40
|
+
"no-bitwise": "error",
|
|
41
|
+
"no-caller": "error",
|
|
42
|
+
"no-case-declarations": "error",
|
|
43
|
+
"no-class-assign": "error",
|
|
44
|
+
"no-compare-neg-zero": "error",
|
|
45
|
+
"no-cond-assign": "error",
|
|
46
|
+
"no-console": "error",
|
|
47
|
+
"no-const-assign": "error",
|
|
48
|
+
"no-constant-binary-expression": "error",
|
|
49
|
+
"no-constant-condition": "error",
|
|
50
|
+
"no-constructor-return": "error",
|
|
51
|
+
"no-continue": "error",
|
|
52
|
+
"no-control-regex": "error",
|
|
53
|
+
"no-debugger": "error",
|
|
54
|
+
"no-delete-var": "error",
|
|
55
|
+
"no-div-regex": "error",
|
|
56
|
+
"no-dupe-class-members": "error",
|
|
57
|
+
"no-dupe-else-if": "error",
|
|
58
|
+
"no-dupe-keys": "error",
|
|
59
|
+
"no-duplicate-case": "error",
|
|
60
|
+
"no-duplicate-imports": "error",
|
|
61
|
+
"no-else-return": "error",
|
|
62
|
+
"no-empty": "error",
|
|
63
|
+
"no-empty-character-class": "error",
|
|
64
|
+
"no-empty-function": "error",
|
|
65
|
+
"no-empty-pattern": "error",
|
|
66
|
+
"no-empty-static-block": "error",
|
|
67
|
+
"no-eq-null": "error",
|
|
68
|
+
"no-eval": "error",
|
|
69
|
+
"no-ex-assign": "error",
|
|
70
|
+
"no-extend-native": "error",
|
|
71
|
+
"no-extra-bind": "error",
|
|
72
|
+
"no-extra-boolean-cast": "error",
|
|
73
|
+
"no-extra-label": "error",
|
|
74
|
+
"no-fallthrough": "error",
|
|
75
|
+
"no-func-assign": "error",
|
|
76
|
+
"no-global-assign": "error",
|
|
77
|
+
"no-implicit-coercion": "error",
|
|
78
|
+
"no-implicit-globals": "error",
|
|
79
|
+
"no-implied-eval": "error",
|
|
80
|
+
"no-import-assign": "error",
|
|
81
|
+
"no-inline-comments": "error",
|
|
82
|
+
"no-inner-declarations": "error",
|
|
83
|
+
"no-invalid-regexp": "error",
|
|
84
|
+
"no-irregular-whitespace": "error",
|
|
85
|
+
"no-iterator": "error",
|
|
86
|
+
"no-label-var": "error",
|
|
87
|
+
"no-labels": "error",
|
|
88
|
+
"no-lone-blocks": "error",
|
|
89
|
+
"no-lonely-if": "error",
|
|
90
|
+
"no-loop-func": "error",
|
|
91
|
+
"no-loss-of-precision": "error",
|
|
92
|
+
"no-magic-numbers": "error",
|
|
93
|
+
"no-misleading-character-class": "error",
|
|
94
|
+
"no-multi-assign": "error",
|
|
95
|
+
"no-multi-str": "error",
|
|
96
|
+
"no-negated-condition": "error",
|
|
97
|
+
"no-nested-ternary": "error",
|
|
98
|
+
"no-new": "error",
|
|
99
|
+
"no-new-func": "error",
|
|
100
|
+
"no-new-native-nonconstructor": "error",
|
|
101
|
+
"no-new-wrappers": "error",
|
|
102
|
+
"no-nonoctal-decimal-escape": "error",
|
|
103
|
+
"no-obj-calls": "error",
|
|
104
|
+
"no-object-constructor": "error",
|
|
105
|
+
"no-param-reassign": "error",
|
|
106
|
+
"no-plusplus": "error",
|
|
107
|
+
"no-promise-executor-return": "error",
|
|
108
|
+
"no-proto": "error",
|
|
109
|
+
"no-prototype-builtins": "error",
|
|
110
|
+
"no-redeclare": "error",
|
|
111
|
+
"no-regex-spaces": "error",
|
|
112
|
+
"no-restricted-exports": "error",
|
|
113
|
+
"no-restricted-globals": "error",
|
|
114
|
+
"no-restricted-imports": "error",
|
|
115
|
+
"no-restricted-properties": "error",
|
|
116
|
+
"no-return-assign": "error",
|
|
117
|
+
"no-script-url": "error",
|
|
118
|
+
"no-self-assign": "error",
|
|
119
|
+
"no-self-compare": "error",
|
|
120
|
+
"no-sequences": "error",
|
|
121
|
+
"no-setter-return": "error",
|
|
122
|
+
"no-shadow": "error",
|
|
123
|
+
"no-shadow-restricted-names": "error",
|
|
124
|
+
"no-sparse-arrays": "error",
|
|
125
|
+
"no-template-curly-in-string": "error",
|
|
126
|
+
"no-ternary": "error",
|
|
127
|
+
"no-this-before-super": "error",
|
|
128
|
+
"no-throw-literal": "error",
|
|
129
|
+
"no-unassigned-vars": "error",
|
|
130
|
+
"no-undef": "error",
|
|
131
|
+
"no-undefined": "error",
|
|
132
|
+
"no-underscore-dangle": "error",
|
|
133
|
+
"no-unexpected-multiline": "error",
|
|
134
|
+
"no-unmodified-loop-condition": "error",
|
|
135
|
+
"no-unneeded-ternary": "error",
|
|
136
|
+
"no-unreachable": "error",
|
|
137
|
+
"no-unsafe-finally": "error",
|
|
138
|
+
"no-unsafe-negation": "error",
|
|
139
|
+
"no-unsafe-optional-chaining": "error",
|
|
140
|
+
"no-unused-expressions": "error",
|
|
141
|
+
"no-unused-labels": "error",
|
|
142
|
+
"no-unused-private-class-members": "error",
|
|
143
|
+
"no-unused-vars": "error",
|
|
144
|
+
"no-use-before-define": "error",
|
|
145
|
+
"no-useless-assignment": "error",
|
|
146
|
+
"no-useless-backreference": "error",
|
|
147
|
+
"no-useless-call": "error",
|
|
148
|
+
"no-useless-catch": "error",
|
|
149
|
+
"no-useless-computed-key": "error",
|
|
150
|
+
"no-useless-concat": "error",
|
|
151
|
+
"no-useless-constructor": "error",
|
|
152
|
+
"no-useless-escape": "error",
|
|
153
|
+
"no-useless-rename": "error",
|
|
154
|
+
"no-useless-return": "error",
|
|
155
|
+
"no-var": "error",
|
|
156
|
+
"no-void": "error",
|
|
157
|
+
"no-warning-comments": "error",
|
|
158
|
+
"no-with": "error",
|
|
159
|
+
"object-shorthand": "error",
|
|
160
|
+
"operator-assignment": "error",
|
|
161
|
+
"prefer-arrow-callback": "error",
|
|
162
|
+
"prefer-const": "error",
|
|
163
|
+
"prefer-destructuring": "error",
|
|
164
|
+
"prefer-exponentiation-operator": "error",
|
|
165
|
+
"prefer-named-capture-group": "error",
|
|
166
|
+
"prefer-numeric-literals": "error",
|
|
167
|
+
"prefer-object-has-own": "error",
|
|
168
|
+
"prefer-object-spread": "error",
|
|
169
|
+
"prefer-promise-reject-errors": "error",
|
|
170
|
+
"prefer-regex-literals": "error",
|
|
171
|
+
"prefer-rest-params": "error",
|
|
172
|
+
"prefer-spread": "error",
|
|
173
|
+
"prefer-template": "error",
|
|
174
|
+
"preserve-caught-error": "error",
|
|
175
|
+
"radix": "error",
|
|
176
|
+
"require-await": "error",
|
|
177
|
+
"require-unicode-regexp": "error",
|
|
178
|
+
"require-yield": "error",
|
|
179
|
+
"sort-imports": "error",
|
|
180
|
+
"sort-keys": "error",
|
|
181
|
+
"sort-vars": "error",
|
|
182
|
+
"symbol-description": "error",
|
|
183
|
+
"unicode-bom": "error",
|
|
184
|
+
"use-isnan": "error",
|
|
185
|
+
"valid-typeof": "error",
|
|
186
|
+
"vars-on-top": "error",
|
|
187
|
+
"yoda": "error"
|
|
188
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// Source: @eslint/js recommended config
|
|
2
|
+
|
|
3
|
+
export const rules = {
|
|
4
|
+
"constructor-super": "error",
|
|
5
|
+
"for-direction": "error",
|
|
6
|
+
"getter-return": "error",
|
|
7
|
+
"no-async-promise-executor": "error",
|
|
8
|
+
"no-case-declarations": "error",
|
|
9
|
+
"no-class-assign": "error",
|
|
10
|
+
"no-compare-neg-zero": "error",
|
|
11
|
+
"no-cond-assign": "error",
|
|
12
|
+
"no-const-assign": "error",
|
|
13
|
+
"no-constant-binary-expression": "error",
|
|
14
|
+
"no-constant-condition": "error",
|
|
15
|
+
"no-control-regex": "error",
|
|
16
|
+
"no-debugger": "error",
|
|
17
|
+
"no-delete-var": "error",
|
|
18
|
+
"no-dupe-class-members": "error",
|
|
19
|
+
"no-dupe-else-if": "error",
|
|
20
|
+
"no-dupe-keys": "error",
|
|
21
|
+
"no-duplicate-case": "error",
|
|
22
|
+
"no-empty": "error",
|
|
23
|
+
"no-empty-character-class": "error",
|
|
24
|
+
"no-empty-pattern": "error",
|
|
25
|
+
"no-empty-static-block": "error",
|
|
26
|
+
"no-ex-assign": "error",
|
|
27
|
+
"no-extra-boolean-cast": "error",
|
|
28
|
+
"no-fallthrough": "error",
|
|
29
|
+
"no-func-assign": "error",
|
|
30
|
+
"no-global-assign": "error",
|
|
31
|
+
"no-import-assign": "error",
|
|
32
|
+
"no-invalid-regexp": "error",
|
|
33
|
+
"no-irregular-whitespace": "error",
|
|
34
|
+
"no-loss-of-precision": "error",
|
|
35
|
+
"no-misleading-character-class": "error",
|
|
36
|
+
"no-new-native-nonconstructor": "error",
|
|
37
|
+
"no-nonoctal-decimal-escape": "error",
|
|
38
|
+
"no-obj-calls": "error",
|
|
39
|
+
"no-prototype-builtins": "error",
|
|
40
|
+
"no-redeclare": "error",
|
|
41
|
+
"no-regex-spaces": "error",
|
|
42
|
+
"no-self-assign": "error",
|
|
43
|
+
"no-setter-return": "error",
|
|
44
|
+
"no-shadow-restricted-names": "error",
|
|
45
|
+
"no-sparse-arrays": "error",
|
|
46
|
+
"no-this-before-super": "error",
|
|
47
|
+
"no-unassigned-vars": "error",
|
|
48
|
+
"no-undef": "error",
|
|
49
|
+
"no-unexpected-multiline": "error",
|
|
50
|
+
"no-unreachable": "error",
|
|
51
|
+
"no-unsafe-finally": "error",
|
|
52
|
+
"no-unsafe-negation": "error",
|
|
53
|
+
"no-unsafe-optional-chaining": "error",
|
|
54
|
+
"no-unused-labels": "error",
|
|
55
|
+
"no-unused-private-class-members": "error",
|
|
56
|
+
"no-unused-vars": "error",
|
|
57
|
+
"no-useless-assignment": "error",
|
|
58
|
+
"no-useless-backreference": "error",
|
|
59
|
+
"no-useless-catch": "error",
|
|
60
|
+
"no-useless-escape": "error",
|
|
61
|
+
"no-with": "error",
|
|
62
|
+
"preserve-caught-error": "error",
|
|
63
|
+
"require-yield": "error",
|
|
64
|
+
"use-isnan": "error",
|
|
65
|
+
"valid-typeof": "error"
|
|
66
|
+
};
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/filter-rules.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* rules のうち、oxlint が対応しているルールだけを残し、キーを oxlint の命名規則
|
|
4
|
+
* (例: "@typescript-eslint/no-explicit-any" → "typescript/no-explicit-any")に変換する。
|
|
5
|
+
* 複数プラグインのルールが混在する config でもそのまま渡せる。
|
|
6
|
+
*/
|
|
7
|
+
declare function filterSupportedRules(rules: Record<string, unknown>): Record<string, unknown>;
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/merge-flat-config-rules.d.ts
|
|
10
|
+
/**
|
|
11
|
+
* ESLint flat config 形式(単一の config オブジェクト、またはその配列)から
|
|
12
|
+
* rules を順番にマージした結果を返す。後の要素の設定で上書きされる点は
|
|
13
|
+
* ESLint の flat config が配列を適用する挙動と同じ。
|
|
14
|
+
*
|
|
15
|
+
* config の型はツールによって微妙に異なる(例: typescript-eslint 独自の RuleEntry 型)ため、
|
|
16
|
+
* 厳密な型を要求せず unknown で受け取り、実行時に rules の有無を判定する。
|
|
17
|
+
*/
|
|
18
|
+
declare function mergeFlatConfigRules(config: unknown): Record<string, unknown>;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { filterSupportedRules, mergeFlatConfigRules };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
//#region src/parse-rule-key.ts
|
|
5
|
+
/**
|
|
6
|
+
* "@typescript-eslint/no-explicit-any" のようなルールキーを
|
|
7
|
+
* プラグイン名とルール名に分割する。接頭辞がない場合は "eslint" プラグイン扱いとする。
|
|
8
|
+
*/
|
|
9
|
+
function parseRuleKey(ruleKey) {
|
|
10
|
+
const slashIndex = ruleKey.indexOf("/");
|
|
11
|
+
return slashIndex === -1 ? ["eslint", ruleKey] : [ruleKey.slice(0, slashIndex), ruleKey.slice(slashIndex + 1)];
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/oxlint-schema.ts
|
|
15
|
+
const require = createRequire(import.meta.url);
|
|
16
|
+
function loadOxlintSchema() {
|
|
17
|
+
const oxlintPackageJsonPath = require.resolve("oxlint/package.json");
|
|
18
|
+
const schemaText = readFileSync(path.join(path.dirname(oxlintPackageJsonPath), "configuration_schema.json"), "utf8");
|
|
19
|
+
return JSON.parse(schemaText);
|
|
20
|
+
}
|
|
21
|
+
function buildOxlintRulesByPlugin() {
|
|
22
|
+
const schema = loadOxlintSchema();
|
|
23
|
+
const ruleKeys = Object.keys(schema.definitions.DummyRuleMap.properties);
|
|
24
|
+
const grouped = Object.groupBy(ruleKeys.map(parseRuleKey), ([plugin]) => plugin);
|
|
25
|
+
return Object.fromEntries(Object.entries(grouped).map(([plugin, entries]) => [plugin, new Set((entries ?? []).map(([, rule]) => rule))]));
|
|
26
|
+
}
|
|
27
|
+
let oxlintRulesByPluginCache;
|
|
28
|
+
/**
|
|
29
|
+
* oxlint がサポートするルールを、プラグイン名 -> ルール名の Set にまとめたものを返す。
|
|
30
|
+
* プラグイン接頭辞のないルール(例: "no-unused-vars")は "eslint" プラグイン扱いとする。
|
|
31
|
+
* スキーマの読み込みは初回呼び出し時のみ行い、以降はキャッシュを返す。
|
|
32
|
+
*/
|
|
33
|
+
function getOxlintRulesByPlugin() {
|
|
34
|
+
oxlintRulesByPluginCache ??= buildOxlintRulesByPlugin();
|
|
35
|
+
return oxlintRulesByPluginCache;
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/filter-rules.ts
|
|
39
|
+
/**
|
|
40
|
+
* ESLint 系のプラグイン名から、oxlint の configuration schema 上でのプラグイン名への対応表。
|
|
41
|
+
* ここに載っていないプラグインのルールは oxlint 非対応として除外される。
|
|
42
|
+
* ファイル名の接頭辞にもこの値を使う(例: "typescript-recommended.js")。
|
|
43
|
+
*/
|
|
44
|
+
const OXLINT_PLUGIN_NAME_BY_SOURCE = {
|
|
45
|
+
eslint: "eslint",
|
|
46
|
+
"@typescript-eslint": "typescript"
|
|
47
|
+
};
|
|
48
|
+
function toOxlintRuleKey(oxlintPlugin, ruleName) {
|
|
49
|
+
return oxlintPlugin === "eslint" ? ruleName : `${oxlintPlugin}/${ruleName}`;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* rules のうち、oxlint が対応しているルールだけを残し、キーを oxlint の命名規則
|
|
53
|
+
* (例: "@typescript-eslint/no-explicit-any" → "typescript/no-explicit-any")に変換する。
|
|
54
|
+
* 複数プラグインのルールが混在する config でもそのまま渡せる。
|
|
55
|
+
*/
|
|
56
|
+
function filterSupportedRules(rules) {
|
|
57
|
+
const oxlintRulesByPlugin = getOxlintRulesByPlugin();
|
|
58
|
+
const result = {};
|
|
59
|
+
for (const [ruleKey, value] of Object.entries(rules)) {
|
|
60
|
+
const [sourcePlugin, ruleName] = parseRuleKey(ruleKey);
|
|
61
|
+
const oxlintPlugin = OXLINT_PLUGIN_NAME_BY_SOURCE[sourcePlugin];
|
|
62
|
+
if (oxlintPlugin === void 0) continue;
|
|
63
|
+
if (!oxlintRulesByPlugin[oxlintPlugin]?.has(ruleName)) continue;
|
|
64
|
+
result[toOxlintRuleKey(oxlintPlugin, ruleName)] = value;
|
|
65
|
+
}
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region src/merge-flat-config-rules.ts
|
|
70
|
+
function getRules(config) {
|
|
71
|
+
if (config !== null && typeof config === "object" && "rules" in config && config.rules !== null && typeof config.rules === "object") return config.rules;
|
|
72
|
+
return {};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* ESLint flat config 形式(単一の config オブジェクト、またはその配列)から
|
|
76
|
+
* rules を順番にマージした結果を返す。後の要素の設定で上書きされる点は
|
|
77
|
+
* ESLint の flat config が配列を適用する挙動と同じ。
|
|
78
|
+
*
|
|
79
|
+
* config の型はツールによって微妙に異なる(例: typescript-eslint 独自の RuleEntry 型)ため、
|
|
80
|
+
* 厳密な型を要求せず unknown で受け取り、実行時に rules の有無を判定する。
|
|
81
|
+
*/
|
|
82
|
+
function mergeFlatConfigRules(config) {
|
|
83
|
+
return Object.assign({}, ...(Array.isArray(config) ? config : [config]).map(getRules));
|
|
84
|
+
}
|
|
85
|
+
//#endregion
|
|
86
|
+
export { filterSupportedRules, mergeFlatConfigRules };
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
// Source: typescript-eslint all config
|
|
2
|
+
|
|
3
|
+
export const rules = {
|
|
4
|
+
"constructor-super": "off",
|
|
5
|
+
"getter-return": "off",
|
|
6
|
+
"no-class-assign": "off",
|
|
7
|
+
"no-const-assign": "off",
|
|
8
|
+
"no-dupe-class-members": "off",
|
|
9
|
+
"no-dupe-keys": "off",
|
|
10
|
+
"no-func-assign": "off",
|
|
11
|
+
"no-import-assign": "off",
|
|
12
|
+
"no-new-native-nonconstructor": "off",
|
|
13
|
+
"no-obj-calls": "off",
|
|
14
|
+
"no-redeclare": "off",
|
|
15
|
+
"no-setter-return": "off",
|
|
16
|
+
"no-this-before-super": "off",
|
|
17
|
+
"no-undef": "off",
|
|
18
|
+
"no-unreachable": "off",
|
|
19
|
+
"no-unsafe-negation": "off",
|
|
20
|
+
"no-var": "error",
|
|
21
|
+
"no-with": "off",
|
|
22
|
+
"prefer-const": "error",
|
|
23
|
+
"prefer-rest-params": "error",
|
|
24
|
+
"prefer-spread": "error",
|
|
25
|
+
"typescript/adjacent-overload-signatures": "error",
|
|
26
|
+
"typescript/array-type": "error",
|
|
27
|
+
"typescript/await-thenable": "error",
|
|
28
|
+
"typescript/ban-ts-comment": "error",
|
|
29
|
+
"typescript/ban-tslint-comment": "error",
|
|
30
|
+
"typescript/class-literal-property-style": "error",
|
|
31
|
+
"class-methods-use-this": "off",
|
|
32
|
+
"typescript/consistent-generic-constructors": "error",
|
|
33
|
+
"typescript/consistent-indexed-object-style": "error",
|
|
34
|
+
"typescript/consistent-return": "error",
|
|
35
|
+
"typescript/consistent-type-assertions": "error",
|
|
36
|
+
"typescript/consistent-type-definitions": "error",
|
|
37
|
+
"typescript/consistent-type-exports": "error",
|
|
38
|
+
"typescript/consistent-type-imports": "error",
|
|
39
|
+
"default-param-last": "off",
|
|
40
|
+
"typescript/dot-notation": "error",
|
|
41
|
+
"typescript/explicit-function-return-type": "error",
|
|
42
|
+
"typescript/explicit-member-accessibility": "error",
|
|
43
|
+
"typescript/explicit-module-boundary-types": "error",
|
|
44
|
+
"init-declarations": "off",
|
|
45
|
+
"max-params": "off",
|
|
46
|
+
"typescript/method-signature-style": "error",
|
|
47
|
+
"no-array-constructor": "off",
|
|
48
|
+
"typescript/no-array-delete": "error",
|
|
49
|
+
"typescript/no-base-to-string": "error",
|
|
50
|
+
"typescript/no-confusing-non-null-assertion": "error",
|
|
51
|
+
"typescript/no-confusing-void-expression": "error",
|
|
52
|
+
"typescript/no-deprecated": "error",
|
|
53
|
+
"typescript/no-duplicate-enum-values": "error",
|
|
54
|
+
"typescript/no-duplicate-type-constituents": "error",
|
|
55
|
+
"typescript/no-dynamic-delete": "error",
|
|
56
|
+
"no-empty-function": "off",
|
|
57
|
+
"typescript/no-empty-object-type": "error",
|
|
58
|
+
"typescript/no-explicit-any": "error",
|
|
59
|
+
"typescript/no-extra-non-null-assertion": "error",
|
|
60
|
+
"typescript/no-extraneous-class": "error",
|
|
61
|
+
"typescript/no-floating-promises": "error",
|
|
62
|
+
"typescript/no-for-in-array": "error",
|
|
63
|
+
"no-implied-eval": "off",
|
|
64
|
+
"typescript/no-implied-eval": "error",
|
|
65
|
+
"typescript/no-import-type-side-effects": "error",
|
|
66
|
+
"typescript/no-inferrable-types": "error",
|
|
67
|
+
"typescript/no-invalid-void-type": "error",
|
|
68
|
+
"no-loop-func": "off",
|
|
69
|
+
"no-magic-numbers": "off",
|
|
70
|
+
"typescript/no-meaningless-void-operator": "error",
|
|
71
|
+
"typescript/no-misused-new": "error",
|
|
72
|
+
"typescript/no-misused-promises": "error",
|
|
73
|
+
"typescript/no-misused-spread": "error",
|
|
74
|
+
"typescript/no-mixed-enums": "error",
|
|
75
|
+
"typescript/no-namespace": "error",
|
|
76
|
+
"typescript/no-non-null-asserted-nullish-coalescing": "error",
|
|
77
|
+
"typescript/no-non-null-asserted-optional-chain": "error",
|
|
78
|
+
"typescript/no-non-null-assertion": "error",
|
|
79
|
+
"typescript/no-redundant-type-constituents": "error",
|
|
80
|
+
"typescript/no-require-imports": "error",
|
|
81
|
+
"no-restricted-imports": "off",
|
|
82
|
+
"typescript/no-restricted-types": "error",
|
|
83
|
+
"no-shadow": "off",
|
|
84
|
+
"typescript/no-this-alias": "error",
|
|
85
|
+
"typescript/no-unnecessary-boolean-literal-compare": "error",
|
|
86
|
+
"typescript/no-unnecessary-condition": "error",
|
|
87
|
+
"typescript/no-unnecessary-parameter-property-assignment": "error",
|
|
88
|
+
"typescript/no-unnecessary-qualifier": "error",
|
|
89
|
+
"typescript/no-unnecessary-template-expression": "error",
|
|
90
|
+
"typescript/no-unnecessary-type-arguments": "error",
|
|
91
|
+
"typescript/no-unnecessary-type-assertion": "error",
|
|
92
|
+
"typescript/no-unnecessary-type-constraint": "error",
|
|
93
|
+
"typescript/no-unnecessary-type-conversion": "error",
|
|
94
|
+
"typescript/no-unnecessary-type-parameters": "error",
|
|
95
|
+
"typescript/no-unsafe-argument": "error",
|
|
96
|
+
"typescript/no-unsafe-assignment": "error",
|
|
97
|
+
"typescript/no-unsafe-call": "error",
|
|
98
|
+
"typescript/no-unsafe-declaration-merging": "error",
|
|
99
|
+
"typescript/no-unsafe-enum-comparison": "error",
|
|
100
|
+
"typescript/no-unsafe-function-type": "error",
|
|
101
|
+
"typescript/no-unsafe-member-access": "error",
|
|
102
|
+
"typescript/no-unsafe-return": "error",
|
|
103
|
+
"typescript/no-unsafe-type-assertion": "error",
|
|
104
|
+
"typescript/no-unsafe-unary-minus": "error",
|
|
105
|
+
"no-unused-expressions": "off",
|
|
106
|
+
"no-unused-private-class-members": "off",
|
|
107
|
+
"no-unused-vars": "off",
|
|
108
|
+
"no-use-before-define": "off",
|
|
109
|
+
"no-useless-constructor": "off",
|
|
110
|
+
"typescript/no-useless-default-assignment": "error",
|
|
111
|
+
"typescript/no-useless-empty-export": "error",
|
|
112
|
+
"typescript/no-wrapper-object-types": "error",
|
|
113
|
+
"typescript/non-nullable-type-assertion-style": "error",
|
|
114
|
+
"no-throw-literal": "off",
|
|
115
|
+
"typescript/only-throw-error": "error",
|
|
116
|
+
"typescript/parameter-properties": "error",
|
|
117
|
+
"typescript/prefer-as-const": "error",
|
|
118
|
+
"prefer-destructuring": "off",
|
|
119
|
+
"typescript/prefer-enum-initializers": "error",
|
|
120
|
+
"typescript/prefer-find": "error",
|
|
121
|
+
"typescript/prefer-for-of": "error",
|
|
122
|
+
"typescript/prefer-function-type": "error",
|
|
123
|
+
"typescript/prefer-includes": "error",
|
|
124
|
+
"typescript/prefer-literal-enum-member": "error",
|
|
125
|
+
"typescript/prefer-namespace-keyword": "error",
|
|
126
|
+
"typescript/prefer-nullish-coalescing": "error",
|
|
127
|
+
"typescript/prefer-optional-chain": "error",
|
|
128
|
+
"prefer-promise-reject-errors": "off",
|
|
129
|
+
"typescript/prefer-promise-reject-errors": "error",
|
|
130
|
+
"typescript/prefer-readonly": "error",
|
|
131
|
+
"typescript/prefer-readonly-parameter-types": "error",
|
|
132
|
+
"typescript/prefer-reduce-type-parameter": "error",
|
|
133
|
+
"typescript/prefer-regexp-exec": "error",
|
|
134
|
+
"typescript/prefer-return-this-type": "error",
|
|
135
|
+
"typescript/prefer-string-starts-ends-with": "error",
|
|
136
|
+
"typescript/promise-function-async": "error",
|
|
137
|
+
"typescript/related-getter-setter-pairs": "error",
|
|
138
|
+
"typescript/require-array-sort-compare": "error",
|
|
139
|
+
"require-await": "off",
|
|
140
|
+
"typescript/require-await": "error",
|
|
141
|
+
"typescript/restrict-plus-operands": "error",
|
|
142
|
+
"typescript/restrict-template-expressions": "error",
|
|
143
|
+
"typescript/return-await": "error",
|
|
144
|
+
"typescript/strict-boolean-expressions": "error",
|
|
145
|
+
"typescript/strict-void-return": "error",
|
|
146
|
+
"typescript/switch-exhaustiveness-check": "error",
|
|
147
|
+
"typescript/triple-slash-reference": "error",
|
|
148
|
+
"typescript/unbound-method": "error",
|
|
149
|
+
"typescript/unified-signatures": "error",
|
|
150
|
+
"typescript/use-unknown-in-catch-callback-variable": "error"
|
|
151
|
+
};
|