@antelopejs/tooling-configs 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +225 -0
- package/dist/eslint.d.mts +34 -0
- package/dist/eslint.mjs +46 -0
- package/dist/knip.d.mts +25 -0
- package/dist/knip.mjs +30 -0
- package/dist/oxc/anti-slop/index.d.mts +5 -0
- package/dist/oxc/anti-slop/index.mjs +1524 -0
- package/dist/oxc/fmt.d.mts +108 -0
- package/dist/oxc/fmt.mjs +52 -0
- package/dist/oxc/lint.d.mts +175 -0
- package/dist/oxc/lint.mjs +179 -0
- package/dist/shared-DYvliWWW.mjs +28 -0
- package/package.json +86 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { defineConfig } from "oxfmt";
|
|
2
|
+
//#region src/oxc/fmt.d.ts
|
|
3
|
+
type OxfmtOptions = Parameters<typeof defineConfig>[0];
|
|
4
|
+
/**
|
|
5
|
+
* The house style. Every field is set explicitly, including the ones that match
|
|
6
|
+
* oxfmt's own defaults: repositories carry `.editorconfig` files that disagree
|
|
7
|
+
* with each other (five declare tabs, two declare spaces), and oxfmt falls back
|
|
8
|
+
* to `.editorconfig` for any field a config leaves unset. Stating all of them
|
|
9
|
+
* is what makes the style the same everywhere.
|
|
10
|
+
*/
|
|
11
|
+
declare const ANTELOPE_STYLE: {
|
|
12
|
+
readonly printWidth: 80;
|
|
13
|
+
readonly tabWidth: 2;
|
|
14
|
+
readonly useTabs: false;
|
|
15
|
+
readonly semi: true;
|
|
16
|
+
readonly singleQuote: false;
|
|
17
|
+
readonly trailingComma: "all";
|
|
18
|
+
};
|
|
19
|
+
interface AntelopeFmtOptions extends Partial<OxfmtOptions> {
|
|
20
|
+
/**
|
|
21
|
+
* Sort Tailwind classes, replacing `prettier-plugin-tailwindcss`. Pass the
|
|
22
|
+
* path to the stylesheet that declares the theme, as the Nuxt layers do.
|
|
23
|
+
*/
|
|
24
|
+
tailwindStylesheet?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Extra paths to leave alone. These are **added** to the shared ignores, not
|
|
27
|
+
* substituted for them: a repository adopting oxfmt in stages needs to park
|
|
28
|
+
* `nuxt-layer/**` for a while without also un-ignoring its own build output.
|
|
29
|
+
*/
|
|
30
|
+
ignorePatterns?: string[];
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The shared AntelopeJS oxfmt preset.
|
|
34
|
+
*
|
|
35
|
+
* Import order is deliberately absent: `perfectionist/sort-imports` owns it on
|
|
36
|
+
* the lint side, and two tools sorting the same imports differently would each
|
|
37
|
+
* undo the other's work on every save.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* // oxfmt.config.ts
|
|
42
|
+
* import { antelopeFmtPreset } from "@antelopejs/tooling-configs/oxc/fmt";
|
|
43
|
+
*
|
|
44
|
+
* export default antelopeFmtPreset();
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
declare function antelopeFmtPreset(options?: AntelopeFmtOptions): {
|
|
48
|
+
ignorePatterns: string[];
|
|
49
|
+
arrowParens?: import("oxfmt").ArrowParensConfig | undefined;
|
|
50
|
+
bracketSameLine?: boolean | undefined;
|
|
51
|
+
bracketSpacing?: boolean | undefined;
|
|
52
|
+
embeddedLanguageFormatting?: import("oxfmt").EmbeddedLanguageFormattingConfig | undefined;
|
|
53
|
+
endOfLine?: import("oxfmt").EndOfLineConfig | undefined;
|
|
54
|
+
experimentalOperatorPosition?: import("oxfmt").OperatorPositionConfig | undefined;
|
|
55
|
+
htmlWhitespaceSensitivity?: import("oxfmt").HtmlWhitespaceSensitivityConfig | undefined;
|
|
56
|
+
insertFinalNewline?: boolean | undefined;
|
|
57
|
+
jsdoc?: import("oxfmt").JsdocUserConfig | undefined;
|
|
58
|
+
jsxSingleQuote?: boolean | undefined;
|
|
59
|
+
objectWrap?: import("oxfmt").ObjectWrapConfig | undefined;
|
|
60
|
+
overrides?: import("oxfmt").OxfmtOverrideConfig[] | undefined;
|
|
61
|
+
printWidth: number;
|
|
62
|
+
proseWrap?: import("oxfmt").ProseWrapConfig | undefined;
|
|
63
|
+
quoteProps?: import("oxfmt").QuotePropsConfig | undefined;
|
|
64
|
+
semi: boolean;
|
|
65
|
+
singleAttributePerLine?: boolean | undefined;
|
|
66
|
+
singleQuote: boolean;
|
|
67
|
+
sortImports?: import("oxfmt").SortImportsUserConfig | undefined;
|
|
68
|
+
sortPackageJson?: import("oxfmt").SortPackageJsonUserConfig | undefined;
|
|
69
|
+
sortTailwindcss?: import("oxfmt").SortTailwindcssUserConfig;
|
|
70
|
+
svelte?: import("oxfmt").SvelteUserConfig | undefined;
|
|
71
|
+
tabWidth: number;
|
|
72
|
+
trailingComma: import("oxfmt").TrailingCommaConfig;
|
|
73
|
+
useTabs: boolean;
|
|
74
|
+
vueIndentScriptAndStyle?: boolean | undefined;
|
|
75
|
+
} | {
|
|
76
|
+
ignorePatterns: string[];
|
|
77
|
+
arrowParens?: import("oxfmt").ArrowParensConfig | undefined;
|
|
78
|
+
bracketSameLine?: boolean | undefined;
|
|
79
|
+
bracketSpacing?: boolean | undefined;
|
|
80
|
+
embeddedLanguageFormatting?: import("oxfmt").EmbeddedLanguageFormattingConfig | undefined;
|
|
81
|
+
endOfLine?: import("oxfmt").EndOfLineConfig | undefined;
|
|
82
|
+
experimentalOperatorPosition?: import("oxfmt").OperatorPositionConfig | undefined;
|
|
83
|
+
htmlWhitespaceSensitivity?: import("oxfmt").HtmlWhitespaceSensitivityConfig | undefined;
|
|
84
|
+
insertFinalNewline?: boolean | undefined;
|
|
85
|
+
jsdoc?: import("oxfmt").JsdocUserConfig | undefined;
|
|
86
|
+
jsxSingleQuote?: boolean | undefined;
|
|
87
|
+
objectWrap?: import("oxfmt").ObjectWrapConfig | undefined;
|
|
88
|
+
overrides?: import("oxfmt").OxfmtOverrideConfig[] | undefined;
|
|
89
|
+
printWidth: number;
|
|
90
|
+
proseWrap?: import("oxfmt").ProseWrapConfig | undefined;
|
|
91
|
+
quoteProps?: import("oxfmt").QuotePropsConfig | undefined;
|
|
92
|
+
semi: boolean;
|
|
93
|
+
singleAttributePerLine?: boolean | undefined;
|
|
94
|
+
singleQuote: boolean;
|
|
95
|
+
sortImports?: import("oxfmt").SortImportsUserConfig | undefined;
|
|
96
|
+
sortPackageJson?: import("oxfmt").SortPackageJsonUserConfig | undefined;
|
|
97
|
+
sortTailwindcss: {
|
|
98
|
+
stylesheet: string;
|
|
99
|
+
functions: string[];
|
|
100
|
+
} | import("oxfmt").SortTailwindcssUserConfig;
|
|
101
|
+
svelte?: import("oxfmt").SvelteUserConfig | undefined;
|
|
102
|
+
tabWidth: number;
|
|
103
|
+
trailingComma: import("oxfmt").TrailingCommaConfig;
|
|
104
|
+
useTabs: boolean;
|
|
105
|
+
vueIndentScriptAndStyle?: boolean | undefined;
|
|
106
|
+
};
|
|
107
|
+
//#endregion
|
|
108
|
+
export { ANTELOPE_STYLE, AntelopeFmtOptions, antelopeFmtPreset };
|
package/dist/oxc/fmt.mjs
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { n as IGNORE_PATTERNS, t as AGENT_IGNORE_PATTERNS } from "../shared-DYvliWWW.mjs";
|
|
2
|
+
import { defineConfig } from "oxfmt";
|
|
3
|
+
//#region src/oxc/fmt.ts
|
|
4
|
+
/**
|
|
5
|
+
* The house style. Every field is set explicitly, including the ones that match
|
|
6
|
+
* oxfmt's own defaults: repositories carry `.editorconfig` files that disagree
|
|
7
|
+
* with each other (five declare tabs, two declare spaces), and oxfmt falls back
|
|
8
|
+
* to `.editorconfig` for any field a config leaves unset. Stating all of them
|
|
9
|
+
* is what makes the style the same everywhere.
|
|
10
|
+
*/
|
|
11
|
+
const ANTELOPE_STYLE = {
|
|
12
|
+
printWidth: 80,
|
|
13
|
+
tabWidth: 2,
|
|
14
|
+
useTabs: false,
|
|
15
|
+
semi: true,
|
|
16
|
+
singleQuote: false,
|
|
17
|
+
trailingComma: "all"
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* The shared AntelopeJS oxfmt preset.
|
|
21
|
+
*
|
|
22
|
+
* Import order is deliberately absent: `perfectionist/sort-imports` owns it on
|
|
23
|
+
* the lint side, and two tools sorting the same imports differently would each
|
|
24
|
+
* undo the other's work on every save.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* // oxfmt.config.ts
|
|
29
|
+
* import { antelopeFmtPreset } from "@antelopejs/tooling-configs/oxc/fmt";
|
|
30
|
+
*
|
|
31
|
+
* export default antelopeFmtPreset();
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
function antelopeFmtPreset(options = {}) {
|
|
35
|
+
const { tailwindStylesheet, ignorePatterns = [], ...overrides } = options;
|
|
36
|
+
const tailwind = tailwindStylesheet === void 0 ? {} : { sortTailwindcss: {
|
|
37
|
+
stylesheet: tailwindStylesheet,
|
|
38
|
+
functions: ["clsx", "cn"]
|
|
39
|
+
} };
|
|
40
|
+
return defineConfig({
|
|
41
|
+
...ANTELOPE_STYLE,
|
|
42
|
+
...tailwind,
|
|
43
|
+
...overrides,
|
|
44
|
+
ignorePatterns: [
|
|
45
|
+
...IGNORE_PATTERNS,
|
|
46
|
+
...AGENT_IGNORE_PATTERNS,
|
|
47
|
+
...ignorePatterns
|
|
48
|
+
]
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
export { ANTELOPE_STYLE, antelopeFmtPreset };
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
//#region src/oxc/lint.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* The paths the preset ignores. oxlint does not merge `ignorePatterns` across
|
|
4
|
+
* `extends`: a root config that declares its own **replaces** these, so spread
|
|
5
|
+
* them when a repository adds patterns of its own.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* export default defineConfig({
|
|
10
|
+
* extends: [antelopePreset()],
|
|
11
|
+
* ignorePatterns: [...ANTELOPE_IGNORE_PATTERNS, "playground/**"],
|
|
12
|
+
* });
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
declare const ANTELOPE_IGNORE_PATTERNS: string[];
|
|
16
|
+
type Severity = "off" | "warn" | "error";
|
|
17
|
+
/**
|
|
18
|
+
* Thresholds for the complexity rules. The defaults are deliberately looser than
|
|
19
|
+
* oxlint's own (3 parameters, 50 lines per function): AntelopeJS handlers take a
|
|
20
|
+
* request context plus its dependencies, and interface files declare long types.
|
|
21
|
+
* They are meant to catch the outliers, not to redesign every signature.
|
|
22
|
+
*/
|
|
23
|
+
interface ComplexityThresholds {
|
|
24
|
+
/** `eslint/max-params` (oxlint default: 3). */
|
|
25
|
+
maxParams: number;
|
|
26
|
+
/** `eslint/max-lines-per-function` (oxlint default: 50). */
|
|
27
|
+
maxLinesPerFunction: number;
|
|
28
|
+
/** `eslint/max-lines` (oxlint default: 300). */
|
|
29
|
+
maxLines: number;
|
|
30
|
+
/** `eslint/max-depth` (oxlint default: 4). */
|
|
31
|
+
maxDepth: number;
|
|
32
|
+
/** `eslint/complexity`, cyclomatic (oxlint default: 20). */
|
|
33
|
+
complexity: number;
|
|
34
|
+
}
|
|
35
|
+
declare const DEFAULT_COMPLEXITY_THRESHOLDS: ComplexityThresholds;
|
|
36
|
+
interface AntelopePresetOptions {
|
|
37
|
+
/**
|
|
38
|
+
* Vendored anti-slop rules, which reject low-evidence TypeScript (`unknown`
|
|
39
|
+
* parameters, unjustified `as` assertions, open dictionaries...).
|
|
40
|
+
* `true` maps to `"warn"`: a repository adopting them has findings to work
|
|
41
|
+
* through before the gate can be raised to `"error"`.
|
|
42
|
+
*
|
|
43
|
+
* @default "warn"
|
|
44
|
+
*/
|
|
45
|
+
antiSlop?: boolean | Severity;
|
|
46
|
+
/**
|
|
47
|
+
* Complexity ceilings. Pass an object to override individual thresholds.
|
|
48
|
+
*
|
|
49
|
+
* @default "warn" with {@link DEFAULT_COMPLEXITY_THRESHOLDS}
|
|
50
|
+
*/
|
|
51
|
+
complexity?: boolean | (Partial<ComplexityThresholds> & {
|
|
52
|
+
severity?: Severity;
|
|
53
|
+
});
|
|
54
|
+
/**
|
|
55
|
+
* Import sorting through `eslint-plugin-perfectionist`, autofixed by
|
|
56
|
+
* `oxlint --fix`. Repositories that still let Biome organize imports must
|
|
57
|
+
* leave this off until they drop that assist, or the two tools fight.
|
|
58
|
+
*
|
|
59
|
+
* The plugin is an optional peer dependency: it pulls ESLint and
|
|
60
|
+
* typescript-eslint in with it, which a repository that turns this off has no
|
|
61
|
+
* reason to install. Add `eslint-plugin-perfectionist` alongside this package
|
|
62
|
+
* when leaving it on.
|
|
63
|
+
*
|
|
64
|
+
* @default true
|
|
65
|
+
*/
|
|
66
|
+
importSorting?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Severity of `import/no-cycle`. A cycle only shows up at runtime, in a
|
|
69
|
+
* consumer's process, so it ships as an error — but a repository that already
|
|
70
|
+
* has cycles needs to see them without a red pipeline while it untangles them.
|
|
71
|
+
*
|
|
72
|
+
* @default "error"
|
|
73
|
+
*/
|
|
74
|
+
importCycles?: boolean | Severity;
|
|
75
|
+
/**
|
|
76
|
+
* `typescript/no-floating-promises`, which needs type information. The
|
|
77
|
+
* consuming repository must also set `options.typeAware` in its own root
|
|
78
|
+
* config: oxlint only reads that field there, never from an extended preset.
|
|
79
|
+
*
|
|
80
|
+
* @default true
|
|
81
|
+
*/
|
|
82
|
+
typeAware?: boolean;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* The shared AntelopeJS oxlint preset: oxc's own defaults (the `correctness`
|
|
86
|
+
* category), plus import hygiene, complexity ceilings, import sorting, and the
|
|
87
|
+
* vendored anti-slop rules.
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```ts
|
|
91
|
+
* // oxlint.config.ts
|
|
92
|
+
* import { defineConfig } from "oxlint";
|
|
93
|
+
* import { antelopePreset } from "@antelopejs/tooling-configs/oxc/lint";
|
|
94
|
+
*
|
|
95
|
+
* export default defineConfig({
|
|
96
|
+
* extends: [antelopePreset()],
|
|
97
|
+
* options: { typeAware: true },
|
|
98
|
+
* });
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
declare function antelopePreset(options?: AntelopePresetOptions): {
|
|
102
|
+
extends: ({
|
|
103
|
+
categories: {
|
|
104
|
+
correctness: "error";
|
|
105
|
+
};
|
|
106
|
+
ignorePatterns: string[];
|
|
107
|
+
plugins: ("eslint" | "typescript" | "oxc" | "import" | "promise" | "node")[];
|
|
108
|
+
rules: {
|
|
109
|
+
"eslint/no-unused-vars": ["error", {
|
|
110
|
+
argsIgnorePattern: "^_";
|
|
111
|
+
varsIgnorePattern: "^_";
|
|
112
|
+
caughtErrorsIgnorePattern: "^_";
|
|
113
|
+
}];
|
|
114
|
+
"import/no-cycle": Severity;
|
|
115
|
+
"import/no-self-import": "error";
|
|
116
|
+
"import/no-duplicates": "error";
|
|
117
|
+
};
|
|
118
|
+
} | {
|
|
119
|
+
rules: {
|
|
120
|
+
"typescript/no-floating-promises": "error";
|
|
121
|
+
"typescript/await-thenable": "warn";
|
|
122
|
+
"typescript/unbound-method": "warn";
|
|
123
|
+
"typescript/no-meaningless-void-operator": "warn";
|
|
124
|
+
"typescript/no-misused-spread": "warn";
|
|
125
|
+
"typescript/no-redundant-type-constituents": "warn";
|
|
126
|
+
"typescript/restrict-template-expressions": "warn";
|
|
127
|
+
"typescript/require-array-sort-compare": "warn";
|
|
128
|
+
};
|
|
129
|
+
} | {
|
|
130
|
+
jsPlugins: {
|
|
131
|
+
name: string;
|
|
132
|
+
specifier: string;
|
|
133
|
+
}[];
|
|
134
|
+
rules: {
|
|
135
|
+
[k: string]: Severity;
|
|
136
|
+
};
|
|
137
|
+
} | {
|
|
138
|
+
rules: {
|
|
139
|
+
"eslint/max-params": [Severity, {
|
|
140
|
+
max: number;
|
|
141
|
+
}];
|
|
142
|
+
"eslint/max-lines-per-function": [Severity, {
|
|
143
|
+
max: number;
|
|
144
|
+
skipBlankLines: true;
|
|
145
|
+
skipComments: true;
|
|
146
|
+
}];
|
|
147
|
+
"eslint/max-lines": [Severity, {
|
|
148
|
+
max: number;
|
|
149
|
+
skipBlankLines: true;
|
|
150
|
+
skipComments: true;
|
|
151
|
+
}];
|
|
152
|
+
"eslint/max-depth": [Severity, {
|
|
153
|
+
max: number;
|
|
154
|
+
}];
|
|
155
|
+
"eslint/complexity": [Severity, {
|
|
156
|
+
max: number;
|
|
157
|
+
}];
|
|
158
|
+
};
|
|
159
|
+
} | {
|
|
160
|
+
jsPlugins: string[];
|
|
161
|
+
rules: {
|
|
162
|
+
"perfectionist/sort-imports": ["error", {
|
|
163
|
+
type: "line-length";
|
|
164
|
+
order: "asc";
|
|
165
|
+
internalPattern: string[];
|
|
166
|
+
groups: string[][];
|
|
167
|
+
}];
|
|
168
|
+
};
|
|
169
|
+
})[];
|
|
170
|
+
rules: {
|
|
171
|
+
"typescript/no-floating-promises": "off" | "error";
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
//#endregion
|
|
175
|
+
export { ANTELOPE_IGNORE_PATTERNS, AntelopePresetOptions, ComplexityThresholds, DEFAULT_COMPLEXITY_THRESHOLDS, antelopePreset };
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { n as IGNORE_PATTERNS, t as AGENT_IGNORE_PATTERNS } from "../shared-DYvliWWW.mjs";
|
|
2
|
+
import { defineConfig } from "oxlint";
|
|
3
|
+
//#region src/oxc/lint.ts
|
|
4
|
+
/**
|
|
5
|
+
* The paths the preset ignores. oxlint does not merge `ignorePatterns` across
|
|
6
|
+
* `extends`: a root config that declares its own **replaces** these, so spread
|
|
7
|
+
* them when a repository adds patterns of its own.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* export default defineConfig({
|
|
12
|
+
* extends: [antelopePreset()],
|
|
13
|
+
* ignorePatterns: [...ANTELOPE_IGNORE_PATTERNS, "playground/**"],
|
|
14
|
+
* });
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
const ANTELOPE_IGNORE_PATTERNS = [...IGNORE_PATTERNS, ...AGENT_IGNORE_PATTERNS];
|
|
18
|
+
const DEFAULT_COMPLEXITY_THRESHOLDS = {
|
|
19
|
+
maxParams: 5,
|
|
20
|
+
maxLinesPerFunction: 120,
|
|
21
|
+
maxLines: 500,
|
|
22
|
+
maxDepth: 4,
|
|
23
|
+
complexity: 20
|
|
24
|
+
};
|
|
25
|
+
const ANTI_SLOP_RULES = [
|
|
26
|
+
"no-chained-type-assertions",
|
|
27
|
+
"no-conditional-empty-object-spread",
|
|
28
|
+
"no-known-value-widening",
|
|
29
|
+
"no-module-mocking",
|
|
30
|
+
"no-object-parameters",
|
|
31
|
+
"no-reflect-apply",
|
|
32
|
+
"no-reflect-get",
|
|
33
|
+
"no-runtime-typeof",
|
|
34
|
+
"no-shape-in-symbol-names",
|
|
35
|
+
"no-unknown-parameters",
|
|
36
|
+
"no-unknown-returns",
|
|
37
|
+
"no-unknown-type-aliases",
|
|
38
|
+
"no-unsafe-dictionary-type",
|
|
39
|
+
"no-widen-then-assert",
|
|
40
|
+
"require-safety-comment-for-type-assertion"
|
|
41
|
+
];
|
|
42
|
+
/** Shared empty override set, so the threshold spread is never conditional. */
|
|
43
|
+
const EMPTY_THRESHOLDS = {};
|
|
44
|
+
function severityOf(option, fallback) {
|
|
45
|
+
if (option === void 0 || option === true) return fallback;
|
|
46
|
+
if (option === false) return "off";
|
|
47
|
+
return option;
|
|
48
|
+
}
|
|
49
|
+
function basePreset(cycleSeverity) {
|
|
50
|
+
return defineConfig({
|
|
51
|
+
categories: { correctness: "error" },
|
|
52
|
+
ignorePatterns: ANTELOPE_IGNORE_PATTERNS,
|
|
53
|
+
plugins: [
|
|
54
|
+
"eslint",
|
|
55
|
+
"typescript",
|
|
56
|
+
"node",
|
|
57
|
+
"oxc",
|
|
58
|
+
"import",
|
|
59
|
+
"promise"
|
|
60
|
+
],
|
|
61
|
+
rules: {
|
|
62
|
+
"eslint/no-unused-vars": ["error", {
|
|
63
|
+
argsIgnorePattern: "^_",
|
|
64
|
+
varsIgnorePattern: "^_",
|
|
65
|
+
caughtErrorsIgnorePattern: "^_"
|
|
66
|
+
}],
|
|
67
|
+
"import/no-cycle": cycleSeverity,
|
|
68
|
+
"import/no-self-import": "error",
|
|
69
|
+
"import/no-duplicates": "error"
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function antiSlopPreset(severity) {
|
|
74
|
+
return defineConfig({
|
|
75
|
+
jsPlugins: [{
|
|
76
|
+
name: "anti-slop",
|
|
77
|
+
specifier: "@antelopejs/tooling-configs/oxc/anti-slop"
|
|
78
|
+
}],
|
|
79
|
+
rules: Object.fromEntries(ANTI_SLOP_RULES.map((rule) => [`anti-slop/${rule}`, severity]))
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
function complexityPreset(thresholds, severity) {
|
|
83
|
+
return defineConfig({ rules: {
|
|
84
|
+
"eslint/max-params": [severity, { max: thresholds.maxParams }],
|
|
85
|
+
"eslint/max-lines-per-function": [severity, {
|
|
86
|
+
max: thresholds.maxLinesPerFunction,
|
|
87
|
+
skipBlankLines: true,
|
|
88
|
+
skipComments: true
|
|
89
|
+
}],
|
|
90
|
+
"eslint/max-lines": [severity, {
|
|
91
|
+
max: thresholds.maxLines,
|
|
92
|
+
skipBlankLines: true,
|
|
93
|
+
skipComments: true
|
|
94
|
+
}],
|
|
95
|
+
"eslint/max-depth": [severity, { max: thresholds.maxDepth }],
|
|
96
|
+
"eslint/complexity": [severity, { max: thresholds.complexity }]
|
|
97
|
+
} });
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Turning on type information enables a whole family of rules, not just the one
|
|
101
|
+
* worth the setup. `no-floating-promises` catches a promise whose rejection is
|
|
102
|
+
* lost, which is why type-aware linting is worth running at all; the rest report
|
|
103
|
+
* until a repository has worked through them, like every other backlog here.
|
|
104
|
+
*/
|
|
105
|
+
function typeAwarePreset() {
|
|
106
|
+
return defineConfig({ rules: {
|
|
107
|
+
"typescript/no-floating-promises": "error",
|
|
108
|
+
"typescript/await-thenable": "warn",
|
|
109
|
+
"typescript/unbound-method": "warn",
|
|
110
|
+
"typescript/no-meaningless-void-operator": "warn",
|
|
111
|
+
"typescript/no-misused-spread": "warn",
|
|
112
|
+
"typescript/no-redundant-type-constituents": "warn",
|
|
113
|
+
"typescript/restrict-template-expressions": "warn",
|
|
114
|
+
"typescript/require-array-sort-compare": "warn"
|
|
115
|
+
} });
|
|
116
|
+
}
|
|
117
|
+
function importSortingPreset() {
|
|
118
|
+
return defineConfig({
|
|
119
|
+
jsPlugins: ["eslint-plugin-perfectionist"],
|
|
120
|
+
rules: { "perfectionist/sort-imports": ["error", {
|
|
121
|
+
type: "line-length",
|
|
122
|
+
order: "asc",
|
|
123
|
+
internalPattern: ["^@/.*", "^~/.*"],
|
|
124
|
+
groups: [
|
|
125
|
+
["side-effect", "side-effect-style"],
|
|
126
|
+
["builtin", "external"],
|
|
127
|
+
[
|
|
128
|
+
"internal",
|
|
129
|
+
"subpath",
|
|
130
|
+
"parent",
|
|
131
|
+
"sibling",
|
|
132
|
+
"index",
|
|
133
|
+
"style",
|
|
134
|
+
"unknown"
|
|
135
|
+
]
|
|
136
|
+
]
|
|
137
|
+
}] }
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* The shared AntelopeJS oxlint preset: oxc's own defaults (the `correctness`
|
|
142
|
+
* category), plus import hygiene, complexity ceilings, import sorting, and the
|
|
143
|
+
* vendored anti-slop rules.
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* ```ts
|
|
147
|
+
* // oxlint.config.ts
|
|
148
|
+
* import { defineConfig } from "oxlint";
|
|
149
|
+
* import { antelopePreset } from "@antelopejs/tooling-configs/oxc/lint";
|
|
150
|
+
*
|
|
151
|
+
* export default defineConfig({
|
|
152
|
+
* extends: [antelopePreset()],
|
|
153
|
+
* options: { typeAware: true },
|
|
154
|
+
* });
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
function antelopePreset(options = {}) {
|
|
158
|
+
const complexity = options.complexity ?? true;
|
|
159
|
+
const isToggle = complexity === true || complexity === false;
|
|
160
|
+
const overrides = isToggle ? EMPTY_THRESHOLDS : complexity;
|
|
161
|
+
const complexityThresholds = {
|
|
162
|
+
...DEFAULT_COMPLEXITY_THRESHOLDS,
|
|
163
|
+
...overrides
|
|
164
|
+
};
|
|
165
|
+
const complexitySeverity = severityOf(isToggle ? complexity : overrides.severity ?? true, "warn");
|
|
166
|
+
const antiSlopSeverity = severityOf(options.antiSlop, "warn");
|
|
167
|
+
return defineConfig({
|
|
168
|
+
extends: [
|
|
169
|
+
basePreset(severityOf(options.importCycles, "error")),
|
|
170
|
+
options.typeAware === false ? null : typeAwarePreset(),
|
|
171
|
+
antiSlopSeverity === "off" ? null : antiSlopPreset(antiSlopSeverity),
|
|
172
|
+
complexitySeverity === "off" ? null : complexityPreset(complexityThresholds, complexitySeverity),
|
|
173
|
+
options.importSorting === false ? null : importSortingPreset()
|
|
174
|
+
].filter((config) => config !== null),
|
|
175
|
+
rules: { "typescript/no-floating-promises": options.typeAware === false ? "off" : "error" }
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
//#endregion
|
|
179
|
+
export { ANTELOPE_IGNORE_PATTERNS, DEFAULT_COMPLEXITY_THRESHOLDS, antelopePreset };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region src/oxc/shared.ts
|
|
2
|
+
/** Paths every AntelopeJS project generates or vendors, and that no linter should read. */
|
|
3
|
+
const IGNORE_PATTERNS = [
|
|
4
|
+
"**/node_modules/**",
|
|
5
|
+
"**/dist/**",
|
|
6
|
+
"**/build/**",
|
|
7
|
+
"**/coverage/**",
|
|
8
|
+
"**/.antelope/**",
|
|
9
|
+
"**/.nuxt/**",
|
|
10
|
+
"**/.output/**",
|
|
11
|
+
"**/output/**",
|
|
12
|
+
"**/generated-layers.json",
|
|
13
|
+
"**/i18n-registry.generated.ts"
|
|
14
|
+
];
|
|
15
|
+
/** Agent tooling directories: assets we install, not source we own. */
|
|
16
|
+
const AGENT_IGNORE_PATTERNS = [
|
|
17
|
+
".agent/**",
|
|
18
|
+
".agents/**",
|
|
19
|
+
".amp/**",
|
|
20
|
+
".claude/**",
|
|
21
|
+
".codex/**",
|
|
22
|
+
".cursor/**",
|
|
23
|
+
".gemini/**",
|
|
24
|
+
".opencode/**",
|
|
25
|
+
".windsurf/**"
|
|
26
|
+
];
|
|
27
|
+
//#endregion
|
|
28
|
+
export { IGNORE_PATTERNS as n, AGENT_IGNORE_PATTERNS as t };
|
package/package.json
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@antelopejs/tooling-configs",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Shared tooling presets for AntelopeJS projects: oxlint (incl. vendored anti-slop) and Knip",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"antelopejs",
|
|
7
|
+
"anti-slop",
|
|
8
|
+
"knip",
|
|
9
|
+
"oxc",
|
|
10
|
+
"oxlint"
|
|
11
|
+
],
|
|
12
|
+
"license": "Apache-2.0",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/AntelopeJS/tooling-configs.git"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"type": "module",
|
|
21
|
+
"exports": {
|
|
22
|
+
"./oxc/lint": "./dist/oxc/lint.mjs",
|
|
23
|
+
"./oxc/fmt": "./dist/oxc/fmt.mjs",
|
|
24
|
+
"./oxc/anti-slop": "./dist/oxc/anti-slop/index.mjs",
|
|
25
|
+
"./knip": "./dist/knip.mjs",
|
|
26
|
+
"./eslint": "./dist/eslint.mjs"
|
|
27
|
+
},
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsdown",
|
|
33
|
+
"lint": "oxlint",
|
|
34
|
+
"lint:fix": "oxlint --fix",
|
|
35
|
+
"format": "oxfmt .",
|
|
36
|
+
"prepack": "pnpm run build",
|
|
37
|
+
"release": "pnpm run lint && pnpm run prepack && release-it",
|
|
38
|
+
"typecheck": "tsc --noEmit",
|
|
39
|
+
"test": "node --test \"src/oxc/anti-slop/rules/*.test.ts\"",
|
|
40
|
+
"checks": "pnpm run typecheck && pnpm run lint && pnpm run format:check && pnpm run test",
|
|
41
|
+
"check:dist": "pnpm run build && git diff --exit-code dist",
|
|
42
|
+
"format:check": "oxfmt --check ."
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@oxlint/plugins": "1.81.0"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@nuxt/eslint-config": "^1.17.0",
|
|
49
|
+
"@types/node": "^24.13.3",
|
|
50
|
+
"eslint-plugin-perfectionist": "^5.11.0",
|
|
51
|
+
"oxfmt": "^0.66.0",
|
|
52
|
+
"oxlint": "1.81.0",
|
|
53
|
+
"release-it": "^19.2.4",
|
|
54
|
+
"release-it-changelogen": "^0.1.0",
|
|
55
|
+
"tsdown": "^0.22.14",
|
|
56
|
+
"typescript": "^5.9.3"
|
|
57
|
+
},
|
|
58
|
+
"peerDependencies": {
|
|
59
|
+
"@nuxt/eslint-config": ">=1.2.0",
|
|
60
|
+
"eslint-plugin-perfectionist": ">=5.0.0",
|
|
61
|
+
"knip": ">=6.0.0",
|
|
62
|
+
"oxfmt": "^0.66.0",
|
|
63
|
+
"oxlint": "1.81.0"
|
|
64
|
+
},
|
|
65
|
+
"peerDependenciesMeta": {
|
|
66
|
+
"knip": {
|
|
67
|
+
"optional": true
|
|
68
|
+
},
|
|
69
|
+
"oxlint": {
|
|
70
|
+
"optional": true
|
|
71
|
+
},
|
|
72
|
+
"oxfmt": {
|
|
73
|
+
"optional": true
|
|
74
|
+
},
|
|
75
|
+
"@nuxt/eslint-config": {
|
|
76
|
+
"optional": true
|
|
77
|
+
},
|
|
78
|
+
"eslint-plugin-perfectionist": {
|
|
79
|
+
"optional": true
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
"engines": {
|
|
83
|
+
"node": ">=22.18.0"
|
|
84
|
+
},
|
|
85
|
+
"packageManager": "pnpm@10.2.0"
|
|
86
|
+
}
|