-
-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy patheslint.config.mjs
96 lines (91 loc) · 2.8 KB
/
eslint.config.mjs
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
import { dirname } from "path";
import { FlatCompat } from "@eslint/eslintrc";
import * as path from "node:path";
import { fileURLToPath } from "node:url";
import { includeIgnoreFile } from "@eslint/compat";
import eslint from "@eslint/js";
import importPlugin from "eslint-plugin-import";
import unusedImportsPlugin from "eslint-plugin-unused-imports";
import tseslint from "typescript-eslint";
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
});
const nextConfig = [...compat.extends("next/core-web-vitals", "next/typescript")];
const baseConfig = tseslint.config(
includeIgnoreFile(path.resolve(path.dirname(fileURLToPath(import.meta.url)), "./.gitignore")),
{ ignores: ["**/*.config.*"] },
{
files: ["**/*.js", "**/*.ts", "**/*.tsx"],
plugins: {
import: importPlugin,
"unused-imports": unusedImportsPlugin,
},
extends: [
eslint.configs.recommended,
...tseslint.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
...tseslint.configs.stylisticTypeChecked,
],
rules: {
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/consistent-type-imports": [
"warn",
{ prefer: "type-imports", fixStyle: "separate-type-imports" },
],
"@typescript-eslint/no-misused-promises": [2, { checksVoidReturn: { attributes: false } }],
"@typescript-eslint/no-unnecessary-condition": [
"error",
{
allowConstantLoopConditions: true,
},
],
"@typescript-eslint/no-non-null-assertion": "error",
"import/consistent-type-specifier-style": ["error", "prefer-top-level"],
"import/order": [
"error",
{
alphabetize: {
caseInsensitive: true,
order: "asc",
},
pathGroups: [
{
pattern: "@/**",
group: "internal",
position: "before",
},
],
groups: [
["builtin", "external"],
"internal",
"parent",
"sibling",
"index",
"object",
"type",
],
"newlines-between": "always",
warnOnUnassignedImports: true,
pathGroupsExcludedImportTypes: ["type"],
},
],
"unused-imports/no-unused-imports": "error",
"unused-imports/no-unused-vars": [
"warn",
{
vars: "all",
varsIgnorePattern: "^_",
args: "after-used",
argsIgnorePattern: "^_",
},
],
},
},
{
linterOptions: { reportUnusedDisableDirectives: true },
languageOptions: { parserOptions: { projectService: true } },
},
);
export default [...baseConfig, ...nextConfig];