-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheslint.config.ts
129 lines (125 loc) · 3.74 KB
/
eslint.config.ts
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
import eslint from "@eslint/js";
import tsPlugin from "@typescript-eslint/eslint-plugin";
import prettierConfig from "eslint-config-prettier";
import prettierPlugin from "eslint-plugin-prettier";
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
import { readFileSync } from "fs";
import tsEslint from "typescript-eslint";
import importPlugin from "eslint-plugin-import";
const gitIgnores: string[] = readFileSync(".gitignore", "utf8")
.split("\r\n")
.filter((f): boolean => f.length && !f.includes("playground"));
const isForBuild: boolean = process.argv.includes("build");
const tsConfig: string = isForBuild ? "tsconfig.build.json" : "tsconfig.json";
export default tsEslint.config(
eslint.configs.recommended,
tsEslint.configs.recommendedTypeChecked,
prettierConfig,
eslintPluginPrettierRecommended,
{
ignores: [...gitIgnores, "yarn.lock", ".gitignore"],
},
{
plugins: {
prettier: prettierPlugin,
},
rules: {
"prettier/prettier": [
"warn",
{
semi: true,
useTabs: false,
tabWidth: 2,
singleQuote: false,
trailingComma: "all",
printWidth: 120,
endOfLine: "crlf",
bracketSpacing: true,
quoteProps: "as-needed",
arrowParens: "always",
parser: "typescript",
},
],
},
},
{
files: ["src/**/*.{ts,tsx,cts,mts,js,cjs,mjs}", "tests/**/*.{ts,tsx,cts,mts,js,cjs,mjs}"],
languageOptions: {
parserOptions: {
projectService: true,
project: tsConfig,
tsconfigRootDir: __dirname,
sourceType: "commonjs",
},
},
plugins: {
"typescript-eslint": tsPlugin,
prettier: prettierPlugin,
import: importPlugin,
},
rules: {
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/no-explicit-any": "warn",
"consistent-return": "off",
"@typescript-eslint/consistent-return": "error",
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/explicit-function-return-type": "error",
"@typescript-eslint/no-unsafe-enum-comparison": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-floating-promises": "off",
"import/no-dynamic-require": "warn",
"import/no-nodejs-modules": "warn",
"import/order": [
"error",
{
groups: [["builtin", "external"], ["internal", "parent", "sibling", "index"], ["type"]],
pathGroups: [
{
pattern: "@option/**",
group: "internal",
position: "before",
},
{
pattern: "@response/**",
group: "internal",
position: "before",
},
{
pattern: "@core/**",
group: "internal",
position: "before",
},
{
pattern: "@util/**",
group: "internal",
position: "before",
},
],
pathGroupsExcludedImportTypes: ["type"],
alphabetize: {
order: "asc",
caseInsensitive: true,
},
"newlines-between": "never",
},
],
},
},
{
files: ["tests/**/*.{ts,tsx,cts,mts,js,cjs,mjs}"],
rules: {
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-explicit-any": "off",
},
},
{
files: ["**/*.{json}", "**/*.config.ts"],
plugins: {
"typescript-eslint": tsPlugin,
prettier: prettierPlugin,
},
extends: [tsEslint.configs.disableTypeChecked],
},
);