Skip to content

Commit 90d3cd7

Browse files
committed
chore: cleanup monorepo eslint config
1 parent 611cc24 commit 90d3cd7

File tree

9 files changed

+428
-142
lines changed

9 files changed

+428
-142
lines changed

.pkgs/configs/.gitignore

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Node.js
2+
node_modules/
3+
4+
# Build
5+
!dist/
6+
out/
7+
build
8+
docs/internals/
9+
10+
# Editor
11+
.vim/
12+
.idea/
13+
14+
# Test
15+
coverage/
16+
17+
.eslintcache
18+
19+
# misc
20+
.DS_Store
21+
*.pem
22+
23+
# debug
24+
npm-debug.log*
25+
yarn-debug.log*
26+
yarn-error.log*
27+
28+
# local env files
29+
.env
30+
.env.local
31+
.env.development.local
32+
.env.test.local
33+
.env.production.local
34+
35+
# turbo
36+
.turbo
37+
38+
# vercel
39+
.vercel
40+
41+
stats.html
42+
*.config-*.mjs
43+
/eslint-config.json
44+
*.bundled_*.mjs
45+
*.tgz
46+
eslint-results.sarif
47+
.tsup

.pkgs/configs/eslint.d.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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 };

.pkgs/configs/eslint.js

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
// eslint.ts
2+
var templateIndentAnnotations = [
3+
"outdent",
4+
"dedent",
5+
"html",
6+
"tsx",
7+
"ts",
8+
];
9+
var p11tOptions = {
10+
type: "natural",
11+
ignoreCase: false,
12+
};
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"],
27+
};
28+
var typescript = {
29+
rules: {
30+
eqeqeq: ["error", "smart"],
31+
"no-undef": "off",
32+
"no-console": "error",
33+
"no-else-return": "error",
34+
"no-fallthrough": ["error", { commentPattern: ".*intentional fallthrough.*" }],
35+
"no-implicit-coercion": ["error", { allow: ["!!"] }],
36+
"no-mixed-operators": "warn",
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-imports": "error",
59+
"@typescript-eslint/explicit-function-return-type": "off",
60+
"@typescript-eslint/no-namespace": "off",
61+
"@typescript-eslint/no-empty-object-type": "off",
62+
"@typescript-eslint/no-misused-promises": "off",
63+
"@typescript-eslint/no-unnecessary-parameter-property-assignment": "warn",
64+
"@typescript-eslint/no-unused-vars": ["warn", { caughtErrors: "all" }],
65+
"@typescript-eslint/consistent-type-exports": "error",
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+
},
107+
],
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 };

.pkgs/configs/eslint.ts

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

.pkgs/configs/package.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,21 @@
44
"private": true,
55
"description": "Local config bases for use in the workspace",
66
"sideEffects": false,
7+
"type": "module",
78
"exports": {
9+
"./eslint": {
10+
"types": "./eslint.d.ts",
11+
"import": "./eslint.js"
12+
},
813
"./tsconfig.base.json": "./tsconfig.base.json",
914
"./typedoc.base.json": "./typedoc.base.json"
15+
},
16+
"scripts": {
17+
"build": "tsup",
18+
"lint:publish": "publint",
19+
"lint:ts": "tsc --noEmit"
20+
},
21+
"devDependencies": {
22+
"tsup": "^8.4.0"
1023
}
1124
}

0 commit comments

Comments
 (0)