forked from farhadimrf/next-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheslint.config.js
82 lines (80 loc) · 2.42 KB
/
eslint.config.js
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
const { FlatCompat } = require("@eslint/eslintrc");
const compat = new FlatCompat({
baseDirectory: __dirname,
});
module.exports = [
...compat.extends(
"next/core-web-vitals",
"next/typescript",
"plugin:prettier/recommended",
"prettier",
),
{
// custom rules
rules: {
// force to use only arrow function
"no-restricted-syntax": [
"error",
"FunctionDeclaration",
{
selector: "FunctionExpression",
},
],
// do not check error objects in try...catch blocks
"@typescript-eslint/no-unused-vars": [
"error",
{
caughtErrors: "none",
},
],
// restrict any relative imports from parent directories
"@typescript-eslint/no-restricted-imports": [
"error",
{
patterns: ["../*"],
},
],
// force to use named exports instead of default export
"import/no-default-export": "error",
//
"import/order": [
"error",
{
groups: [
"builtin",
"external",
"internal",
"parent",
"sibling",
"index",
],
// put css modules at last
pathGroups: [
{
pattern: "./*.module.css",
group: "index",
position: "after",
},
],
// prevent any new line between all imports
"newlines-between": "never",
warnOnUnassignedImports: true,
},
],
},
},
{
// override to allow default exports in the pages directory
files: ["src/pages/**/*.{js,jsx,ts,tsx}"],
rules: {
"import/no-default-export": "off",
},
},
{
// override to allow 'require' imports in js/cjs files only in project root
files: ["*.{js,cjs}"],
rules: {
"@typescript-eslint/no-require-imports": "off",
},
},
];