Skip to content

Commit 8a74df7

Browse files
authored
Add Nordcloud eslint config (#388)
* add nordcloud eslint config, fix errors * cleanup
1 parent 0e74b80 commit 8a74df7

16 files changed

+388
-753
lines changed

.eslintrc.js

+13-248
Original file line numberDiff line numberDiff line change
@@ -4,271 +4,36 @@
44
const isProd = process.env.NODE_ENV === "production";
55

66
module.exports = {
7-
parser: "@typescript-eslint/parser",
8-
parserOptions: {
9-
ecmaVersion: 2020,
10-
sourceType: "module",
11-
ecmaFeatures: {
12-
jsx: true,
13-
},
14-
},
157
extends: [
16-
"plugin:sonarjs/recommended",
17-
"plugin:react/recommended",
18-
"plugin:react-hooks/recommended",
19-
"plugin:@typescript-eslint/eslint-recommended",
20-
"plugin:@typescript-eslint/recommended",
21-
"plugin:jsx-a11y/recommended",
22-
"plugin:fp/recommended",
23-
"plugin:import/errors",
24-
"plugin:import/warnings",
25-
"plugin:import/typescript",
26-
"prettier",
8+
"@nordcloud/eslint-config-pat/profile/web-app",
9+
"@nordcloud/eslint-config-pat/mixins/react",
2710
],
28-
plugins: ["fp"],
11+
12+
parserOptions: { tsconfigRootDir: __dirname },
13+
14+
settings: {
15+
react: {
16+
version: "16.13.1", // React version. "detect" automatically picks the version you have installed.
17+
},
18+
},
19+
2920
rules: {
3021
// general
31-
"no-shadow": "off", // @typescript-eslint/no-shadow is used
32-
"consistent-return": "off",
33-
"no-underscore-dangle": "off",
34-
"no-prototype-builtins": "off",
35-
"require-await": "off",
36-
camelcase: "off", // @typescript-eslint/naming-convention is used
37-
"no-nested-ternary": "error",
3822
"no-console": isProd ? "error" : "warn",
39-
"prefer-const": "error",
40-
complexity: ["error", 15],
41-
"max-params": ["error", 3],
42-
eqeqeq: ["error", "smart"],
4323
"no-unused-expressions": [
4424
isProd ? "error" : "warn",
4525
{ allowShortCircuit: true },
4626
],
27+
4728
// eslint-plugin-fp
48-
"fp/no-unused-expression": "off",
49-
"fp/no-rest-parameters": "off",
50-
"fp/no-nil": "off",
51-
"fp/no-throw": "off",
5229
"fp/no-mutating-methods": [
5330
isProd ? "off" : "warn",
5431
{
5532
allowedObjects: ["history"],
5633
},
5734
],
58-
"fp/no-mutation": [
59-
"error",
60-
{
61-
commonjs: true,
62-
exceptions: [{ property: "current" }],
63-
},
64-
],
65-
// eslint-plugin-import
66-
"import/no-extraneous-dependencies": "off",
67-
"import/no-relative-parent-imports": "off",
68-
// avoid false-positives for webpack resolution
69-
"import/no-unresolved": "off",
70-
"import/no-internal-modules": [
71-
"off",
72-
{
73-
allow: ["@testing-library/**"],
74-
},
75-
],
76-
"import/order": [
77-
"error",
78-
{
79-
alphabetize: {
80-
order: "asc",
81-
caseInsensitive: true,
82-
},
83-
groups: [
84-
"builtin",
85-
"external",
86-
"internal",
87-
"parent",
88-
"sibling",
89-
"index",
90-
],
91-
pathGroups: [
92-
{
93-
pattern: "~/**",
94-
group: "internal",
95-
},
96-
{
97-
pattern: "react",
98-
group: "external",
99-
position: "before",
100-
},
101-
],
102-
pathGroupsExcludedImportTypes: ["react"],
103-
},
104-
],
105-
"import/no-anonymous-default-export": [
106-
"error",
107-
{
108-
allowArray: false,
109-
allowArrowFunction: false,
110-
allowAnonymousClass: false,
111-
allowAnonymousFunction: false,
112-
allowCallExpression: true, // The true value here is for backward compatibility
113-
allowLiteral: false,
114-
allowObject: false,
115-
},
116-
],
117-
// eslint-plugin-react-hooks
118-
"react-hooks/exhaustive-deps": "warn",
119-
"react-hooks/rules-of-hooks": "error",
120-
// eslint-plugin-react
121-
"react/jsx-no-useless-fragment": "off",
122-
"react/prop-types": "off",
123-
"react/display-name": "off",
124-
"react/function-component-definition": [
125-
"error",
126-
{
127-
namedComponents: "function-declaration",
128-
unnamedComponents: "arrow-function",
129-
},
130-
],
131-
"react/jsx-pascal-case": ["error", { allowNamespace: true }],
132-
"react/jsx-boolean-value": ["error", "never"],
133-
"react/jsx-key": "error",
35+
13436
// eslint-plugin-sonarjs
135-
"sonarjs/cognitive-complexity": "off",
136-
"sonarjs/no-duplicate-string": "off",
13737
"sonarjs/no-nested-template-literals": "off",
138-
"sonarjs/no-unused-collection": "warn",
139-
"sonarjs/no-collapsible-if": "warn",
140-
// @typescript-eslint/eslint-plugin
141-
"@typescript-eslint/no-use-before-define": "off",
142-
"@typescript-eslint/explicit-function-return-type": "off",
143-
"@typescript-eslint/explicit-module-boundary-types": "off",
144-
"@typescript-eslint/interface-name-prefix": ["off", "never"],
145-
"@typescript-eslint/no-empty-function": "off",
146-
"@typescript-eslint/no-explicit-any": "error",
147-
"@typescript-eslint/naming-convention": [
148-
"error",
149-
{
150-
selector: "default",
151-
format: ["camelCase"],
152-
filter: {
153-
regex: "^(__typename|Component|_[iI]gnored)$",
154-
match: false,
155-
},
156-
},
157-
{
158-
selector: "variable",
159-
format: ["camelCase", "UPPER_CASE", "PascalCase"],
160-
filter: {
161-
regex: "^(__typename|_[iI]gnored)$",
162-
match: false,
163-
},
164-
},
165-
{
166-
selector: "parameter",
167-
format: ["camelCase"],
168-
leadingUnderscore: "allow",
169-
filter: {
170-
regex: "^(Component)$",
171-
match: false,
172-
},
173-
},
174-
{
175-
selector: "memberLike",
176-
modifiers: ["private"],
177-
format: ["camelCase"],
178-
leadingUnderscore: "require",
179-
},
180-
{
181-
selector: "typeLike",
182-
format: ["PascalCase"],
183-
},
184-
{
185-
selector: ["typeProperty"],
186-
format: ["camelCase"],
187-
leadingUnderscore: "allowDouble",
188-
filter: {
189-
regex: "^(Component)$",
190-
match: false,
191-
},
192-
},
193-
{
194-
selector: ["function"],
195-
format: ["camelCase", "PascalCase"],
196-
leadingUnderscore: "forbid",
197-
},
198-
{
199-
selector: ["objectLiteralProperty", "objectLiteralMethod"],
200-
format: ["camelCase", "UPPER_CASE", "PascalCase"],
201-
leadingUnderscore: "allowDouble",
202-
filter: {
203-
regex: "^(Content-Type|Authorization|Component)$",
204-
match: false,
205-
},
206-
},
207-
{
208-
selector: "enum",
209-
format: ["PascalCase", "UPPER_CASE"],
210-
},
211-
{
212-
selector: "enumMember",
213-
format: ["UPPER_CASE"],
214-
},
215-
],
216-
"@typescript-eslint/no-non-null-assertion": "error",
217-
"@typescript-eslint/consistent-type-definitions": ["error", "type"],
218-
"@typescript-eslint/no-unused-vars": [
219-
"error",
220-
{ varsIgnorePattern: "[iI]gnored", argsIgnorePattern: "^_" },
221-
],
222-
"@typescript-eslint/no-shadow": "error",
223-
},
224-
env: {
225-
es2020: true,
226-
browser: true,
227-
node: true,
228-
jest: true,
229-
},
230-
overrides: [
231-
{
232-
files: [
233-
"src/**/__tests__/**/*.[jt]s?(x)",
234-
"src/**/?(*.)+(spec|test).[jt]s?(x)",
235-
],
236-
extends: [
237-
"plugin:jest/all",
238-
"plugin:jest-dom/recommended",
239-
"plugin:testing-library/react",
240-
],
241-
rules: {
242-
// eslint-plugin-jest
243-
"jest/no-hooks": "off",
244-
"jest/require-top-level-describe": "off",
245-
"jest/prefer-expect-assertions": "off",
246-
"jest/expect-expect": "off",
247-
"jest/valid-expect-in-promise": "warn",
248-
"jest/no-identical-title": "error",
249-
"jest/no-mocks-import": "error",
250-
"jest/no-disabled-tests": "error",
251-
"jest/require-to-throw-message": "error",
252-
"jest/no-commented-out-tests": "error",
253-
// eslint-plugin-jest-dom
254-
"jest-dom/prefer-in-document": "off",
255-
// eslint-plugin-testing-library
256-
"testing-library/prefer-screen-queries": "error",
257-
// eslint-plugin-fp
258-
"fp/no-loops": "off",
259-
},
260-
},
261-
],
262-
settings: {
263-
linkComponents: ["Hyperlink", { name: "Link", linkAttribute: "to" }],
264-
"import/resolver": {
265-
node: {
266-
extensions: [".js", ".ts", ".tsx"],
267-
},
268-
},
269-
"import/internal-regex": "^~/",
270-
react: {
271-
version: "detect", // React version. "detect" automatically picks the version you have installed.
272-
},
27338
},
27439
};

.prettierrc

-19
This file was deleted.

.stylelintrc

-9
This file was deleted.

0 commit comments

Comments
 (0)