-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy path.eslintrc.js
79 lines (79 loc) · 2.56 KB
/
.eslintrc.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
module.exports = {
root: true,
extends: [
"nava",
"plugin:storybook/recommended",
// Disable ESLint code formatting rules which conflict with Prettier
"prettier",
// `next` should be extended last according to their docs
// https://nextjs.org/docs/basic-features/eslint
"next/core-web-vitals",
],
rules: {
// Next.js <Image> component is useful for optimizing images, but also requires additional
// dependencies to work in standalone mode. It may be overkill for most projects at
// Nava which aren't image heavy.
"@next/next/no-img-element": "off",
"no-restricted-imports": [
"error",
{
patterns: [
{
group: ["../"],
message: "Relative imports are not allowed.",
},
],
},
],
},
// Additional lint rules. These get layered onto the top-level rules.
overrides: [
// Lint config specific to Test files
{
files: ["tests/**"],
plugins: ["jest"],
extends: [
"plugin:jest/recommended",
"plugin:jest-dom/recommended",
"plugin:testing-library/react",
],
},
// Lint config specific to TypeScript files
{
files: "**/*.+(ts|tsx)",
parserOptions: {
// These paths need defined to support rules that require type information
tsconfigRootDir: __dirname,
project: ["./tsconfig.json"],
},
extends: [
"plugin:@typescript-eslint/recommended",
// Disable vanilla ESLint rules that conflict with those in @typescript-eslint
"plugin:@typescript-eslint/eslint-recommended",
// Rules that specifically require type information
"plugin:@typescript-eslint/recommended-requiring-type-checking",
],
plugins: ["@typescript-eslint"],
rules: {
camelcase: "off",
// Prevent dead code accumulation
"@typescript-eslint/no-unused-vars": [
"error",
{ argsIgnorePattern: "^_" },
],
// The usage of `any` defeats the purpose of typescript. Consider using `unknown` type instead instead.
"@typescript-eslint/no-explicit-any": "error",
// Just warn since playwright tests may not use screen the way jest would
"testing-library/prefer-screen-queries": "warn",
// Prevent unnecessary console statements
"no-console": ["error", { allow: ["warn", "error"] }],
},
},
],
settings: {
// Support projects where Next.js isn't installed in the root directory (such as a monorepo)
next: {
rootDir: __dirname,
},
},
};