-
Notifications
You must be signed in to change notification settings - Fork 73
/
eslint.config.js
137 lines (136 loc) · 3.23 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
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
130
131
132
133
134
135
136
137
import cyfConfig from "@codeyourfuture/eslint-config-standard";
import vitestPlugin from "@vitest/eslint-plugin";
import prettierConfig from "eslint-config-prettier";
import importPlugin from "eslint-plugin-import";
import jestDomPlugin from "eslint-plugin-jest-dom";
import jsxA11yPlugin from "eslint-plugin-jsx-a11y";
import nodePlugin from "eslint-plugin-n";
import playwrightPlugin from "eslint-plugin-playwright";
import reactPlugin from "eslint-plugin-react";
import reactHooksPlugin from "eslint-plugin-react-hooks";
import reactRefreshPlugin from "eslint-plugin-react-refresh";
import testingLibraryPlugin from "eslint-plugin-testing-library";
import globals from "globals";
/** @type {import("eslint").Linter.FlatConfig} */
export default [
cyfConfig,
prettierConfig,
{
plugins: {
import: importPlugin,
},
rules: {
"import/order": [
"error",
{ alphabetize: { order: "asc" }, "newlines-between": "always" },
],
},
},
{
files: ["api/**", "e2e/**", "**/vite.config.js"],
...nodePlugin.configs["flat/recommended"],
rules: {
...nodePlugin.configs["flat/recommended"].rules,
"n/no-extraneous-import": "off",
},
},
{
files: ["api/**"],
rules: {
"no-console": "warn",
},
},
{
files: ["api/**"],
rules: {
"no-restricted-syntax": [
"warn",
{
selector: "MemberExpression[object.name=process][property.name=env]",
message: "process.env should only be accessed in utils/config.cjs",
},
],
},
ignores: ["api/utils/config.cjs"],
},
{
files: ["**/*.cjs"],
...nodePlugin.configs["flat/recommended-script"],
},
{
files: ["api/migrations/template.cjs"],
rules: {
"no-unused-vars": ["error", { argsIgnorePattern: "pgm" }],
},
},
{
files: ["**/*.test.js", "**/setupTests.js"],
languageOptions: {
globals: vitestPlugin.environments.env.globals,
},
plugins: {
vitest: vitestPlugin,
},
rules: {
...vitestPlugin.configs.recommended.rules,
"vitest/expect-expect": [
"error",
{
assertFunctionNames: ["expect", "request.**.expect"],
},
],
},
},
{
files: ["e2e/**"],
...playwrightPlugin.configs["flat/recommended"],
},
{
files: ["web/**/*.js?(x)"],
languageOptions: {
globals: globals.browser,
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
},
plugins: {
"jsx-a11y": jsxA11yPlugin,
react: reactPlugin,
"react-hooks": reactHooksPlugin,
"react-refresh": reactRefreshPlugin,
},
rules: {
...jsxA11yPlugin.flatConfigs.recommended.rules,
...reactPlugin.configs.flat["recommended"].rules,
...reactPlugin.configs.flat["jsx-runtime"].rules,
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
],
},
settings: {
react: { version: "detect" },
},
},
{
files: ["web/**/*.test.js?(x)", "web/src/setupTests.js"],
languageOptions: {
globals: vitestPlugin.environments.env.globals,
},
plugins: {
"jest-dom": jestDomPlugin,
"testing-library": testingLibraryPlugin,
},
rules: {
...jestDomPlugin.configs.recommended.rules,
...testingLibraryPlugin.configs.react.rules,
},
},
{
ignores: ["api/static", "e2e/playwright-report", "e2e/test-results"],
},
];