@jabworks/oxlint-config 0.0.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/README.md +48 -0
- package/dist/index.cjs +263 -0
- package/dist/index.d.cts +72 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +72 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +258 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +52 -0
package/README.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# @jabworks/oxlint-config
|
|
2
|
+
|
|
3
|
+
Opinionated [oxlint](https://oxc.rs/docs/guide/usage/linter/) presets ported from [`@jabworks/eslint-plugin`](../eslint-plugin). Each preset is a complete, JSON-serializable `.oxlintrc` object.
|
|
4
|
+
|
|
5
|
+
## Presets
|
|
6
|
+
|
|
7
|
+
- `base` — JS best practices, ES6, import hygiene, `unicorn/filename-case`, with `correctness` category on
|
|
8
|
+
- `typescript` — base + typescript rules (some type-aware, see below)
|
|
9
|
+
- `react` — typescript + react / react-hooks / jsx-a11y + vitest test-file override
|
|
10
|
+
- `next` — react + nextjs plugin, default-export overrides for Next.js special files, ignores `.next/`
|
|
11
|
+
- `vitest` — standalone test-file override preset
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
`.oxlintrc.json` cannot extend an npm package, so serialize a preset:
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
// scripts/generate-oxlintrc.mjs
|
|
19
|
+
import { config } from '@jabworks/oxlint-config';
|
|
20
|
+
import { writeFileSync } from 'node:fs';
|
|
21
|
+
|
|
22
|
+
writeFileSync(
|
|
23
|
+
'.oxlintrc.json',
|
|
24
|
+
JSON.stringify({ $schema: './node_modules/oxlint/configuration_schema.json', ...config.configs.next }, null, 2),
|
|
25
|
+
);
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Then lint with:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
oxlint --type-aware --deny-warnings
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
You can also compose presets with the exported `mergeConfigs` helper.
|
|
35
|
+
|
|
36
|
+
## Type-aware rules
|
|
37
|
+
|
|
38
|
+
The typescript preset enables type-aware rules (`typescript/no-misused-promises`, `typescript/consistent-type-exports`, `typescript/restrict-template-expressions`, …). These require [`oxlint-tsgolint`](https://github.com/oxc-project/tsgolint) installed in the consuming project and running oxlint with `--type-aware`; without it they are silently skipped.
|
|
39
|
+
|
|
40
|
+
## Rules not ported from @jabworks/eslint-plugin
|
|
41
|
+
|
|
42
|
+
Unsupported by oxlint 1.58 (verified with `oxlint --rules` and `@oxlint/migrate --details`):
|
|
43
|
+
|
|
44
|
+
- Core: `no-floating-decimal`, `no-implied-eval`, `no-octal-escape`, `prefer-regex-literals`, `object-shorthand`, `no-unreachable-loop`, `camelcase`, `prefer-arrow-callback`, `no-undef-init`
|
|
45
|
+
- Import: `newline-after-import`, `no-extraneous-dependencies`, `no-relative-packages`, `no-useless-path-segments`, `no-deprecated`
|
|
46
|
+
- TypeScript: `method-signature-style`, `naming-convention`
|
|
47
|
+
- React: `function-component-definition`, `hook-use-state`, `jsx-no-leaked-render`, `jsx-sort-props`, `no-unstable-nested-components`
|
|
48
|
+
- Plugins with no oxlint equivalent: `simple-import-sort`, `eslint-comments`, `@stylistic` (formatting is Prettier's job)
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/configs/base.ts
|
|
3
|
+
/**
|
|
4
|
+
* Base preset, ported from `@jabworks/eslint-plugin` configs.base.
|
|
5
|
+
*
|
|
6
|
+
* Dropped (no oxlint equivalent as of 1.58): no-floating-decimal,
|
|
7
|
+
* no-implied-eval, no-octal-escape, prefer-regex-literals, object-shorthand,
|
|
8
|
+
* no-unreachable-loop, camelcase, prefer-arrow-callback, no-undef-init,
|
|
9
|
+
* import/newline-after-import, import/no-extraneous-dependencies,
|
|
10
|
+
* import/no-relative-packages, import/no-useless-path-segments,
|
|
11
|
+
* import/no-deprecated, simple-import-sort/*, eslint-comments/*, @stylistic/*.
|
|
12
|
+
*/
|
|
13
|
+
const base = {
|
|
14
|
+
plugins: ["import", "unicorn"],
|
|
15
|
+
categories: { correctness: "error" },
|
|
16
|
+
env: { builtin: true },
|
|
17
|
+
rules: {
|
|
18
|
+
"eslint/array-callback-return": ["error", { allowImplicit: true }],
|
|
19
|
+
"eslint/block-scoped-var": "error",
|
|
20
|
+
"eslint/curly": ["warn", "multi-line"],
|
|
21
|
+
"eslint/default-case-last": "error",
|
|
22
|
+
"eslint/eqeqeq": "error",
|
|
23
|
+
"eslint/grouped-accessor-pairs": "error",
|
|
24
|
+
"eslint/no-alert": "error",
|
|
25
|
+
"eslint/no-caller": "error",
|
|
26
|
+
"eslint/no-constructor-return": "error",
|
|
27
|
+
"eslint/no-else-return": "warn",
|
|
28
|
+
"eslint/no-eval": "error",
|
|
29
|
+
"eslint/no-extend-native": "error",
|
|
30
|
+
"eslint/no-extra-bind": "error",
|
|
31
|
+
"eslint/no-extra-label": "error",
|
|
32
|
+
"eslint/no-implicit-coercion": "error",
|
|
33
|
+
"eslint/no-iterator": "error",
|
|
34
|
+
"eslint/no-labels": "error",
|
|
35
|
+
"eslint/no-lone-blocks": "error",
|
|
36
|
+
"eslint/no-new": "error",
|
|
37
|
+
"eslint/no-new-func": "error",
|
|
38
|
+
"eslint/no-new-wrappers": "error",
|
|
39
|
+
"eslint/no-param-reassign": "error",
|
|
40
|
+
"eslint/no-proto": "error",
|
|
41
|
+
"eslint/no-return-assign": "error",
|
|
42
|
+
"eslint/no-script-url": "error",
|
|
43
|
+
"eslint/no-self-compare": "error",
|
|
44
|
+
"eslint/no-sequences": "error",
|
|
45
|
+
"eslint/no-useless-call": "error",
|
|
46
|
+
"eslint/no-useless-concat": "error",
|
|
47
|
+
"eslint/no-useless-return": "warn",
|
|
48
|
+
"eslint/prefer-promise-reject-errors": ["error", { allowEmptyReject: true }],
|
|
49
|
+
"eslint/yoda": "warn",
|
|
50
|
+
"eslint/no-useless-computed-key": "warn",
|
|
51
|
+
"eslint/no-useless-rename": "warn",
|
|
52
|
+
"eslint/no-var": "error",
|
|
53
|
+
"eslint/prefer-const": "warn",
|
|
54
|
+
"eslint/prefer-numeric-literals": "error",
|
|
55
|
+
"eslint/prefer-rest-params": "error",
|
|
56
|
+
"eslint/prefer-spread": "error",
|
|
57
|
+
"eslint/prefer-template": "warn",
|
|
58
|
+
"eslint/symbol-description": "error",
|
|
59
|
+
"eslint/no-console": ["warn", { allow: ["error", "warn"] }],
|
|
60
|
+
"eslint/no-constant-binary-expression": "error",
|
|
61
|
+
"eslint/no-promise-executor-return": "error",
|
|
62
|
+
"eslint/no-template-curly-in-string": "error",
|
|
63
|
+
"eslint/func-names": ["error", "as-needed"],
|
|
64
|
+
"eslint/new-cap": ["error", { capIsNew: false }],
|
|
65
|
+
"eslint/no-array-constructor": "error",
|
|
66
|
+
"eslint/no-bitwise": "error",
|
|
67
|
+
"eslint/no-lonely-if": "warn",
|
|
68
|
+
"eslint/no-multi-assign": "error",
|
|
69
|
+
"eslint/no-nested-ternary": "error",
|
|
70
|
+
"eslint/no-unneeded-ternary": "error",
|
|
71
|
+
"eslint/prefer-object-spread": "warn",
|
|
72
|
+
"eslint/no-label-var": "error",
|
|
73
|
+
"eslint/no-unused-vars": ["error", {
|
|
74
|
+
args: "after-used",
|
|
75
|
+
argsIgnorePattern: "^_",
|
|
76
|
+
ignoreRestSiblings: false,
|
|
77
|
+
vars: "all",
|
|
78
|
+
varsIgnorePattern: "^_"
|
|
79
|
+
}],
|
|
80
|
+
"import/first": "error",
|
|
81
|
+
"import/no-absolute-path": "error",
|
|
82
|
+
"import/no-default-export": "error",
|
|
83
|
+
"import/no-mutable-exports": "error",
|
|
84
|
+
"import/no-self-import": "error",
|
|
85
|
+
"import/no-cycle": "off",
|
|
86
|
+
"import/named": "off",
|
|
87
|
+
"unicorn/filename-case": ["error", { case: "kebabCase" }]
|
|
88
|
+
},
|
|
89
|
+
ignorePatterns: [
|
|
90
|
+
"dist/**",
|
|
91
|
+
"build/**",
|
|
92
|
+
"out/**",
|
|
93
|
+
"coverage/**",
|
|
94
|
+
"node_modules/**",
|
|
95
|
+
"eslint.config.js",
|
|
96
|
+
"eslint.config.mjs",
|
|
97
|
+
"eslint.config.cjs",
|
|
98
|
+
"*.config.js",
|
|
99
|
+
"*.config.mjs",
|
|
100
|
+
"*.config.cjs"
|
|
101
|
+
]
|
|
102
|
+
};
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/lib/merge.ts
|
|
105
|
+
/**
|
|
106
|
+
* Merge oxlint configs left-to-right into a single standalone config.
|
|
107
|
+
*
|
|
108
|
+
* Plugins and ignorePatterns are unioned, categories/rules/env/settings are
|
|
109
|
+
* shallow-merged (later configs win), and overrides are concatenated.
|
|
110
|
+
*/
|
|
111
|
+
const mergeConfigs = (...configs) => {
|
|
112
|
+
const result = {};
|
|
113
|
+
for (const config of configs) {
|
|
114
|
+
if (config.plugins) result.plugins = [...new Set([...result.plugins ?? [], ...config.plugins])];
|
|
115
|
+
if (config.categories) result.categories = {
|
|
116
|
+
...result.categories,
|
|
117
|
+
...config.categories
|
|
118
|
+
};
|
|
119
|
+
if (config.rules) result.rules = {
|
|
120
|
+
...result.rules,
|
|
121
|
+
...config.rules
|
|
122
|
+
};
|
|
123
|
+
if (config.env) result.env = {
|
|
124
|
+
...result.env,
|
|
125
|
+
...config.env
|
|
126
|
+
};
|
|
127
|
+
if (config.settings) result.settings = {
|
|
128
|
+
...result.settings,
|
|
129
|
+
...config.settings
|
|
130
|
+
};
|
|
131
|
+
if (config.overrides) result.overrides = [...result.overrides ?? [], ...config.overrides];
|
|
132
|
+
if (config.ignorePatterns) result.ignorePatterns = [...new Set([...result.ignorePatterns ?? [], ...config.ignorePatterns])];
|
|
133
|
+
}
|
|
134
|
+
return result;
|
|
135
|
+
};
|
|
136
|
+
const typescript = mergeConfigs(base, {
|
|
137
|
+
plugins: ["typescript"],
|
|
138
|
+
rules: {
|
|
139
|
+
"typescript/consistent-type-exports": ["warn", { fixMixedExportsWithInlineTypeSpecifier: true }],
|
|
140
|
+
"typescript/consistent-type-imports": ["warn", {
|
|
141
|
+
disallowTypeAnnotations: true,
|
|
142
|
+
fixStyle: "inline-type-imports",
|
|
143
|
+
prefer: "type-imports"
|
|
144
|
+
}],
|
|
145
|
+
"typescript/no-misused-promises": ["error", { checksVoidReturn: { attributes: false } }],
|
|
146
|
+
"typescript/no-redundant-type-constituents": "warn",
|
|
147
|
+
"typescript/no-unnecessary-qualifier": "warn",
|
|
148
|
+
"typescript/prefer-regexp-exec": "warn",
|
|
149
|
+
"typescript/require-array-sort-compare": ["error", { ignoreStringArrays: true }],
|
|
150
|
+
"typescript/restrict-template-expressions": ["error", { allowNumber: true }],
|
|
151
|
+
"typescript/switch-exhaustiveness-check": ["warn", { considerDefaultExhaustiveForUnions: true }],
|
|
152
|
+
"typescript/no-empty-object-type": ["error", { allowInterfaces: "with-single-extends" }],
|
|
153
|
+
"eslint/default-param-last": "error",
|
|
154
|
+
"eslint/no-loop-func": "error",
|
|
155
|
+
"eslint/no-useless-constructor": "error"
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
//#endregion
|
|
159
|
+
//#region src/configs/vitest.ts
|
|
160
|
+
/**
|
|
161
|
+
* Vitest preset, ported from `@jabworks/eslint-plugin` configs.vitest.
|
|
162
|
+
* Scoped to test files via an override, like the original flat config.
|
|
163
|
+
*/
|
|
164
|
+
const vitestOverride = {
|
|
165
|
+
files: [
|
|
166
|
+
"**/*.test.{js,ts,mjs,cjs,jsx,tsx}",
|
|
167
|
+
"**/__tests__/**",
|
|
168
|
+
"**/tests/**"
|
|
169
|
+
],
|
|
170
|
+
plugins: ["vitest"],
|
|
171
|
+
env: {
|
|
172
|
+
node: true,
|
|
173
|
+
vitest: true
|
|
174
|
+
},
|
|
175
|
+
rules: {
|
|
176
|
+
"vitest/max-nested-describe": ["error", { max: 3 }],
|
|
177
|
+
"vitest/no-commented-out-tests": "error",
|
|
178
|
+
"vitest/no-disabled-tests": "error",
|
|
179
|
+
"vitest/no-focused-tests": "error",
|
|
180
|
+
"vitest/no-identical-title": "error"
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
const vitest = {
|
|
184
|
+
categories: { correctness: "error" },
|
|
185
|
+
overrides: [vitestOverride]
|
|
186
|
+
};
|
|
187
|
+
const react = mergeConfigs(typescript, {
|
|
188
|
+
plugins: ["react", "jsx-a11y"],
|
|
189
|
+
env: { browser: true },
|
|
190
|
+
rules: {
|
|
191
|
+
"react/react-in-jsx-scope": "off",
|
|
192
|
+
"react/button-has-type": "warn",
|
|
193
|
+
"react/jsx-boolean-value": "warn",
|
|
194
|
+
"react/jsx-curly-brace-presence": "warn",
|
|
195
|
+
"react/jsx-fragments": "warn",
|
|
196
|
+
"react/jsx-no-target-blank": ["error", { allowReferrer: true }],
|
|
197
|
+
"react/jsx-no-useless-fragment": ["warn", { allowExpressions: true }],
|
|
198
|
+
"react/jsx-pascal-case": "warn",
|
|
199
|
+
"react/no-array-index-key": "warn",
|
|
200
|
+
"react/self-closing-comp": "warn",
|
|
201
|
+
"react/rules-of-hooks": "error",
|
|
202
|
+
"react/exhaustive-deps": "warn",
|
|
203
|
+
"jsx-a11y/no-autofocus": "off"
|
|
204
|
+
},
|
|
205
|
+
overrides: [vitestOverride]
|
|
206
|
+
});
|
|
207
|
+
//#endregion
|
|
208
|
+
//#region src/configs/next.ts
|
|
209
|
+
/**
|
|
210
|
+
* Next.js preset, ported from `@jabworks/eslint-plugin` configs.next.
|
|
211
|
+
* The nextjs plugin's recommended/core-web-vitals rules are enabled through
|
|
212
|
+
* the `correctness` category.
|
|
213
|
+
*/
|
|
214
|
+
const next = mergeConfigs(react, {
|
|
215
|
+
plugins: ["nextjs"],
|
|
216
|
+
overrides: [{
|
|
217
|
+
files: [
|
|
218
|
+
"*.config.js",
|
|
219
|
+
"*.config.mjs",
|
|
220
|
+
"*.config.cjs",
|
|
221
|
+
"*.config.ts",
|
|
222
|
+
"**/*.d.ts",
|
|
223
|
+
"**/*.stories.ts",
|
|
224
|
+
"**/*.stories.tsx",
|
|
225
|
+
"app/**/*error.tsx",
|
|
226
|
+
"app/**/layout.tsx",
|
|
227
|
+
"app/**/not-found.tsx",
|
|
228
|
+
"app/**/opengraph-image.tsx",
|
|
229
|
+
"app/**/page.tsx",
|
|
230
|
+
"app/apple-icon.tsx",
|
|
231
|
+
"app/robots.ts",
|
|
232
|
+
"app/sitemap.ts",
|
|
233
|
+
"next.config.mjs",
|
|
234
|
+
"src/app/**/*error.tsx",
|
|
235
|
+
"src/app/**/layout.tsx",
|
|
236
|
+
"src/app/**/not-found.tsx",
|
|
237
|
+
"src/app/**/opengraph-image.tsx",
|
|
238
|
+
"src/app/**/page.tsx",
|
|
239
|
+
"src/app/apple-icon.tsx",
|
|
240
|
+
"src/app/robots.ts",
|
|
241
|
+
"src/app/sitemap.ts"
|
|
242
|
+
],
|
|
243
|
+
rules: { "import/no-default-export": "off" }
|
|
244
|
+
}],
|
|
245
|
+
ignorePatterns: [".next/**"]
|
|
246
|
+
});
|
|
247
|
+
//#endregion
|
|
248
|
+
//#region src/index.ts
|
|
249
|
+
const config = { configs: {
|
|
250
|
+
base,
|
|
251
|
+
typescript,
|
|
252
|
+
react,
|
|
253
|
+
next,
|
|
254
|
+
vitest
|
|
255
|
+
} };
|
|
256
|
+
//#endregion
|
|
257
|
+
exports.base = base;
|
|
258
|
+
exports.config = config;
|
|
259
|
+
exports.mergeConfigs = mergeConfigs;
|
|
260
|
+
exports.next = next;
|
|
261
|
+
exports.react = react;
|
|
262
|
+
exports.typescript = typescript;
|
|
263
|
+
exports.vitest = vitest;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
//#region src/types.d.ts
|
|
2
|
+
type OxlintSeverity = 'off' | 'warn' | 'error';
|
|
3
|
+
type OxlintRuleEntry = OxlintSeverity | [OxlintSeverity, ...unknown[]];
|
|
4
|
+
interface OxlintOverride {
|
|
5
|
+
files: string[];
|
|
6
|
+
plugins?: string[];
|
|
7
|
+
rules?: Record<string, OxlintRuleEntry>;
|
|
8
|
+
env?: Record<string, boolean>;
|
|
9
|
+
}
|
|
10
|
+
interface OxlintConfig {
|
|
11
|
+
$schema?: string;
|
|
12
|
+
plugins?: string[];
|
|
13
|
+
categories?: Record<string, OxlintSeverity>;
|
|
14
|
+
rules?: Record<string, OxlintRuleEntry>;
|
|
15
|
+
overrides?: OxlintOverride[];
|
|
16
|
+
ignorePatterns?: string[];
|
|
17
|
+
env?: Record<string, boolean>;
|
|
18
|
+
settings?: Record<string, unknown>;
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/configs/base.d.ts
|
|
22
|
+
/**
|
|
23
|
+
* Base preset, ported from `@jabworks/eslint-plugin` configs.base.
|
|
24
|
+
*
|
|
25
|
+
* Dropped (no oxlint equivalent as of 1.58): no-floating-decimal,
|
|
26
|
+
* no-implied-eval, no-octal-escape, prefer-regex-literals, object-shorthand,
|
|
27
|
+
* no-unreachable-loop, camelcase, prefer-arrow-callback, no-undef-init,
|
|
28
|
+
* import/newline-after-import, import/no-extraneous-dependencies,
|
|
29
|
+
* import/no-relative-packages, import/no-useless-path-segments,
|
|
30
|
+
* import/no-deprecated, simple-import-sort/*, eslint-comments/*, @stylistic/*.
|
|
31
|
+
*/
|
|
32
|
+
declare const base: OxlintConfig;
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/configs/next.d.ts
|
|
35
|
+
/**
|
|
36
|
+
* Next.js preset, ported from `@jabworks/eslint-plugin` configs.next.
|
|
37
|
+
* The nextjs plugin's recommended/core-web-vitals rules are enabled through
|
|
38
|
+
* the `correctness` category.
|
|
39
|
+
*/
|
|
40
|
+
declare const next: OxlintConfig;
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/configs/react.d.ts
|
|
43
|
+
declare const react: OxlintConfig;
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/configs/typescript.d.ts
|
|
46
|
+
declare const typescript: OxlintConfig;
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src/configs/vitest.d.ts
|
|
49
|
+
declare const vitest: OxlintConfig;
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/lib/merge.d.ts
|
|
52
|
+
/**
|
|
53
|
+
* Merge oxlint configs left-to-right into a single standalone config.
|
|
54
|
+
*
|
|
55
|
+
* Plugins and ignorePatterns are unioned, categories/rules/env/settings are
|
|
56
|
+
* shallow-merged (later configs win), and overrides are concatenated.
|
|
57
|
+
*/
|
|
58
|
+
declare const mergeConfigs: (...configs: OxlintConfig[]) => OxlintConfig;
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/index.d.ts
|
|
61
|
+
declare const config: {
|
|
62
|
+
configs: {
|
|
63
|
+
base: OxlintConfig;
|
|
64
|
+
typescript: OxlintConfig;
|
|
65
|
+
react: OxlintConfig;
|
|
66
|
+
next: OxlintConfig;
|
|
67
|
+
vitest: OxlintConfig;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
//#endregion
|
|
71
|
+
export { type OxlintConfig, type OxlintOverride, type OxlintRuleEntry, type OxlintSeverity, base, config, mergeConfigs, next, react, typescript, vitest };
|
|
72
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/configs/base.ts","../src/configs/next.ts","../src/configs/react.ts","../src/configs/typescript.ts","../src/configs/vitest.ts","../src/lib/merge.ts","../src/index.ts"],"mappings":";KAAY,cAAA;AAAA,KAEA,eAAA,GAAkB,cAAA,IAAkB,cAAA;AAAA,UAE/B,cAAA;EACf,KAAA;EACA,OAAA;EACA,KAAA,GAAQ,MAAA,SAAe,eAAA;EACvB,GAAA,GAAM,MAAA;AAAA;AAAA,UAGS,YAAA;EACf,OAAA;EACA,OAAA;EACA,UAAA,GAAa,MAAA,SAAe,cAAA;EAC5B,KAAA,GAAQ,MAAA,SAAe,eAAA;EACvB,SAAA,GAAY,cAAA;EACZ,cAAA;EACA,GAAA,GAAM,MAAA;EACN,QAAA,GAAW,MAAA;AAAA;;;AAnBb;;;;;AAEA;;;;;AAFA,cCYM,IAAA,EAAM,YAAA;;;ADZZ;;;;;AAAA,cESM,IAAA,EAAM,YAAA;;;cC6BN,KAAA,EAAO,YAAA;;;cCKP,UAAA,EAAY,YAAA;;;cCrBZ,MAAA,EAAQ,YAAA;;;ALtBd;;;;;AAEA;AAFA,cMQa,YAAA,MAAmB,OAAA,EAAS,YAAA,OAAiB,YAAA;;;cCC7C,MAAA;;UAQZ,YAAA"}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
//#region src/types.d.ts
|
|
2
|
+
type OxlintSeverity = 'off' | 'warn' | 'error';
|
|
3
|
+
type OxlintRuleEntry = OxlintSeverity | [OxlintSeverity, ...unknown[]];
|
|
4
|
+
interface OxlintOverride {
|
|
5
|
+
files: string[];
|
|
6
|
+
plugins?: string[];
|
|
7
|
+
rules?: Record<string, OxlintRuleEntry>;
|
|
8
|
+
env?: Record<string, boolean>;
|
|
9
|
+
}
|
|
10
|
+
interface OxlintConfig {
|
|
11
|
+
$schema?: string;
|
|
12
|
+
plugins?: string[];
|
|
13
|
+
categories?: Record<string, OxlintSeverity>;
|
|
14
|
+
rules?: Record<string, OxlintRuleEntry>;
|
|
15
|
+
overrides?: OxlintOverride[];
|
|
16
|
+
ignorePatterns?: string[];
|
|
17
|
+
env?: Record<string, boolean>;
|
|
18
|
+
settings?: Record<string, unknown>;
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/configs/base.d.ts
|
|
22
|
+
/**
|
|
23
|
+
* Base preset, ported from `@jabworks/eslint-plugin` configs.base.
|
|
24
|
+
*
|
|
25
|
+
* Dropped (no oxlint equivalent as of 1.58): no-floating-decimal,
|
|
26
|
+
* no-implied-eval, no-octal-escape, prefer-regex-literals, object-shorthand,
|
|
27
|
+
* no-unreachable-loop, camelcase, prefer-arrow-callback, no-undef-init,
|
|
28
|
+
* import/newline-after-import, import/no-extraneous-dependencies,
|
|
29
|
+
* import/no-relative-packages, import/no-useless-path-segments,
|
|
30
|
+
* import/no-deprecated, simple-import-sort/*, eslint-comments/*, @stylistic/*.
|
|
31
|
+
*/
|
|
32
|
+
declare const base: OxlintConfig;
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/configs/next.d.ts
|
|
35
|
+
/**
|
|
36
|
+
* Next.js preset, ported from `@jabworks/eslint-plugin` configs.next.
|
|
37
|
+
* The nextjs plugin's recommended/core-web-vitals rules are enabled through
|
|
38
|
+
* the `correctness` category.
|
|
39
|
+
*/
|
|
40
|
+
declare const next: OxlintConfig;
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/configs/react.d.ts
|
|
43
|
+
declare const react: OxlintConfig;
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/configs/typescript.d.ts
|
|
46
|
+
declare const typescript: OxlintConfig;
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src/configs/vitest.d.ts
|
|
49
|
+
declare const vitest: OxlintConfig;
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/lib/merge.d.ts
|
|
52
|
+
/**
|
|
53
|
+
* Merge oxlint configs left-to-right into a single standalone config.
|
|
54
|
+
*
|
|
55
|
+
* Plugins and ignorePatterns are unioned, categories/rules/env/settings are
|
|
56
|
+
* shallow-merged (later configs win), and overrides are concatenated.
|
|
57
|
+
*/
|
|
58
|
+
declare const mergeConfigs: (...configs: OxlintConfig[]) => OxlintConfig;
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/index.d.ts
|
|
61
|
+
declare const config: {
|
|
62
|
+
configs: {
|
|
63
|
+
base: OxlintConfig;
|
|
64
|
+
typescript: OxlintConfig;
|
|
65
|
+
react: OxlintConfig;
|
|
66
|
+
next: OxlintConfig;
|
|
67
|
+
vitest: OxlintConfig;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
//#endregion
|
|
71
|
+
export { type OxlintConfig, type OxlintOverride, type OxlintRuleEntry, type OxlintSeverity, base, config, mergeConfigs, next, react, typescript, vitest };
|
|
72
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/configs/base.ts","../src/configs/next.ts","../src/configs/react.ts","../src/configs/typescript.ts","../src/configs/vitest.ts","../src/lib/merge.ts","../src/index.ts"],"mappings":";KAAY,cAAA;AAAA,KAEA,eAAA,GAAkB,cAAA,IAAkB,cAAA;AAAA,UAE/B,cAAA;EACf,KAAA;EACA,OAAA;EACA,KAAA,GAAQ,MAAA,SAAe,eAAA;EACvB,GAAA,GAAM,MAAA;AAAA;AAAA,UAGS,YAAA;EACf,OAAA;EACA,OAAA;EACA,UAAA,GAAa,MAAA,SAAe,cAAA;EAC5B,KAAA,GAAQ,MAAA,SAAe,eAAA;EACvB,SAAA,GAAY,cAAA;EACZ,cAAA;EACA,GAAA,GAAM,MAAA;EACN,QAAA,GAAW,MAAA;AAAA;;;AAnBb;;;;;AAEA;;;;;AAFA,cCYM,IAAA,EAAM,YAAA;;;ADZZ;;;;;AAAA,cESM,IAAA,EAAM,YAAA;;;cC6BN,KAAA,EAAO,YAAA;;;cCKP,UAAA,EAAY,YAAA;;;cCrBZ,MAAA,EAAQ,YAAA;;;ALtBd;;;;;AAEA;AAFA,cMQa,YAAA,MAAmB,OAAA,EAAS,YAAA,OAAiB,YAAA;;;cCC7C,MAAA;;UAQZ,YAAA"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
//#region src/configs/base.ts
|
|
2
|
+
/**
|
|
3
|
+
* Base preset, ported from `@jabworks/eslint-plugin` configs.base.
|
|
4
|
+
*
|
|
5
|
+
* Dropped (no oxlint equivalent as of 1.58): no-floating-decimal,
|
|
6
|
+
* no-implied-eval, no-octal-escape, prefer-regex-literals, object-shorthand,
|
|
7
|
+
* no-unreachable-loop, camelcase, prefer-arrow-callback, no-undef-init,
|
|
8
|
+
* import/newline-after-import, import/no-extraneous-dependencies,
|
|
9
|
+
* import/no-relative-packages, import/no-useless-path-segments,
|
|
10
|
+
* import/no-deprecated, simple-import-sort/*, eslint-comments/*, @stylistic/*.
|
|
11
|
+
*/
|
|
12
|
+
const base = {
|
|
13
|
+
plugins: ["import", "unicorn"],
|
|
14
|
+
categories: { correctness: "error" },
|
|
15
|
+
env: { builtin: true },
|
|
16
|
+
rules: {
|
|
17
|
+
"eslint/array-callback-return": ["error", { allowImplicit: true }],
|
|
18
|
+
"eslint/block-scoped-var": "error",
|
|
19
|
+
"eslint/curly": ["warn", "multi-line"],
|
|
20
|
+
"eslint/default-case-last": "error",
|
|
21
|
+
"eslint/eqeqeq": "error",
|
|
22
|
+
"eslint/grouped-accessor-pairs": "error",
|
|
23
|
+
"eslint/no-alert": "error",
|
|
24
|
+
"eslint/no-caller": "error",
|
|
25
|
+
"eslint/no-constructor-return": "error",
|
|
26
|
+
"eslint/no-else-return": "warn",
|
|
27
|
+
"eslint/no-eval": "error",
|
|
28
|
+
"eslint/no-extend-native": "error",
|
|
29
|
+
"eslint/no-extra-bind": "error",
|
|
30
|
+
"eslint/no-extra-label": "error",
|
|
31
|
+
"eslint/no-implicit-coercion": "error",
|
|
32
|
+
"eslint/no-iterator": "error",
|
|
33
|
+
"eslint/no-labels": "error",
|
|
34
|
+
"eslint/no-lone-blocks": "error",
|
|
35
|
+
"eslint/no-new": "error",
|
|
36
|
+
"eslint/no-new-func": "error",
|
|
37
|
+
"eslint/no-new-wrappers": "error",
|
|
38
|
+
"eslint/no-param-reassign": "error",
|
|
39
|
+
"eslint/no-proto": "error",
|
|
40
|
+
"eslint/no-return-assign": "error",
|
|
41
|
+
"eslint/no-script-url": "error",
|
|
42
|
+
"eslint/no-self-compare": "error",
|
|
43
|
+
"eslint/no-sequences": "error",
|
|
44
|
+
"eslint/no-useless-call": "error",
|
|
45
|
+
"eslint/no-useless-concat": "error",
|
|
46
|
+
"eslint/no-useless-return": "warn",
|
|
47
|
+
"eslint/prefer-promise-reject-errors": ["error", { allowEmptyReject: true }],
|
|
48
|
+
"eslint/yoda": "warn",
|
|
49
|
+
"eslint/no-useless-computed-key": "warn",
|
|
50
|
+
"eslint/no-useless-rename": "warn",
|
|
51
|
+
"eslint/no-var": "error",
|
|
52
|
+
"eslint/prefer-const": "warn",
|
|
53
|
+
"eslint/prefer-numeric-literals": "error",
|
|
54
|
+
"eslint/prefer-rest-params": "error",
|
|
55
|
+
"eslint/prefer-spread": "error",
|
|
56
|
+
"eslint/prefer-template": "warn",
|
|
57
|
+
"eslint/symbol-description": "error",
|
|
58
|
+
"eslint/no-console": ["warn", { allow: ["error", "warn"] }],
|
|
59
|
+
"eslint/no-constant-binary-expression": "error",
|
|
60
|
+
"eslint/no-promise-executor-return": "error",
|
|
61
|
+
"eslint/no-template-curly-in-string": "error",
|
|
62
|
+
"eslint/func-names": ["error", "as-needed"],
|
|
63
|
+
"eslint/new-cap": ["error", { capIsNew: false }],
|
|
64
|
+
"eslint/no-array-constructor": "error",
|
|
65
|
+
"eslint/no-bitwise": "error",
|
|
66
|
+
"eslint/no-lonely-if": "warn",
|
|
67
|
+
"eslint/no-multi-assign": "error",
|
|
68
|
+
"eslint/no-nested-ternary": "error",
|
|
69
|
+
"eslint/no-unneeded-ternary": "error",
|
|
70
|
+
"eslint/prefer-object-spread": "warn",
|
|
71
|
+
"eslint/no-label-var": "error",
|
|
72
|
+
"eslint/no-unused-vars": ["error", {
|
|
73
|
+
args: "after-used",
|
|
74
|
+
argsIgnorePattern: "^_",
|
|
75
|
+
ignoreRestSiblings: false,
|
|
76
|
+
vars: "all",
|
|
77
|
+
varsIgnorePattern: "^_"
|
|
78
|
+
}],
|
|
79
|
+
"import/first": "error",
|
|
80
|
+
"import/no-absolute-path": "error",
|
|
81
|
+
"import/no-default-export": "error",
|
|
82
|
+
"import/no-mutable-exports": "error",
|
|
83
|
+
"import/no-self-import": "error",
|
|
84
|
+
"import/no-cycle": "off",
|
|
85
|
+
"import/named": "off",
|
|
86
|
+
"unicorn/filename-case": ["error", { case: "kebabCase" }]
|
|
87
|
+
},
|
|
88
|
+
ignorePatterns: [
|
|
89
|
+
"dist/**",
|
|
90
|
+
"build/**",
|
|
91
|
+
"out/**",
|
|
92
|
+
"coverage/**",
|
|
93
|
+
"node_modules/**",
|
|
94
|
+
"eslint.config.js",
|
|
95
|
+
"eslint.config.mjs",
|
|
96
|
+
"eslint.config.cjs",
|
|
97
|
+
"*.config.js",
|
|
98
|
+
"*.config.mjs",
|
|
99
|
+
"*.config.cjs"
|
|
100
|
+
]
|
|
101
|
+
};
|
|
102
|
+
//#endregion
|
|
103
|
+
//#region src/lib/merge.ts
|
|
104
|
+
/**
|
|
105
|
+
* Merge oxlint configs left-to-right into a single standalone config.
|
|
106
|
+
*
|
|
107
|
+
* Plugins and ignorePatterns are unioned, categories/rules/env/settings are
|
|
108
|
+
* shallow-merged (later configs win), and overrides are concatenated.
|
|
109
|
+
*/
|
|
110
|
+
const mergeConfigs = (...configs) => {
|
|
111
|
+
const result = {};
|
|
112
|
+
for (const config of configs) {
|
|
113
|
+
if (config.plugins) result.plugins = [...new Set([...result.plugins ?? [], ...config.plugins])];
|
|
114
|
+
if (config.categories) result.categories = {
|
|
115
|
+
...result.categories,
|
|
116
|
+
...config.categories
|
|
117
|
+
};
|
|
118
|
+
if (config.rules) result.rules = {
|
|
119
|
+
...result.rules,
|
|
120
|
+
...config.rules
|
|
121
|
+
};
|
|
122
|
+
if (config.env) result.env = {
|
|
123
|
+
...result.env,
|
|
124
|
+
...config.env
|
|
125
|
+
};
|
|
126
|
+
if (config.settings) result.settings = {
|
|
127
|
+
...result.settings,
|
|
128
|
+
...config.settings
|
|
129
|
+
};
|
|
130
|
+
if (config.overrides) result.overrides = [...result.overrides ?? [], ...config.overrides];
|
|
131
|
+
if (config.ignorePatterns) result.ignorePatterns = [...new Set([...result.ignorePatterns ?? [], ...config.ignorePatterns])];
|
|
132
|
+
}
|
|
133
|
+
return result;
|
|
134
|
+
};
|
|
135
|
+
const typescript = mergeConfigs(base, {
|
|
136
|
+
plugins: ["typescript"],
|
|
137
|
+
rules: {
|
|
138
|
+
"typescript/consistent-type-exports": ["warn", { fixMixedExportsWithInlineTypeSpecifier: true }],
|
|
139
|
+
"typescript/consistent-type-imports": ["warn", {
|
|
140
|
+
disallowTypeAnnotations: true,
|
|
141
|
+
fixStyle: "inline-type-imports",
|
|
142
|
+
prefer: "type-imports"
|
|
143
|
+
}],
|
|
144
|
+
"typescript/no-misused-promises": ["error", { checksVoidReturn: { attributes: false } }],
|
|
145
|
+
"typescript/no-redundant-type-constituents": "warn",
|
|
146
|
+
"typescript/no-unnecessary-qualifier": "warn",
|
|
147
|
+
"typescript/prefer-regexp-exec": "warn",
|
|
148
|
+
"typescript/require-array-sort-compare": ["error", { ignoreStringArrays: true }],
|
|
149
|
+
"typescript/restrict-template-expressions": ["error", { allowNumber: true }],
|
|
150
|
+
"typescript/switch-exhaustiveness-check": ["warn", { considerDefaultExhaustiveForUnions: true }],
|
|
151
|
+
"typescript/no-empty-object-type": ["error", { allowInterfaces: "with-single-extends" }],
|
|
152
|
+
"eslint/default-param-last": "error",
|
|
153
|
+
"eslint/no-loop-func": "error",
|
|
154
|
+
"eslint/no-useless-constructor": "error"
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
//#endregion
|
|
158
|
+
//#region src/configs/vitest.ts
|
|
159
|
+
/**
|
|
160
|
+
* Vitest preset, ported from `@jabworks/eslint-plugin` configs.vitest.
|
|
161
|
+
* Scoped to test files via an override, like the original flat config.
|
|
162
|
+
*/
|
|
163
|
+
const vitestOverride = {
|
|
164
|
+
files: [
|
|
165
|
+
"**/*.test.{js,ts,mjs,cjs,jsx,tsx}",
|
|
166
|
+
"**/__tests__/**",
|
|
167
|
+
"**/tests/**"
|
|
168
|
+
],
|
|
169
|
+
plugins: ["vitest"],
|
|
170
|
+
env: {
|
|
171
|
+
node: true,
|
|
172
|
+
vitest: true
|
|
173
|
+
},
|
|
174
|
+
rules: {
|
|
175
|
+
"vitest/max-nested-describe": ["error", { max: 3 }],
|
|
176
|
+
"vitest/no-commented-out-tests": "error",
|
|
177
|
+
"vitest/no-disabled-tests": "error",
|
|
178
|
+
"vitest/no-focused-tests": "error",
|
|
179
|
+
"vitest/no-identical-title": "error"
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
const vitest = {
|
|
183
|
+
categories: { correctness: "error" },
|
|
184
|
+
overrides: [vitestOverride]
|
|
185
|
+
};
|
|
186
|
+
const react = mergeConfigs(typescript, {
|
|
187
|
+
plugins: ["react", "jsx-a11y"],
|
|
188
|
+
env: { browser: true },
|
|
189
|
+
rules: {
|
|
190
|
+
"react/react-in-jsx-scope": "off",
|
|
191
|
+
"react/button-has-type": "warn",
|
|
192
|
+
"react/jsx-boolean-value": "warn",
|
|
193
|
+
"react/jsx-curly-brace-presence": "warn",
|
|
194
|
+
"react/jsx-fragments": "warn",
|
|
195
|
+
"react/jsx-no-target-blank": ["error", { allowReferrer: true }],
|
|
196
|
+
"react/jsx-no-useless-fragment": ["warn", { allowExpressions: true }],
|
|
197
|
+
"react/jsx-pascal-case": "warn",
|
|
198
|
+
"react/no-array-index-key": "warn",
|
|
199
|
+
"react/self-closing-comp": "warn",
|
|
200
|
+
"react/rules-of-hooks": "error",
|
|
201
|
+
"react/exhaustive-deps": "warn",
|
|
202
|
+
"jsx-a11y/no-autofocus": "off"
|
|
203
|
+
},
|
|
204
|
+
overrides: [vitestOverride]
|
|
205
|
+
});
|
|
206
|
+
//#endregion
|
|
207
|
+
//#region src/configs/next.ts
|
|
208
|
+
/**
|
|
209
|
+
* Next.js preset, ported from `@jabworks/eslint-plugin` configs.next.
|
|
210
|
+
* The nextjs plugin's recommended/core-web-vitals rules are enabled through
|
|
211
|
+
* the `correctness` category.
|
|
212
|
+
*/
|
|
213
|
+
const next = mergeConfigs(react, {
|
|
214
|
+
plugins: ["nextjs"],
|
|
215
|
+
overrides: [{
|
|
216
|
+
files: [
|
|
217
|
+
"*.config.js",
|
|
218
|
+
"*.config.mjs",
|
|
219
|
+
"*.config.cjs",
|
|
220
|
+
"*.config.ts",
|
|
221
|
+
"**/*.d.ts",
|
|
222
|
+
"**/*.stories.ts",
|
|
223
|
+
"**/*.stories.tsx",
|
|
224
|
+
"app/**/*error.tsx",
|
|
225
|
+
"app/**/layout.tsx",
|
|
226
|
+
"app/**/not-found.tsx",
|
|
227
|
+
"app/**/opengraph-image.tsx",
|
|
228
|
+
"app/**/page.tsx",
|
|
229
|
+
"app/apple-icon.tsx",
|
|
230
|
+
"app/robots.ts",
|
|
231
|
+
"app/sitemap.ts",
|
|
232
|
+
"next.config.mjs",
|
|
233
|
+
"src/app/**/*error.tsx",
|
|
234
|
+
"src/app/**/layout.tsx",
|
|
235
|
+
"src/app/**/not-found.tsx",
|
|
236
|
+
"src/app/**/opengraph-image.tsx",
|
|
237
|
+
"src/app/**/page.tsx",
|
|
238
|
+
"src/app/apple-icon.tsx",
|
|
239
|
+
"src/app/robots.ts",
|
|
240
|
+
"src/app/sitemap.ts"
|
|
241
|
+
],
|
|
242
|
+
rules: { "import/no-default-export": "off" }
|
|
243
|
+
}],
|
|
244
|
+
ignorePatterns: [".next/**"]
|
|
245
|
+
});
|
|
246
|
+
//#endregion
|
|
247
|
+
//#region src/index.ts
|
|
248
|
+
const config = { configs: {
|
|
249
|
+
base,
|
|
250
|
+
typescript,
|
|
251
|
+
react,
|
|
252
|
+
next,
|
|
253
|
+
vitest
|
|
254
|
+
} };
|
|
255
|
+
//#endregion
|
|
256
|
+
export { base, config, mergeConfigs, next, react, typescript, vitest };
|
|
257
|
+
|
|
258
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/configs/base.ts","../src/lib/merge.ts","../src/configs/typescript.ts","../src/configs/vitest.ts","../src/configs/react.ts","../src/configs/next.ts","../src/index.ts"],"sourcesContent":["import type { OxlintConfig } from '../types.js';\n\n/**\n * Base preset, ported from `@jabworks/eslint-plugin` configs.base.\n *\n * Dropped (no oxlint equivalent as of 1.58): no-floating-decimal,\n * no-implied-eval, no-octal-escape, prefer-regex-literals, object-shorthand,\n * no-unreachable-loop, camelcase, prefer-arrow-callback, no-undef-init,\n * import/newline-after-import, import/no-extraneous-dependencies,\n * import/no-relative-packages, import/no-useless-path-segments,\n * import/no-deprecated, simple-import-sort/*, eslint-comments/*, @stylistic/*.\n */\nconst base: OxlintConfig = {\n plugins: ['import', 'unicorn'],\n categories: {\n correctness: 'error',\n },\n env: {\n builtin: true,\n },\n rules: {\n // Best practices\n 'eslint/array-callback-return': ['error', { allowImplicit: true }],\n 'eslint/block-scoped-var': 'error',\n 'eslint/curly': ['warn', 'multi-line'],\n 'eslint/default-case-last': 'error',\n 'eslint/eqeqeq': 'error',\n 'eslint/grouped-accessor-pairs': 'error',\n 'eslint/no-alert': 'error',\n 'eslint/no-caller': 'error',\n 'eslint/no-constructor-return': 'error',\n 'eslint/no-else-return': 'warn',\n 'eslint/no-eval': 'error',\n 'eslint/no-extend-native': 'error',\n 'eslint/no-extra-bind': 'error',\n 'eslint/no-extra-label': 'error',\n 'eslint/no-implicit-coercion': 'error',\n 'eslint/no-iterator': 'error',\n 'eslint/no-labels': 'error',\n 'eslint/no-lone-blocks': 'error',\n 'eslint/no-new': 'error',\n 'eslint/no-new-func': 'error',\n 'eslint/no-new-wrappers': 'error',\n 'eslint/no-param-reassign': 'error',\n 'eslint/no-proto': 'error',\n 'eslint/no-return-assign': 'error',\n 'eslint/no-script-url': 'error',\n 'eslint/no-self-compare': 'error',\n 'eslint/no-sequences': 'error',\n 'eslint/no-useless-call': 'error',\n 'eslint/no-useless-concat': 'error',\n 'eslint/no-useless-return': 'warn',\n 'eslint/prefer-promise-reject-errors': ['error', { allowEmptyReject: true }],\n 'eslint/yoda': 'warn',\n // ES6\n 'eslint/no-useless-computed-key': 'warn',\n 'eslint/no-useless-rename': 'warn',\n 'eslint/no-var': 'error',\n 'eslint/prefer-const': 'warn',\n 'eslint/prefer-numeric-literals': 'error',\n 'eslint/prefer-rest-params': 'error',\n 'eslint/prefer-spread': 'error',\n 'eslint/prefer-template': 'warn',\n 'eslint/symbol-description': 'error',\n // Possible errors\n 'eslint/no-console': ['warn', { allow: ['error', 'warn'] }],\n 'eslint/no-constant-binary-expression': 'error',\n 'eslint/no-promise-executor-return': 'error',\n 'eslint/no-template-curly-in-string': 'error',\n // Stylistic\n 'eslint/func-names': ['error', 'as-needed'],\n 'eslint/new-cap': ['error', { capIsNew: false }],\n 'eslint/no-array-constructor': 'error',\n 'eslint/no-bitwise': 'error',\n 'eslint/no-lonely-if': 'warn',\n 'eslint/no-multi-assign': 'error',\n 'eslint/no-nested-ternary': 'error',\n 'eslint/no-unneeded-ternary': 'error',\n 'eslint/prefer-object-spread': 'warn',\n // Variables\n 'eslint/no-label-var': 'error',\n 'eslint/no-unused-vars': [\n 'error',\n {\n args: 'after-used',\n argsIgnorePattern: '^_',\n ignoreRestSiblings: false,\n vars: 'all',\n varsIgnorePattern: '^_',\n },\n ],\n // Import\n 'import/first': 'error',\n 'import/no-absolute-path': 'error',\n 'import/no-default-export': 'error',\n 'import/no-mutable-exports': 'error',\n 'import/no-self-import': 'error',\n // This rule is the most taxing on performance, so we disable it by default.\n 'import/no-cycle': 'off',\n 'import/named': 'off',\n // Unicorn\n 'unicorn/filename-case': ['error', { case: 'kebabCase' }],\n },\n ignorePatterns: [\n 'dist/**',\n 'build/**',\n 'out/**',\n 'coverage/**',\n 'node_modules/**',\n 'eslint.config.js',\n 'eslint.config.mjs',\n 'eslint.config.cjs',\n '*.config.js',\n '*.config.mjs',\n '*.config.cjs',\n ],\n};\n\nexport default base;\n","import type { OxlintConfig } from '../types.js';\n\n/**\n * Merge oxlint configs left-to-right into a single standalone config.\n *\n * Plugins and ignorePatterns are unioned, categories/rules/env/settings are\n * shallow-merged (later configs win), and overrides are concatenated.\n */\nexport const mergeConfigs = (...configs: OxlintConfig[]): OxlintConfig => {\n const result: OxlintConfig = {};\n\n for (const config of configs) {\n if (config.plugins) result.plugins = [...new Set([...(result.plugins ?? []), ...config.plugins])];\n\n if (config.categories) result.categories = { ...result.categories, ...config.categories };\n\n if (config.rules) result.rules = { ...result.rules, ...config.rules };\n\n if (config.env) result.env = { ...result.env, ...config.env };\n\n if (config.settings) result.settings = { ...result.settings, ...config.settings };\n\n if (config.overrides) result.overrides = [...(result.overrides ?? []), ...config.overrides];\n\n if (config.ignorePatterns)\n result.ignorePatterns = [...new Set([...(result.ignorePatterns ?? []), ...config.ignorePatterns])];\n }\n\n return result;\n};\n","import { mergeConfigs } from '../lib/merge.js';\nimport type { OxlintConfig } from '../types.js';\nimport base from './base.js';\n\n/**\n * TypeScript preset, ported from `@jabworks/eslint-plugin` configs.typescript.\n *\n * Type-aware rules (consistent-type-exports, no-misused-promises,\n * no-redundant-type-constituents, no-unnecessary-qualifier,\n * prefer-regexp-exec, require-array-sort-compare,\n * restrict-template-expressions, switch-exhaustiveness-check) only run when\n * `oxlint-tsgolint` is installed and oxlint runs with `--type-aware`.\n *\n * Dropped (no oxlint equivalent as of 1.58): method-signature-style,\n * naming-convention.\n */\nexport const typescriptRules: OxlintConfig = {\n plugins: ['typescript'],\n rules: {\n 'typescript/consistent-type-exports': ['warn', { fixMixedExportsWithInlineTypeSpecifier: true }],\n 'typescript/consistent-type-imports': [\n 'warn',\n {\n disallowTypeAnnotations: true,\n fixStyle: 'inline-type-imports',\n prefer: 'type-imports',\n },\n ],\n 'typescript/no-misused-promises': ['error', { checksVoidReturn: { attributes: false } }],\n 'typescript/no-redundant-type-constituents': 'warn',\n 'typescript/no-unnecessary-qualifier': 'warn',\n 'typescript/prefer-regexp-exec': 'warn',\n 'typescript/require-array-sort-compare': ['error', { ignoreStringArrays: true }],\n 'typescript/restrict-template-expressions': ['error', { allowNumber: true }],\n 'typescript/switch-exhaustiveness-check': ['warn', { considerDefaultExhaustiveForUnions: true }],\n 'typescript/no-empty-object-type': ['error', { allowInterfaces: 'with-single-extends' }],\n // Extension rules: oxlint's eslint/* implementations handle TS sources.\n 'eslint/default-param-last': 'error',\n 'eslint/no-loop-func': 'error',\n 'eslint/no-useless-constructor': 'error',\n },\n};\n\nconst typescript: OxlintConfig = mergeConfigs(base, typescriptRules);\n\nexport default typescript;\n","import type { OxlintConfig, OxlintOverride } from '../types.js';\n\n/**\n * Vitest preset, ported from `@jabworks/eslint-plugin` configs.vitest.\n * Scoped to test files via an override, like the original flat config.\n */\nexport const vitestOverride: OxlintOverride = {\n files: ['**/*.test.{js,ts,mjs,cjs,jsx,tsx}', '**/__tests__/**', '**/tests/**'],\n plugins: ['vitest'],\n env: {\n node: true,\n vitest: true,\n },\n rules: {\n 'vitest/max-nested-describe': ['error', { max: 3 }],\n 'vitest/no-commented-out-tests': 'error',\n 'vitest/no-disabled-tests': 'error',\n 'vitest/no-focused-tests': 'error',\n 'vitest/no-identical-title': 'error',\n },\n};\n\nconst vitest: OxlintConfig = {\n categories: {\n correctness: 'error',\n },\n overrides: [vitestOverride],\n};\n\nexport default vitest;\n","import { mergeConfigs } from '../lib/merge.js';\nimport type { OxlintConfig } from '../types.js';\nimport typescript from './typescript.js';\nimport { vitestOverride } from './vitest.js';\n\n/**\n * React preset, ported from `@jabworks/eslint-plugin` configs.react.\n * Includes the react-hooks rules (folded into oxlint's react plugin) and the\n * vitest override for test files.\n *\n * Dropped (no oxlint equivalent as of 1.58): function-component-definition,\n * hook-use-state, jsx-no-leaked-render, jsx-sort-props,\n * no-unstable-nested-components.\n */\nexport const reactRules: OxlintConfig = {\n plugins: ['react', 'jsx-a11y'],\n env: {\n browser: true,\n },\n rules: {\n 'react/react-in-jsx-scope': 'off',\n 'react/button-has-type': 'warn',\n 'react/jsx-boolean-value': 'warn',\n 'react/jsx-curly-brace-presence': 'warn',\n 'react/jsx-fragments': 'warn',\n 'react/jsx-no-target-blank': ['error', { allowReferrer: true }],\n 'react/jsx-no-useless-fragment': ['warn', { allowExpressions: true }],\n 'react/jsx-pascal-case': 'warn',\n 'react/no-array-index-key': 'warn',\n 'react/self-closing-comp': 'warn',\n // react-hooks rules live under oxlint's react plugin.\n 'react/rules-of-hooks': 'error',\n 'react/exhaustive-deps': 'warn',\n 'jsx-a11y/no-autofocus': 'off',\n },\n overrides: [vitestOverride],\n};\n\nconst react: OxlintConfig = mergeConfigs(typescript, reactRules);\n\nexport default react;\n","import { mergeConfigs } from '../lib/merge.js';\nimport type { OxlintConfig } from '../types.js';\nimport react from './react.js';\n\n/**\n * Next.js preset, ported from `@jabworks/eslint-plugin` configs.next.\n * The nextjs plugin's recommended/core-web-vitals rules are enabled through\n * the `correctness` category.\n */\nconst next: OxlintConfig = mergeConfigs(react, {\n plugins: ['nextjs'],\n overrides: [\n {\n files: [\n '*.config.js',\n '*.config.mjs',\n '*.config.cjs',\n '*.config.ts',\n '**/*.d.ts',\n '**/*.stories.ts',\n '**/*.stories.tsx',\n 'app/**/*error.tsx',\n 'app/**/layout.tsx',\n 'app/**/not-found.tsx',\n 'app/**/opengraph-image.tsx',\n 'app/**/page.tsx',\n 'app/apple-icon.tsx',\n 'app/robots.ts',\n 'app/sitemap.ts',\n 'next.config.mjs',\n 'src/app/**/*error.tsx',\n 'src/app/**/layout.tsx',\n 'src/app/**/not-found.tsx',\n 'src/app/**/opengraph-image.tsx',\n 'src/app/**/page.tsx',\n 'src/app/apple-icon.tsx',\n 'src/app/robots.ts',\n 'src/app/sitemap.ts',\n ],\n rules: {\n 'import/no-default-export': 'off',\n },\n },\n ],\n ignorePatterns: ['.next/**'],\n});\n\nexport default next;\n","import base from './configs/base.js';\nimport next from './configs/next.js';\nimport react from './configs/react.js';\nimport typescript from './configs/typescript.js';\nimport vitest from './configs/vitest.js';\n\nexport { mergeConfigs } from './lib/merge.js';\nexport type { OxlintConfig, OxlintOverride, OxlintRuleEntry, OxlintSeverity } from './types.js';\n\nexport const config = {\n configs: {\n base,\n typescript,\n react,\n next,\n vitest,\n },\n};\n\nexport { base, next, react, typescript, vitest };\n"],"mappings":"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"}
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jabworks/oxlint-config",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "Opinionated oxlint presets for JS, TS, React, Next.js, and Vitest, ported from @jabworks/eslint-plugin",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"oxlint",
|
|
8
|
+
"oxlint-config",
|
|
9
|
+
"oxc",
|
|
10
|
+
"linter",
|
|
11
|
+
"typescript"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://github.com/jabworks/style-guide/tree/main/packages/oxlint-config#readme",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/jabworks/style-guide/issues"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/jabworks/style-guide.git",
|
|
20
|
+
"directory": "packages/oxlint-config"
|
|
21
|
+
},
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"author": "Vi Minh Hiếu <jabworks@hieuvi.dev> (https://hieuvi.dev)",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./dist/index.d.mts",
|
|
27
|
+
"import": "./dist/index.mjs",
|
|
28
|
+
"require": "./dist/index.cjs",
|
|
29
|
+
"default": "./dist/index.mjs"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"main": "dist/index.cjs",
|
|
33
|
+
"module": "dist/index.mjs",
|
|
34
|
+
"files": [
|
|
35
|
+
"dist"
|
|
36
|
+
],
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "tsdown"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@jabworks/typescript-config": "workspace:*",
|
|
42
|
+
"oxlint": "^1.69.0",
|
|
43
|
+
"tsdown": "^0.21.7",
|
|
44
|
+
"typescript": "^6.0.2"
|
|
45
|
+
},
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"oxlint": ">=1.69.0"
|
|
48
|
+
},
|
|
49
|
+
"publishConfig": {
|
|
50
|
+
"access": "public"
|
|
51
|
+
}
|
|
52
|
+
}
|