@wowlab/eslint-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 +71 -0
- package/dist/core/base.d.ts +4 -0
- package/dist/core/base.js +57 -0
- package/dist/core/perfectionist.d.ts +2 -0
- package/dist/core/perfectionist.js +51 -0
- package/dist/core/stylistic.d.ts +2 -0
- package/dist/core/stylistic.js +120 -0
- package/dist/create-config.d.ts +12 -0
- package/dist/create-config.js +16 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +14 -0
- package/dist/presets/globals.d.ts +6 -0
- package/dist/presets/globals.js +16 -0
- package/dist/presets/next.d.ts +3 -0
- package/dist/presets/next.js +10 -0
- package/dist/presets/react.d.ts +9 -0
- package/dist/presets/react.js +38 -0
- package/dist/presets/tanstack-query.d.ts +3 -0
- package/dist/presets/tanstack-query.js +8 -0
- package/dist/presets/typescript.d.ts +7 -0
- package/dist/presets/typescript.js +23 -0
- package/package.json +58 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ESLint Config contributors
|
|
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,71 @@
|
|
|
1
|
+
<!-- @generated by markupwright v0.1.2 -- do not edit by hand. Edit the source template and run `markupwright`. -->
|
|
2
|
+
|
|
3
|
+
# ESLint Config
|
|
4
|
+
|
|
5
|
+
Composable ESLint flat configs for JavaScript and TypeScript
|
|
6
|
+
|
|
7
|
+
## Getting started
|
|
8
|
+
|
|
9
|
+
```console
|
|
10
|
+
pnpm add --save-dev @wowlab/eslint-config eslint typescript
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
import { createConfig, presets } from "@wowlab/eslint-config";
|
|
15
|
+
|
|
16
|
+
export default createConfig({
|
|
17
|
+
presets: [
|
|
18
|
+
presets.next(),
|
|
19
|
+
presets.react({
|
|
20
|
+
typeChecked: true,
|
|
21
|
+
tsconfigRootDir: import.meta.dirname,
|
|
22
|
+
}),
|
|
23
|
+
presets.tanstackQuery(),
|
|
24
|
+
],
|
|
25
|
+
internalPatterns: ["^@/", "^@acme/"],
|
|
26
|
+
ignores: ["dist/**"],
|
|
27
|
+
rules: {
|
|
28
|
+
"unicorn/prefer-module": "off",
|
|
29
|
+
},
|
|
30
|
+
overrides: [
|
|
31
|
+
{
|
|
32
|
+
files: ["scripts/**"],
|
|
33
|
+
rules: { "no-console": "off" },
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
});
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
`createConfig` includes the base rules. Consumer rules and overrides are applied last.
|
|
40
|
+
|
|
41
|
+
## Presets
|
|
42
|
+
|
|
43
|
+
- `deno` adds Deno globals.
|
|
44
|
+
- `next` adds the Next.js Core Web Vitals rules.
|
|
45
|
+
- `node` adds Node.js globals.
|
|
46
|
+
- `react` adds React rules for JavaScript. Set `typescript: true` to add TypeScript support or `typeChecked: true` to add TypeScript and type-aware rules together.
|
|
47
|
+
- `tanstackQuery` adds TanStack Query rules.
|
|
48
|
+
- `typescript` adds TypeScript rules, optionally using the project service.
|
|
49
|
+
|
|
50
|
+
Presets return ordinary flat-config arrays and work alongside configs from other plugins.
|
|
51
|
+
|
|
52
|
+
## Development
|
|
53
|
+
|
|
54
|
+
Development requires Node.js 22.13 or newer, Deno 2, pnpm, and Markupwright.
|
|
55
|
+
|
|
56
|
+
```console
|
|
57
|
+
cargo install markupwright --locked
|
|
58
|
+
corepack enable
|
|
59
|
+
pnpm install
|
|
60
|
+
pnpm check
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Run `pnpm docs:generate` after changing a `.md.in` file or package metadata.
|
|
64
|
+
|
|
65
|
+
## Contributing
|
|
66
|
+
|
|
67
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) to get started and [SECURITY.md](SECURITY.md) for vulnerability reports.
|
|
68
|
+
|
|
69
|
+
## License
|
|
70
|
+
|
|
71
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import comments from "@eslint-community/eslint-plugin-eslint-comments/configs";
|
|
2
|
+
import js from "@eslint/js";
|
|
3
|
+
import sonarjs from "eslint-plugin-sonarjs";
|
|
4
|
+
import switchCase from "eslint-plugin-switch-case";
|
|
5
|
+
import unicorn from "eslint-plugin-unicorn";
|
|
6
|
+
import { perfectionistConfig } from "./perfectionist.js";
|
|
7
|
+
import { stylisticConfig } from "./stylistic.js";
|
|
8
|
+
const ruleOverrides = {
|
|
9
|
+
"@eslint-community/eslint-comments/disable-enable-pair": [
|
|
10
|
+
"error",
|
|
11
|
+
{ allowWholeFile: true },
|
|
12
|
+
],
|
|
13
|
+
"@eslint-community/eslint-comments/no-unlimited-disable": "off",
|
|
14
|
+
"sonarjs/pseudo-random": "off",
|
|
15
|
+
"sonarjs/todo-tag": "off",
|
|
16
|
+
"sonarjs/void-use": "off",
|
|
17
|
+
"unicorn/import-style": "off",
|
|
18
|
+
"unicorn/no-abusive-eslint-disable": "off",
|
|
19
|
+
"unicorn/no-array-reduce": "off",
|
|
20
|
+
"unicorn/no-array-sort": "off",
|
|
21
|
+
"unicorn/no-await-expression-member": "off",
|
|
22
|
+
"unicorn/no-null": "off",
|
|
23
|
+
"unicorn/no-thenable": "off",
|
|
24
|
+
"unicorn/number-literal-case": "off",
|
|
25
|
+
"unicorn/prefer-global-this": "off",
|
|
26
|
+
"unicorn/prefer-spread": "off",
|
|
27
|
+
"unicorn/prevent-abbreviations": "off",
|
|
28
|
+
};
|
|
29
|
+
export function createBaseConfig({ internalPatterns = [], } = {}) {
|
|
30
|
+
return [
|
|
31
|
+
{
|
|
32
|
+
linterOptions: { reportUnusedDisableDirectives: "error" },
|
|
33
|
+
name: "wowlab/linter-options",
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
...js.configs.recommended,
|
|
37
|
+
name: "wowlab/javascript",
|
|
38
|
+
},
|
|
39
|
+
perfectionistConfig(internalPatterns),
|
|
40
|
+
stylisticConfig,
|
|
41
|
+
{
|
|
42
|
+
name: "wowlab/switch-case",
|
|
43
|
+
plugins: { "switch-case": switchCase },
|
|
44
|
+
rules: {
|
|
45
|
+
"switch-case/newline-between-switch-case": [
|
|
46
|
+
"error",
|
|
47
|
+
"always",
|
|
48
|
+
{ fallthrough: "never" },
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
unicorn.configs["flat/recommended"],
|
|
53
|
+
sonarjs.configs.recommended,
|
|
54
|
+
comments.recommended,
|
|
55
|
+
{ name: "wowlab/rule-defaults", rules: ruleOverrides },
|
|
56
|
+
];
|
|
57
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import perfectionist from "eslint-plugin-perfectionist";
|
|
2
|
+
// prettier-ignore
|
|
3
|
+
const CLASS_GROUPS = [
|
|
4
|
+
"index-signature",
|
|
5
|
+
["static-property", "static-accessor-property"],
|
|
6
|
+
"static-block",
|
|
7
|
+
"static-get-method",
|
|
8
|
+
"static-set-method",
|
|
9
|
+
"static-method",
|
|
10
|
+
["property", "accessor-property"],
|
|
11
|
+
["protected-property", "protected-accessor-property"],
|
|
12
|
+
["private-property", "private-accessor-property"],
|
|
13
|
+
"constructor",
|
|
14
|
+
"get-method",
|
|
15
|
+
"set-method",
|
|
16
|
+
"method",
|
|
17
|
+
"protected-get-method",
|
|
18
|
+
"protected-set-method",
|
|
19
|
+
"protected-method",
|
|
20
|
+
"private-get-method",
|
|
21
|
+
"private-set-method",
|
|
22
|
+
"private-method",
|
|
23
|
+
"unknown",
|
|
24
|
+
];
|
|
25
|
+
export function perfectionistConfig(internalPatterns) {
|
|
26
|
+
const importOptions = internalPatterns.length > 0 ? { internalPattern: internalPatterns } : {};
|
|
27
|
+
return {
|
|
28
|
+
name: "wowlab/perfectionist",
|
|
29
|
+
plugins: { perfectionist },
|
|
30
|
+
rules: {
|
|
31
|
+
curly: ["error", "all"],
|
|
32
|
+
"perfectionist/sort-array-includes": "warn",
|
|
33
|
+
"perfectionist/sort-classes": ["warn", { groups: CLASS_GROUPS }],
|
|
34
|
+
"perfectionist/sort-decorators": "warn",
|
|
35
|
+
"perfectionist/sort-enums": ["warn", { partitionByComment: true }],
|
|
36
|
+
"perfectionist/sort-exports": "warn",
|
|
37
|
+
"perfectionist/sort-heritage-clauses": "warn",
|
|
38
|
+
"perfectionist/sort-imports": ["warn", importOptions],
|
|
39
|
+
"perfectionist/sort-interfaces": "warn",
|
|
40
|
+
"perfectionist/sort-intersection-types": "warn",
|
|
41
|
+
"perfectionist/sort-maps": ["warn", { partitionByComment: true }],
|
|
42
|
+
"perfectionist/sort-modules": "warn",
|
|
43
|
+
"perfectionist/sort-named-exports": "warn",
|
|
44
|
+
"perfectionist/sort-named-imports": "warn",
|
|
45
|
+
"perfectionist/sort-objects": ["warn", { partitionByComment: true }],
|
|
46
|
+
"perfectionist/sort-sets": ["warn", { partitionByComment: true }],
|
|
47
|
+
"perfectionist/sort-switch-case": "warn",
|
|
48
|
+
"perfectionist/sort-variable-declarations": "warn",
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import stylistic from "@stylistic/eslint-plugin";
|
|
2
|
+
const prettierCompatible = stylistic.configs.customize({
|
|
3
|
+
arrowParens: true,
|
|
4
|
+
blockSpacing: true,
|
|
5
|
+
braceStyle: "1tbs",
|
|
6
|
+
commaDangle: "always-multiline",
|
|
7
|
+
indent: 2,
|
|
8
|
+
jsx: true,
|
|
9
|
+
quoteProps: "as-needed",
|
|
10
|
+
quotes: "double",
|
|
11
|
+
semi: true,
|
|
12
|
+
severity: "error",
|
|
13
|
+
});
|
|
14
|
+
const structuralRules = {
|
|
15
|
+
"@stylistic/function-call-spacing": ["error", "never"],
|
|
16
|
+
"@stylistic/jsx-pascal-case": "error",
|
|
17
|
+
"@stylistic/jsx-self-closing-comp": [
|
|
18
|
+
"error",
|
|
19
|
+
{ component: true, html: true },
|
|
20
|
+
],
|
|
21
|
+
"@stylistic/jsx-wrap-multilines": [
|
|
22
|
+
"error",
|
|
23
|
+
{
|
|
24
|
+
arrow: "parens-new-line",
|
|
25
|
+
assignment: "parens-new-line",
|
|
26
|
+
condition: "parens-new-line",
|
|
27
|
+
declaration: "parens-new-line",
|
|
28
|
+
logical: "parens-new-line",
|
|
29
|
+
prop: "ignore",
|
|
30
|
+
propertyValue: "ignore",
|
|
31
|
+
return: "parens-new-line",
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
"@stylistic/linebreak-style": ["error", "unix"],
|
|
35
|
+
"@stylistic/lines-around-comment": [
|
|
36
|
+
"error",
|
|
37
|
+
{
|
|
38
|
+
allowArrayEnd: true,
|
|
39
|
+
allowArrayStart: true,
|
|
40
|
+
allowBlockEnd: true,
|
|
41
|
+
allowBlockStart: true,
|
|
42
|
+
allowClassEnd: true,
|
|
43
|
+
allowClassStart: true,
|
|
44
|
+
allowEnumEnd: true,
|
|
45
|
+
allowEnumStart: true,
|
|
46
|
+
allowInterfaceEnd: true,
|
|
47
|
+
allowInterfaceStart: true,
|
|
48
|
+
allowModuleEnd: true,
|
|
49
|
+
allowModuleStart: true,
|
|
50
|
+
allowObjectEnd: true,
|
|
51
|
+
allowObjectStart: true,
|
|
52
|
+
allowTypeEnd: true,
|
|
53
|
+
allowTypeStart: true,
|
|
54
|
+
beforeBlockComment: true,
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
"@stylistic/no-extra-semi": "error",
|
|
58
|
+
"@stylistic/nonblock-statement-body-position": ["error", "beside"],
|
|
59
|
+
// prettier-ignore
|
|
60
|
+
"@stylistic/padding-line-between-statements": [
|
|
61
|
+
"error",
|
|
62
|
+
{ blankLine: "always", next: "return", prev: "*" },
|
|
63
|
+
{ blankLine: "always", next: "*", prev: ["const", "let", "var"] },
|
|
64
|
+
{ blankLine: "any", next: ["const", "let", "var"], prev: ["const", "let", "var"] },
|
|
65
|
+
{ blankLine: "always", next: "*", prev: "directive" },
|
|
66
|
+
{ blankLine: "any", next: "directive", prev: "directive" },
|
|
67
|
+
{ blankLine: "always", next: ["if", "for", "while", "switch", "try", "function", "class"], prev: "*" },
|
|
68
|
+
{ blankLine: "always", next: "*", prev: ["if", "for", "while", "switch", "try", "function", "class"] },
|
|
69
|
+
{ blankLine: "always", next: "block-like", prev: "block-like" },
|
|
70
|
+
{ blankLine: "always", next: "export", prev: "*" },
|
|
71
|
+
{ blankLine: "any", next: "function", prev: "function" },
|
|
72
|
+
{ blankLine: "any", next: "export", prev: "export" },
|
|
73
|
+
],
|
|
74
|
+
"@stylistic/quotes": [
|
|
75
|
+
"error",
|
|
76
|
+
"double",
|
|
77
|
+
{ allowTemplateLiterals: "always", avoidEscape: true },
|
|
78
|
+
],
|
|
79
|
+
"@stylistic/semi-style": ["error", "last"],
|
|
80
|
+
"@stylistic/switch-colon-spacing": ["error", { after: true, before: false }],
|
|
81
|
+
};
|
|
82
|
+
// prettier-ignore
|
|
83
|
+
const prettierOwnedRules = [
|
|
84
|
+
"array-bracket-newline",
|
|
85
|
+
"array-element-newline",
|
|
86
|
+
"curly-newline",
|
|
87
|
+
"exp-jsx-props-style",
|
|
88
|
+
"exp-list-style",
|
|
89
|
+
"function-call-argument-newline",
|
|
90
|
+
"function-paren-newline",
|
|
91
|
+
"implicit-arrow-linebreak",
|
|
92
|
+
"indent",
|
|
93
|
+
"indent-binary-ops",
|
|
94
|
+
"jsx-child-element-spacing",
|
|
95
|
+
"jsx-curly-newline",
|
|
96
|
+
"jsx-indent",
|
|
97
|
+
"jsx-newline",
|
|
98
|
+
"jsx-one-expression-per-line",
|
|
99
|
+
"jsx-sort-props",
|
|
100
|
+
"line-comment-position",
|
|
101
|
+
"max-len",
|
|
102
|
+
"multiline-comment-style",
|
|
103
|
+
"multiline-ternary",
|
|
104
|
+
"newline-per-chained-call",
|
|
105
|
+
"no-confusing-arrow",
|
|
106
|
+
"object-curly-newline",
|
|
107
|
+
"object-property-newline",
|
|
108
|
+
"one-var-declaration-per-line",
|
|
109
|
+
"operator-linebreak",
|
|
110
|
+
"wrap-regex",
|
|
111
|
+
];
|
|
112
|
+
export const stylisticConfig = {
|
|
113
|
+
...prettierCompatible,
|
|
114
|
+
name: "wowlab/stylistic",
|
|
115
|
+
rules: {
|
|
116
|
+
...prettierCompatible.rules,
|
|
117
|
+
...structuralRules,
|
|
118
|
+
...Object.fromEntries(prettierOwnedRules.map((rule) => [`@stylistic/${rule}`, "off"])),
|
|
119
|
+
},
|
|
120
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Config, ConfigWithExtendsArray } from "@eslint/config-helpers";
|
|
2
|
+
import type { Linter } from "eslint";
|
|
3
|
+
export interface ConfigOptions {
|
|
4
|
+
ignores?: string[];
|
|
5
|
+
internalPatterns?: string[];
|
|
6
|
+
overrides?: ConfigInput[];
|
|
7
|
+
presets?: ConfigInput[];
|
|
8
|
+
rules?: Partial<Linter.RulesRecord>;
|
|
9
|
+
}
|
|
10
|
+
type ConfigInput = ConfigWithExtendsArray[number];
|
|
11
|
+
export declare function createConfig({ ignores, internalPatterns, overrides, presets, rules, }?: ConfigOptions): Config[];
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { defineConfig, globalIgnores } from "eslint/config";
|
|
2
|
+
import { createBaseConfig } from "./core/base.js";
|
|
3
|
+
export function createConfig({ ignores = [], internalPatterns = [], overrides = [], presets = [], rules = {}, } = {}) {
|
|
4
|
+
const config = [
|
|
5
|
+
...createBaseConfig({ internalPatterns }),
|
|
6
|
+
...presets,
|
|
7
|
+
];
|
|
8
|
+
if (ignores.length > 0) {
|
|
9
|
+
config.push(globalIgnores(ignores, "wowlab/global-ignores"));
|
|
10
|
+
}
|
|
11
|
+
if (Object.keys(rules).length > 0) {
|
|
12
|
+
config.push({ name: "wowlab/consumer-rules", rules });
|
|
13
|
+
}
|
|
14
|
+
config.push(...overrides);
|
|
15
|
+
return defineConfig(...config);
|
|
16
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { deno, node } from "./presets/globals.js";
|
|
2
|
+
import { next } from "./presets/next.js";
|
|
3
|
+
import { react } from "./presets/react.js";
|
|
4
|
+
import { tanstackQuery } from "./presets/tanstack-query.js";
|
|
5
|
+
import { typescript } from "./presets/typescript.js";
|
|
6
|
+
export { type ConfigOptions, createConfig } from "./create-config.js";
|
|
7
|
+
export type { FilesOptions } from "./presets/globals.js";
|
|
8
|
+
export type { ReactOptions } from "./presets/react.js";
|
|
9
|
+
export type { TypeScriptOptions } from "./presets/typescript.js";
|
|
10
|
+
export declare const presets: Readonly<{
|
|
11
|
+
deno: typeof deno;
|
|
12
|
+
next: typeof next;
|
|
13
|
+
node: typeof node;
|
|
14
|
+
react: typeof react;
|
|
15
|
+
tanstackQuery: typeof tanstackQuery;
|
|
16
|
+
typescript: typeof typescript;
|
|
17
|
+
}>;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { deno, node } from "./presets/globals.js";
|
|
2
|
+
import { next } from "./presets/next.js";
|
|
3
|
+
import { react } from "./presets/react.js";
|
|
4
|
+
import { tanstackQuery } from "./presets/tanstack-query.js";
|
|
5
|
+
import { typescript } from "./presets/typescript.js";
|
|
6
|
+
export { createConfig } from "./create-config.js";
|
|
7
|
+
export const presets = Object.freeze({
|
|
8
|
+
deno,
|
|
9
|
+
next,
|
|
10
|
+
node,
|
|
11
|
+
react,
|
|
12
|
+
tanstackQuery,
|
|
13
|
+
typescript,
|
|
14
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import environmentGlobals from "globals";
|
|
2
|
+
export function deno({ files = ["**/*.{js,jsx,ts,tsx,mjs,mts,cjs,cts}"], } = {}) {
|
|
3
|
+
return environment("denoBuiltin", files);
|
|
4
|
+
}
|
|
5
|
+
export function node({ files = ["**/*.{js,mjs,cjs,ts,mts,cts}"], } = {}) {
|
|
6
|
+
return environment("node", files);
|
|
7
|
+
}
|
|
8
|
+
function environment(name, files) {
|
|
9
|
+
return [
|
|
10
|
+
{
|
|
11
|
+
files,
|
|
12
|
+
languageOptions: { globals: { ...environmentGlobals[name] } },
|
|
13
|
+
name: `wowlab/globals/${name}`,
|
|
14
|
+
},
|
|
15
|
+
];
|
|
16
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Linter } from "eslint";
|
|
2
|
+
import type { FilesOptions } from "./globals.js";
|
|
3
|
+
export interface ReactOptions extends FilesOptions {
|
|
4
|
+
tsconfigRootDir?: string;
|
|
5
|
+
typeChecked?: boolean;
|
|
6
|
+
typescript?: boolean;
|
|
7
|
+
typescriptFiles?: string[];
|
|
8
|
+
}
|
|
9
|
+
export declare function react({ files, tsconfigRootDir, typeChecked, typescript, typescriptFiles, }?: ReactOptions): Linter.Config[];
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import eslintReact from "@eslint-react/eslint-plugin";
|
|
2
|
+
import { typescript as typescriptPreset } from "./typescript.js";
|
|
3
|
+
const JAVASCRIPT_FILES = ["**/*.{js,jsx,mjs,cjs}"];
|
|
4
|
+
const TYPESCRIPT_FILES = ["**/*.{ts,tsx,mts,cts}"];
|
|
5
|
+
export function react({ files = JAVASCRIPT_FILES, tsconfigRootDir, typeChecked = false, typescript = false, typescriptFiles = TYPESCRIPT_FILES, } = {}) {
|
|
6
|
+
const typescriptConfigName = typeChecked
|
|
7
|
+
? "recommended-type-checked"
|
|
8
|
+
: "recommended";
|
|
9
|
+
const recommendedConfig = eslintReact.configs.recommended;
|
|
10
|
+
const typescriptConfig = eslintReact.configs[typescriptConfigName];
|
|
11
|
+
const javascriptConfig = {
|
|
12
|
+
...recommendedConfig,
|
|
13
|
+
files,
|
|
14
|
+
languageOptions: {
|
|
15
|
+
...recommendedConfig.languageOptions,
|
|
16
|
+
parserOptions: {
|
|
17
|
+
ecmaFeatures: { jsx: true },
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
name: "wowlab/react/recommended",
|
|
21
|
+
};
|
|
22
|
+
if (!typescript && !typeChecked) {
|
|
23
|
+
return [javascriptConfig];
|
|
24
|
+
}
|
|
25
|
+
return [
|
|
26
|
+
javascriptConfig,
|
|
27
|
+
...typescriptPreset({
|
|
28
|
+
files: typescriptFiles,
|
|
29
|
+
tsconfigRootDir,
|
|
30
|
+
typeChecked,
|
|
31
|
+
}),
|
|
32
|
+
{
|
|
33
|
+
...typescriptConfig,
|
|
34
|
+
files: typescriptFiles,
|
|
35
|
+
name: `wowlab/react/typescript/${typescriptConfigName}`,
|
|
36
|
+
},
|
|
37
|
+
];
|
|
38
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import query from "@tanstack/eslint-plugin-query";
|
|
2
|
+
export function tanstackQuery({ files = ["**/*.{js,jsx,ts,tsx,mjs,mts,cjs,cts}"], } = {}) {
|
|
3
|
+
return query.configs["flat/recommended"].map((config) => ({
|
|
4
|
+
...config,
|
|
5
|
+
files,
|
|
6
|
+
name: config.name?.replace("tanstack/query/", "wowlab/tanstack-query/"),
|
|
7
|
+
}));
|
|
8
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Linter } from "eslint";
|
|
2
|
+
import type { FilesOptions } from "./globals.js";
|
|
3
|
+
export interface TypeScriptOptions extends FilesOptions {
|
|
4
|
+
tsconfigRootDir?: string;
|
|
5
|
+
typeChecked?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function typescript({ files, tsconfigRootDir, typeChecked, }?: TypeScriptOptions): Linter.Config[];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import tseslint from "typescript-eslint";
|
|
2
|
+
export function typescript({ files = ["**/*.{ts,tsx,mts,cts}"], tsconfigRootDir, typeChecked = false, } = {}) {
|
|
3
|
+
const upstreamConfig = (typeChecked
|
|
4
|
+
? tseslint.configs.recommendedTypeChecked
|
|
5
|
+
: tseslint.configs.recommended);
|
|
6
|
+
return upstreamConfig.map((config) => {
|
|
7
|
+
const languageOptions = config.languageOptions
|
|
8
|
+
? {
|
|
9
|
+
...config.languageOptions,
|
|
10
|
+
parserOptions: {
|
|
11
|
+
...(typeChecked ? { projectService: true } : {}),
|
|
12
|
+
...(tsconfigRootDir ? { tsconfigRootDir } : {}),
|
|
13
|
+
},
|
|
14
|
+
}
|
|
15
|
+
: undefined;
|
|
16
|
+
return {
|
|
17
|
+
...config,
|
|
18
|
+
files,
|
|
19
|
+
...(languageOptions ? { languageOptions } : {}),
|
|
20
|
+
name: config.name?.replace("typescript-eslint/", "wowlab/typescript/"),
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@wowlab/eslint-config",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Composable ESLint flat configs for JavaScript and TypeScript",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist",
|
|
15
|
+
"LICENSE",
|
|
16
|
+
"README.md"
|
|
17
|
+
],
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/wowlabdev/eslint-config.git"
|
|
21
|
+
},
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/wowlabdev/eslint-config/issues"
|
|
24
|
+
},
|
|
25
|
+
"homepage": "https://github.com/wowlabdev/eslint-config#readme",
|
|
26
|
+
"keywords": [
|
|
27
|
+
"eslint",
|
|
28
|
+
"eslint-config",
|
|
29
|
+
"flat-config",
|
|
30
|
+
"javascript",
|
|
31
|
+
"typescript"
|
|
32
|
+
],
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": "^22.13.0 || >=24.0.0"
|
|
35
|
+
},
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"eslint": "^10.0.0",
|
|
41
|
+
"typescript": ">=4.8.4 <6.1.0"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@eslint-community/eslint-plugin-eslint-comments": "^4.7.2",
|
|
45
|
+
"@eslint-react/eslint-plugin": "^5.8.6",
|
|
46
|
+
"@eslint/config-helpers": "^0.7.0",
|
|
47
|
+
"@eslint/js": "^10.0.1",
|
|
48
|
+
"@next/eslint-plugin-next": "16.2.9",
|
|
49
|
+
"@stylistic/eslint-plugin": "^5.10.0",
|
|
50
|
+
"@tanstack/eslint-plugin-query": "^5.100.14",
|
|
51
|
+
"eslint-plugin-perfectionist": "^5.9.0",
|
|
52
|
+
"eslint-plugin-sonarjs": "^4.0.3",
|
|
53
|
+
"eslint-plugin-switch-case": "^4.0.0",
|
|
54
|
+
"eslint-plugin-unicorn": "^64.0.0",
|
|
55
|
+
"globals": "^17.6.0",
|
|
56
|
+
"typescript-eslint": "8.68.0"
|
|
57
|
+
}
|
|
58
|
+
}
|