Repository navigation
Expand file tree
/
Copy patheslint.config.mjs
More file actions
187 lines (182 loc) · 7.53 KB
/
Copy patheslint.config.mjs
File metadata and controls
187 lines (182 loc) · 7.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
import { defineConfig, globalIgnores } from "eslint/config";
import eslint from "@eslint/js";
import tseslint from "typescript-eslint";
import globals from "globals";
import { targets } from "./scripts/inputs.config.mjs";
import noDoubleAssertion from "./eslint-rules/no-double-assertion.mjs";
import noLooseComments from "./eslint-rules/no-loose-comments.mjs";
import noInputWrites from "./eslint-rules/no-input-writes.mjs";
import noInlineObjectTypes from "./eslint-rules/no-inline-object-types.mjs";
const HOUSE_STYLE = {
"quotes": ["error", "double", { avoidEscape: true, allowTemplateLiterals: true }],
"semi": ["error", "always"],
"eqeqeq": ["error", "always", { null: "ignore" }],
"curly": ["error", "all"],
};
const UNDERSCORE_TOLERANT_UNUSED_VARS = ["error", {
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
ignoreRestSiblings: true,
}];
const LOCAL_RULES = { rules: { "no-double-assertion": noDoubleAssertion, "no-loose-comments": noLooseComments, "no-input-writes": noInputWrites, "no-inline-object-types": noInlineObjectTypes } };
const MAGIC_NUMBERS = ["error", {
ignore: [-1, 0, 1, 2, 1024],
ignoreArrayIndexes: true,
ignoreDefaultValues: true,
ignoreClassFieldInitialValues: true,
ignoreEnums: true,
ignoreNumericLiteralTypes: true,
ignoreReadonlyClassProperties: true,
ignoreTypeIndexes: true,
}];
const PLACEMENT_MARKER = "^ (replaces|after) [\\w.]+$|^ (first|last)$";
const NO_JSDOC = { jsDoc: "none" };
const GENERATED = [
"packages/dev/*-worker/lib/api/**",
"packages/dev/*/lib/api/dto-registry.ts",
"packages/dev/*/lib/api/resolved-inputs/**",
"packages/dev/cad-cloud-sdk/src/types/schema-exports.ts",
"packages/dev/cad-cloud-sdk/src/types/pipeline-operations.ts",
"packages/dev/cad-cloud-sdk/src/types/generated.ts",
"packages/dev/cad-cloud-sdk/src/validation/request-schemas.ts",
"packages/dev/mcp/src/guides.generated.ts",
"packages/dev/ifc/lib/schema/generated/**",
];
const TESTS = ["**/*.test.ts", "**/*.test.mjs"];
const STAND_INS = ["**/__mocks__/**", "**/__test__/**"];
const OUTSIDE_CHECKS = ["packages/dev/*/validation/**", "packages/dev/*/bench/**"];
const VITEST_CONFIGS = ["**/vitest.config.ts", "packages/dev/vitest.shared.ts"];
export default defineConfig([
globalIgnores([
"**/node_modules/",
"**/dist/",
"**/coverage/",
"docs/*",
"!docs/scripts/",
"examples/*",
"!examples/scripts/",
"packages/dev/create-app/templates/",
"packages/dev/create-app/.local/",
"packages/dev/occt/bitbybit-dev-occt*/",
"packages/dev/*/etc/",
"**/*.d.ts",
...targets.map((t) => t.out),
], "outputs, the docs site and example apps, templates, generated and vendored files"),
{
files: ["**/*.{js,mjs,cjs,ts}"],
extends: [eslint.configs.recommended],
languageOptions: {
globals: { ...globals.browser, ...globals.node },
},
plugins: { bitbybit: LOCAL_RULES },
rules: {
...HOUSE_STYLE,
"no-unused-vars": UNDERSCORE_TOLERANT_UNUSED_VARS,
"no-empty": ["error", { allowEmptyCatch: true }],
"bitbybit/no-loose-comments": ["error", NO_JSDOC],
},
},
{
files: ["**/*.ts"],
extends: [...tseslint.configs.recommended],
rules: {
"@typescript-eslint/no-unused-vars": UNDERSCORE_TOLERANT_UNUSED_VARS,
"@typescript-eslint/consistent-type-imports": "error",
"bitbybit/no-double-assertion": "error",
},
},
{
files: ["**/*.ts"],
extends: [...tseslint.configs.recommendedTypeChecked],
languageOptions: {
parserOptions: {
projectService: {
allowDefaultProject: [
"packages/dev/vitest.shared.ts",
"packages/dev/cad-cloud-sdk/vitest.config.ts",
"packages/dev/create-app/vitest.config.ts",
"packages/dev/mcp/vitest.config.ts",
],
},
tsconfigRootDir: import.meta.dirname,
},
},
rules: {
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-redundant-type-constituents": "off",
},
},
{
files: ["packages/dev/core/lib/api/bitbybit/json.ts"],
rules: { "@typescript-eslint/no-explicit-any": "off" },
},
{
files: ["packages/dev/base/lib/api/services/logic.ts"],
rules: { "eqeqeq": "off" },
},
{
files: ["packages/dev/**/*.ts"],
ignores: [...TESTS, ...STAND_INS, ...OUTSIDE_CHECKS, ...VITEST_CONFIGS, "packages/dev/mcp/**"],
rules: { "bitbybit/no-loose-comments": ["error", { jsDoc: "public-api" }] },
},
{
files: ["packages/dev/*/lib/api-hand/**/*.ts"],
rules: { "bitbybit/no-loose-comments": ["error", { jsDoc: "public-api", allowLines: [PLACEMENT_MARKER] }] },
},
{
files: ["packages/dev/*/lib/api/inputs/*/namespace.ts"],
rules: { "bitbybit/no-loose-comments": ["error", { jsDoc: "public-api", documentsAssembledDeclaration: true }] },
},
{
files: ["packages/dev/**/*.ts"],
ignores: [...TESTS, ...STAND_INS, ...VITEST_CONFIGS],
rules: {
"bitbybit/no-inline-object-types": "error",
"@typescript-eslint/explicit-function-return-type": ["error", { allowExpressions: true, allowTypedFunctionExpressions: true, allowHigherOrderFunctions: true }],
"max-lines": ["error", { max: 600, skipBlankLines: true, skipComments: true }],
"@typescript-eslint/no-magic-numbers": MAGIC_NUMBERS,
},
},
{
files: ["packages/dev/**/constants.ts", "packages/dev/**/*.constants.ts", "packages/dev/occt/lib/services/design/digest.ts"],
rules: { "@typescript-eslint/no-magic-numbers": "off" },
},
{
files: OUTSIDE_CHECKS,
rules: { "max-lines": "off", "@typescript-eslint/no-magic-numbers": "off" },
},
{
files: GENERATED,
rules: { "bitbybit/no-loose-comments": "off", "bitbybit/no-inline-object-types": "off", "curly": "off", "eqeqeq": "off", "@typescript-eslint/consistent-type-imports": "off", "@typescript-eslint/explicit-function-return-type": "off", "max-lines": "off", "@typescript-eslint/no-magic-numbers": "off" },
},
{
files: [
"packages/dev/occt/lib/services/**/*.ts",
"packages/dev/jscad/lib/api/services/**/*.ts",
"packages/dev/manifold/lib/api/services/**/*.ts",
"packages/dev/ifc/lib/api/services/**/*.ts",
"packages/dev/base/lib/api/services/**/*.ts",
],
ignores: TESTS,
rules: { "bitbybit/no-input-writes": "error" },
},
{
files: [...TESTS, ...STAND_INS, ...OUTSIDE_CHECKS],
languageOptions: {
globals: { ...globals.vitest },
},
},
{
files: [...TESTS, ...STAND_INS, ...OUTSIDE_CHECKS].filter((glob) => !glob.endsWith(".mjs")),
rules: { "@typescript-eslint/consistent-type-imports": ["error", { disallowTypeAnnotations: false }] },
},
{
files: TESTS,
rules: { "bitbybit/no-loose-comments": ["error", { ...NO_JSDOC, allowArrangeActAssert: true }] },
},
]);