-
Notifications
You must be signed in to change notification settings - Fork 48
/
eslint.config.js
157 lines (152 loc) · 4.51 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/*
Copyright 2024 Adobe. All rights reserved.
This file is licensed to you under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/
import { FlatCompat } from "@eslint/eslintrc";
import path from "path";
import { fileURLToPath } from "url";
import pluginJs from "@eslint/js";
import globals from "globals";
import babelParser from "@babel/eslint-parser";
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
import { glob } from "glob";
const allComponentPaths = glob.sync("src/components/*/");
const filename = fileURLToPath(import.meta.url);
const dirname = path.dirname(filename);
const compat = new FlatCompat({
baseDirectory: dirname,
});
export default [
...compat.extends("airbnb-base", "plugin:testcafe/recommended"),
...compat.plugins("ban", "testcafe"),
{
files: ["**/*.{js,cjs}"],
settings: {
// This will do the trick
"import/parsers": {
"@babel/eslint-parser": [".js", ".cjs", ".mjs"],
},
"import/resolver": {
node: {
extensions: [".js", ".cjs", ".mjs"],
},
},
},
languageOptions: {
parser: babelParser,
parserOptions: {
babelOptions: {
presets: ["@babel/preset-env"],
},
},
ecmaVersion: 2021,
globals: {
...globals.jasmine,
...globals.browser,
...globals.node,
fixture: true,
test: true,
expectAsync: "readonly", // newer jasmine feature
spyOnAllFunctions: "readonly", // newer jasmine feature
},
},
rules: {
"ban/ban": [
"error",
{ name: ["describe", "only"], message: "don't focus tests" },
{ name: "fdescribe", message: "don't focus tests" },
{ name: ["it", "only"], message: "don't focus tests" },
{ name: "fit", message: "don't focus tests" },
{ name: ["fixture", "only"], message: "don't focus tests" },
{ name: ["test", "only"], message: "don't focus tests" },
{ name: "ftest", message: "don't focus tests" },
],
"no-param-reassign": "off",
"prettier/prettier": "error",
"func-style": "error",
// Turning this off allows us to import devDependencies in our build tools.
// We enable the rule in src/.eslintrc.js since that's the only place we
// want to disallow importing extraneous dependencies.
"import/no-extraneous-dependencies": "off",
"prefer-destructuring": "off",
"import/prefer-default-export": "off",
"import/no-restricted-paths": [
"error",
{
zones: [
// prevent components from importing from other components, but allow
// importing from themselves
...allComponentPaths.map((componentPath, _, allPaths) => ({
target: componentPath,
from: [
"src/core",
"src/baseCode",
...allPaths.filter((p) => p !== componentPath),
],
})),
{
target: "src/core",
from: "src/baseCode",
},
{
target: "src/utils",
from: ["src/core", "src/components", "src/baseCode"],
},
{
target: "src/constants",
from: ["src/core", "src/components", "src/utils", "src/baseCode"],
},
],
},
],
},
},
{
files: ["src/**/*.{cjs,js}"],
languageOptions: {
globals: {
turbine: "readonly",
},
},
rules: {
"import/no-extraneous-dependencies": "error",
"import/extensions": [
"error",
{
js: "always",
},
],
},
},
{
files: ["test/**/*.{cjs,js}"],
rules: {
"import/extensions": [
"error",
{
js: "always",
},
],
},
},
{
files: ["scripts/**/*.{cjs,js}"],
rules: {
"no-console": "off",
"import/extensions": [
"error",
{
js: "always",
},
],
},
},
pluginJs.configs.recommended,
eslintPluginPrettierRecommended,
];