forked from DuCanhGH/next-pwa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.cjs
121 lines (117 loc) · 2.93 KB
/
.eslintrc.cjs
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
// @ts-check
const path = require("node:path");
const fg = require("fast-glob");
const TSCONFIG_SOURCES = /** @type {const} */ ([
"tsconfig.json",
"tsconfig.eslint.json",
"docs/tsconfig.json",
"packages/*/tsconfig.json",
"packages/*/__tests__/tsconfig.json",
"examples/*/tsconfig.json",
]);
let packageDirs = fg
.sync("packages/*", {
cwd: __dirname,
onlyDirectories: true,
})
.map((dir) => path.join(__dirname, dir));
/** @type {import("eslint").Linter.BaseConfig} */
module.exports = {
parser: "@typescript-eslint/parser",
env: {
browser: true,
es2022: true,
node: true,
},
extends: [
"next/core-web-vitals",
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/recommended",
"plugin:import/typescript",
"turbo",
"prettier",
],
parserOptions: {
tsconfigRootDir: __dirname,
project: TSCONFIG_SOURCES,
ecmaVersion: "latest",
sourceType: "module",
warnOnUnsupportedTypeScriptVersion: false,
},
plugins: ["@typescript-eslint", "simple-import-sort"],
rules: {
"@typescript-eslint/ban-ts-comment": "error",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/consistent-type-imports": "warn",
"@typescript-eslint/no-unused-vars": [
"warn",
{
ignoreRestSiblings: true,
varsIgnorePattern: "^_",
argsIgnorePattern: "^_",
},
],
"import/no-extraneous-dependencies": "off",
// Doesn't really work with VSCode...
"import/no-unresolved": "off",
"import/no-named-as-default": "off",
"import/no-named-as-default-member": "off",
"no-unused-vars": "off",
"no-extra-boolean-cast": "off",
"simple-import-sort/imports": "warn",
"simple-import-sort/exports": "warn",
"turbo/no-undeclared-env-vars": [
"error",
{
allowList: ["^__PWA_FALLBACK_(.*)__+$", "^NEXT_PWA_(.*)+$"],
},
],
},
settings: {
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx", ".mjs", ".cjs", ".js"],
},
"import/resolver": {
typescript: {
alwaysTryTypes: true,
project: TSCONFIG_SOURCES,
},
},
"import/internal-regex": "^@ducanh2912/",
"import/external-module-folders": [
"packages/next-pwa",
"packages/next-sw",
"packages/utils",
"packages/constants",
"node_modules",
],
next: {
rootDir: ["./docs/", "./examples/*/"],
},
},
overrides: [
{
files: ["packages/**"],
rules: {
"import/no-extraneous-dependencies": [
"error",
{
devDependencies: ["**/*.config.{cjs,mjs,js,ts}"],
packageDir: [__dirname, ...packageDirs],
},
],
},
},
{
files: ["packages/*/__tests__/**"],
env: {
jest: true,
},
rules: {
"import/no-extraneous-dependencies": "off",
},
},
],
};