-
Notifications
You must be signed in to change notification settings - Fork 542
Expand file tree
/
Copy patheslint.config.mjs
More file actions
134 lines (127 loc) · 3.24 KB
/
eslint.config.mjs
File metadata and controls
134 lines (127 loc) · 3.24 KB
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
import { defineConfig } from "eslint/config";
// Import global definitions
import globals from "globals";
import js from "@eslint/js";
import tsParser from "@typescript-eslint/parser";
import tsPlugin from "@typescript-eslint/eslint-plugin";
import reactPlugin from "eslint-plugin-react";
import reactHooksPlugin from "eslint-plugin-react-hooks";
import importPlugin from "eslint-plugin-import";
import jsxA11yPlugin from "eslint-plugin-jsx-a11y";
import promisePlugin from "eslint-plugin-promise";
import sonarjsPlugin from "eslint-plugin-sonarjs";
import unicornPlugin from "eslint-plugin-unicorn";
import jestPlugin from "eslint-plugin-jest";
export default defineConfig([
// Base JS rules, with browser + node globals
{
...js.configs.recommended,
languageOptions: {
globals: {
// include browser globals (window, document, etc)
...globals.browser,
// include node globals (process, module, require, global, etc)
...globals.node,
// include jest globals (describe, test, expect etc)
...globals.jest,
},
},
},
// TypeScript files
{
files: ["**/*.ts", "**/*.tsx"],
languageOptions: {
parser: tsParser,
parserOptions: {
project: true,
tsconfigRootDir: new URL(".", import.meta.url).pathname,
ecmaVersion: "latest",
sourceType: "module",
ecmaFeatures: {
jsx: true,
},
},
globals: {
...globals.browser,
...globals.node,
...globals.jest,
},
},
plugins: {
"@typescript-eslint": tsPlugin,
},
rules: {
// desabilitar no-undef para TS, pois TS já detecta variáveis indefinidas
"no-undef": "off",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }],
},
},
// React / JSX files
{
files: ["**/*.tsx", "**/*.jsx"],
languageOptions: {
globals: {
...globals.browser,
...globals.node,
...globals.jest,
},
},
plugins: {
react: reactPlugin,
"react-hooks": reactHooksPlugin,
},
rules: {
"react/prop-types": "off",
"react/react-in-jsx-scope": "off",
},
settings: {
react: {
version: "detect",
},
},
},
// Common rules for all JS/TS/JSX/TSX
{
files: ["**/*.{js,ts,tsx,jsx}"],
languageOptions: {
globals: {
...globals.browser,
...globals.node,
...globals.jest,
},
},
plugins: {
import: importPlugin,
"jsx-a11y": jsxA11yPlugin,
promise: promisePlugin,
sonarjs: sonarjsPlugin,
unicorn: unicornPlugin,
jest: jestPlugin,
},
rules: {
"import/order": [
"warn",
{
groups: [
"builtin",
"external",
"internal",
"parent",
"sibling",
"index",
"object",
"type",
],
"newlines-between": "always",
alphabetize: { order: "asc", caseInsensitive: true },
},
],
"unicorn/prefer-module": "off",
},
},
// Ignores / files to skip
{
ignores: ["node_modules/", "dist/", "build/", "frontend/js/api/", "openapi-ts.config.ts"],
},
]);