Skip to content

Commit b2ddf16

Browse files
committed
chore: cleanup monorepo eslint config
1 parent d17cbad commit b2ddf16

File tree

10 files changed

+269
-244
lines changed

10 files changed

+269
-244
lines changed

.pkgs/configs/eslint.d.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
type Severity = 0 | 1 | 2;
2-
type SeverityString = "error" | "off" | "warn";
3-
type RuleLevel = Severity | SeverityString;
4-
type RuleLevelAndOptions = [RuleLevel, ...unknown[]];
5-
type RuleEntry = RuleLevel | RuleLevelAndOptions;
6-
type RulesRecord = Partial<Record<string, RuleEntry>>;
7-
declare const typescript: {
8-
rules: RulesRecord;
9-
};
10-
11-
export { typescript };
1+
import tseslint from "typescript-eslint";
2+
type ConfigArray = ReturnType<typeof tseslint.config>;
3+
export declare const typescript: ConfigArray;
4+
export {};

.pkgs/configs/eslint.js

Lines changed: 157 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -1,140 +1,161 @@
1-
// eslint.ts
2-
var templateIndentAnnotations = [
3-
"outdent",
4-
"dedent",
5-
"html",
6-
"tsx",
7-
"ts"
1+
import js from "@eslint/js";
2+
import stylistic from "@stylistic/eslint-plugin";
3+
import pluginDeMorgan from "eslint-plugin-de-morgan";
4+
import pluginJsdoc from "eslint-plugin-jsdoc";
5+
import pluginPerfectionist from "eslint-plugin-perfectionist";
6+
import pluginRegexp from "eslint-plugin-regexp";
7+
import pluginSimpleImportSort from "eslint-plugin-simple-import-sort";
8+
import pluginUnicorn from "eslint-plugin-unicorn";
9+
import tseslint from "typescript-eslint";
10+
const GLOB_TS = ["*.{ts,tsx,cts,mts}", "**/*.{ts,tsx,cts,mts}"];
11+
const templateIndentAnnotations = [
12+
"outdent",
13+
"dedent",
14+
"html",
15+
"tsx",
16+
"ts",
817
];
9-
var p11tOptions = {
10-
type: "natural",
11-
ignoreCase: false
18+
const p11tOptions = {
19+
type: "natural",
20+
ignoreCase: false,
1221
};
13-
var p11tGroups = {
14-
customGroups: {
15-
id: ["^_$", "^id$", "^key$", "^self$"],
16-
type: ["^type$", "^kind$"],
17-
meta: [
18-
"^name$",
19-
"^meta$",
20-
"^title$",
21-
"^description$"
22-
],
23-
alias: ["^alias$", "^as$"],
24-
rules: ["^node$", "^messageId$"]
25-
},
26-
groups: ["id", "type", "meta", "alias", "rules", "unknown"]
22+
const p11tGroups = {
23+
customGroups: {
24+
id: ["^_$", "^id$", "^key$", "^self$"],
25+
type: ["^type$", "^kind$"],
26+
meta: [
27+
"^name$",
28+
"^meta$",
29+
"^title$",
30+
"^description$",
31+
],
32+
alias: ["^alias$", "^as$"],
33+
rules: ["^node$", "^messageId$"],
34+
},
35+
groups: ["id", "type", "meta", "alias", "rules", "unknown"],
2736
};
28-
var typescript = {
29-
rules: {
30-
eqeqeq: ["error", "smart"],
31-
"no-console": "error",
32-
"no-else-return": "error",
33-
"no-fallthrough": ["error", { commentPattern: ".*intentional fallthrough.*" }],
34-
"no-implicit-coercion": ["error", { allow: ["!!"] }],
35-
"no-mixed-operators": "warn",
36-
"no-undef": "off",
37-
"prefer-object-has-own": "error",
38-
// Part: custom rules
39-
"no-restricted-syntax": [
40-
"error",
41-
{
42-
message: "no optional",
43-
selector: "TSPropertySignature[optional=true]"
44-
}
45-
],
46-
// Part: typescript-eslint rules
47-
"@typescript-eslint/ban-ts-comment": [
48-
"error",
49-
{
50-
minimumDescriptionLength: 5,
51-
"ts-check": false,
52-
"ts-expect-error": "allow-with-description",
53-
"ts-ignore": true,
54-
"ts-nocheck": true
55-
}
56-
],
57-
"@typescript-eslint/ban-types": "off",
58-
"@typescript-eslint/consistent-type-exports": "error",
59-
"@typescript-eslint/consistent-type-imports": "error",
60-
"@typescript-eslint/explicit-function-return-type": "off",
61-
"@typescript-eslint/no-empty-object-type": "off",
62-
"@typescript-eslint/no-misused-promises": "off",
63-
"@typescript-eslint/no-namespace": "off",
64-
"@typescript-eslint/no-unnecessary-parameter-property-assignment": "warn",
65-
"@typescript-eslint/no-unused-vars": ["warn", { caughtErrors: "all" }],
66-
"@typescript-eslint/strict-boolean-expressions": ["error", {
67-
allowAny: false,
68-
allowNullableBoolean: false,
69-
allowNullableEnum: false,
70-
allowNullableNumber: false,
71-
allowNullableObject: false,
72-
allowNullableString: false,
73-
allowNumber: true,
74-
allowString: false
75-
}],
76-
// Part: jsdoc rules
77-
"jsdoc/check-param-names": "warn",
78-
"jsdoc/check-tag-names": "warn",
79-
"jsdoc/informative-docs": "off",
80-
"jsdoc/lines-before-block": "off",
81-
"jsdoc/require-jsdoc": "off",
82-
"jsdoc/require-param": "warn",
83-
"jsdoc/require-param-description": "warn",
84-
"jsdoc/require-returns": "off",
85-
"jsdoc/require-yields": "warn",
86-
"jsdoc/tag-lines": "off",
87-
// Part: simple-import-sort rules
88-
"simple-import-sort/exports": "warn",
89-
"simple-import-sort/imports": "warn",
90-
// Part: stylistic rules
91-
"@stylistic/arrow-parens": ["warn", "always"],
92-
"@stylistic/no-multi-spaces": ["warn"],
93-
"@stylistic/operator-linebreak": [
94-
"warn",
95-
"before"
96-
],
97-
"@stylistic/quote-props": ["error", "as-needed"],
98-
// Part: perfectionist rules
99-
"perfectionist/sort-exports": "off",
100-
"perfectionist/sort-imports": "off",
101-
"perfectionist/sort-interfaces": [
102-
"warn",
103-
{
104-
...p11tOptions,
105-
...p11tGroups
106-
}
37+
export const typescript = tseslint.config({
38+
extends: [
39+
js.configs.recommended,
40+
...tseslint.configs.strict,
41+
pluginDeMorgan.configs.recommended,
42+
pluginJsdoc.configs["flat/recommended-typescript-error"],
43+
pluginRegexp.configs["flat/recommended"],
44+
pluginPerfectionist.configs["recommended-natural"],
10745
],
108-
"perfectionist/sort-intersection-types": "off",
109-
"perfectionist/sort-modules": "off",
110-
"perfectionist/sort-named-exports": "off",
111-
"perfectionist/sort-named-imports": "off",
112-
"perfectionist/sort-object-types": [
113-
"warn",
114-
{
115-
...p11tOptions,
116-
...p11tGroups
117-
}
118-
],
119-
"perfectionist/sort-objects": [
120-
"warn",
121-
{
122-
...p11tOptions,
123-
...p11tGroups,
124-
partitionByComment: "^Part:.*"
125-
}
126-
],
127-
"perfectionist/sort-switch-case": "off",
128-
"perfectionist/sort-union-types": "off",
129-
// Part: unicorn rules
130-
"unicorn/template-indent": [
131-
"warn",
132-
{
133-
comments: templateIndentAnnotations,
134-
tags: templateIndentAnnotations
135-
}
136-
]
137-
}
138-
};
139-
140-
export { typescript };
46+
files: GLOB_TS,
47+
plugins: {
48+
["@stylistic"]: stylistic,
49+
["simple-import-sort"]: pluginSimpleImportSort,
50+
["unicorn"]: pluginUnicorn,
51+
},
52+
rules: {
53+
eqeqeq: ["error", "smart"],
54+
"no-console": "error",
55+
"no-else-return": "error",
56+
"no-fallthrough": ["error", { commentPattern: ".*intentional fallthrough.*" }],
57+
"no-implicit-coercion": ["error", { allow: ["!!"] }],
58+
"no-mixed-operators": "warn",
59+
"no-undef": "off",
60+
"prefer-object-has-own": "error",
61+
// Part: custom rules
62+
"no-restricted-syntax": [
63+
"error",
64+
{
65+
message: "no optional",
66+
selector: "TSPropertySignature[optional=true]",
67+
},
68+
],
69+
// Part: typescript-eslint rules
70+
"@typescript-eslint/ban-ts-comment": [
71+
"error",
72+
{
73+
minimumDescriptionLength: 5,
74+
"ts-check": false,
75+
"ts-expect-error": "allow-with-description",
76+
"ts-ignore": true,
77+
"ts-nocheck": true,
78+
},
79+
],
80+
"@typescript-eslint/ban-types": "off",
81+
"@typescript-eslint/consistent-type-exports": "error",
82+
"@typescript-eslint/consistent-type-imports": "error",
83+
"@typescript-eslint/explicit-function-return-type": "off",
84+
"@typescript-eslint/no-empty-object-type": "off",
85+
"@typescript-eslint/no-misused-promises": "off",
86+
"@typescript-eslint/no-namespace": "off",
87+
"@typescript-eslint/no-unnecessary-parameter-property-assignment": "warn",
88+
"@typescript-eslint/no-unused-vars": ["warn", { caughtErrors: "all" }],
89+
"@typescript-eslint/strict-boolean-expressions": ["error", {
90+
allowAny: false,
91+
allowNullableBoolean: false,
92+
allowNullableEnum: false,
93+
allowNullableNumber: false,
94+
allowNullableObject: false,
95+
allowNullableString: false,
96+
allowNumber: true,
97+
allowString: false,
98+
}],
99+
// Part: jsdoc rules
100+
"jsdoc/check-param-names": "warn",
101+
"jsdoc/check-tag-names": "warn",
102+
"jsdoc/informative-docs": "off",
103+
"jsdoc/lines-before-block": "off",
104+
"jsdoc/require-jsdoc": "off",
105+
"jsdoc/require-param": "warn",
106+
"jsdoc/require-param-description": "warn",
107+
"jsdoc/require-returns": "off",
108+
"jsdoc/require-yields": "warn",
109+
"jsdoc/tag-lines": "off",
110+
// Part: simple-import-sort rules
111+
"simple-import-sort/exports": "warn",
112+
"simple-import-sort/imports": "warn",
113+
// Part: stylistic rules
114+
"@stylistic/arrow-parens": ["warn", "always"],
115+
"@stylistic/no-multi-spaces": ["warn"],
116+
"@stylistic/operator-linebreak": [
117+
"warn",
118+
"before",
119+
],
120+
"@stylistic/quote-props": ["error", "as-needed"],
121+
// Part: perfectionist rules
122+
"perfectionist/sort-exports": "off",
123+
"perfectionist/sort-imports": "off",
124+
"perfectionist/sort-interfaces": [
125+
"warn",
126+
{
127+
...p11tOptions,
128+
...p11tGroups,
129+
},
130+
],
131+
"perfectionist/sort-intersection-types": "off",
132+
"perfectionist/sort-modules": "off",
133+
"perfectionist/sort-named-exports": "off",
134+
"perfectionist/sort-named-imports": "off",
135+
"perfectionist/sort-object-types": [
136+
"warn",
137+
{
138+
...p11tOptions,
139+
...p11tGroups,
140+
},
141+
],
142+
"perfectionist/sort-objects": [
143+
"warn",
144+
{
145+
...p11tOptions,
146+
...p11tGroups,
147+
partitionByComment: "^Part:.*",
148+
},
149+
],
150+
"perfectionist/sort-switch-case": "off",
151+
"perfectionist/sort-union-types": "off",
152+
// Part: unicorn rules
153+
"unicorn/template-indent": [
154+
"warn",
155+
{
156+
comments: templateIndentAnnotations,
157+
tags: templateIndentAnnotations,
158+
},
159+
],
160+
},
161+
});

.pkgs/configs/eslint.ts

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1-
type Severity = 0 | 1 | 2;
2-
type SeverityString = "error" | "off" | "warn";
3-
type RuleLevel = Severity | SeverityString;
4-
type RuleLevelAndOptions = [RuleLevel, ...unknown[]];
5-
type RuleEntry = RuleLevel | RuleLevelAndOptions;
6-
type RulesRecord = Partial<Record<string, RuleEntry>>;
1+
import js from "@eslint/js";
2+
import stylistic from "@stylistic/eslint-plugin";
3+
import pluginDeMorgan from "eslint-plugin-de-morgan";
4+
import pluginJsdoc from "eslint-plugin-jsdoc";
5+
import pluginPerfectionist from "eslint-plugin-perfectionist";
6+
import pluginRegexp from "eslint-plugin-regexp";
7+
import pluginSimpleImportSort from "eslint-plugin-simple-import-sort";
8+
import pluginUnicorn from "eslint-plugin-unicorn";
9+
import tseslint from "typescript-eslint";
10+
11+
type ConfigArray = ReturnType<typeof tseslint.config>;
12+
13+
const GLOB_TS = ["*.{ts,tsx,cts,mts}", "**/*.{ts,tsx,cts,mts}"];
714

815
const templateIndentAnnotations = [
916
"outdent",
@@ -34,7 +41,21 @@ const p11tGroups = {
3441
groups: ["id", "type", "meta", "alias", "rules", "unknown"],
3542
};
3643

37-
export const typescript: { rules: RulesRecord } = {
44+
export const typescript: ConfigArray = tseslint.config({
45+
extends: [
46+
js.configs.recommended,
47+
...tseslint.configs.strict,
48+
pluginDeMorgan.configs.recommended,
49+
pluginJsdoc.configs["flat/recommended-typescript-error"],
50+
pluginRegexp.configs["flat/recommended"],
51+
pluginPerfectionist.configs["recommended-natural"],
52+
],
53+
files: GLOB_TS,
54+
plugins: {
55+
["@stylistic"]: stylistic,
56+
["simple-import-sort"]: pluginSimpleImportSort,
57+
["unicorn"]: pluginUnicorn,
58+
},
3859
rules: {
3960
eqeqeq: ["error", "smart"],
4061
"no-console": "error",
@@ -144,4 +165,4 @@ export const typescript: { rules: RulesRecord } = {
144165
},
145166
],
146167
},
147-
};
168+
});

.pkgs/configs/package.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,19 @@
1414
"./typedoc.base.json": "./typedoc.base.json"
1515
},
1616
"scripts": {
17-
"build": "tsup",
17+
"build": "tsc -p tsconfig.json",
1818
"lint:publish": "publint",
1919
"lint:ts": "tsc --noEmit"
2020
},
21-
"devDependencies": {
22-
"tsup": "^8.4.0"
21+
"dependencies": {
22+
"@eslint/js": "^9.22.0",
23+
"@stylistic/eslint-plugin": "^4.2.0",
24+
"eslint-plugin-de-morgan": "^1.2.0",
25+
"eslint-plugin-jsdoc": "^50.6.6",
26+
"eslint-plugin-perfectionist": "^4.10.1",
27+
"eslint-plugin-regexp": "^2.7.0",
28+
"eslint-plugin-simple-import-sort": "^12.1.1",
29+
"eslint-plugin-unicorn": "^57.0.0",
30+
"typescript-eslint": "^8.26.1"
2331
}
2432
}

0 commit comments

Comments
 (0)