-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.ts
More file actions
140 lines (129 loc) · 4.55 KB
/
Copy patheslint.config.ts
File metadata and controls
140 lines (129 loc) · 4.55 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
135
136
137
138
139
140
import js from "@eslint/js";
import stylisticJs from "@stylistic/eslint-plugin";
import tanstackRouter from "@tanstack/eslint-plugin-router";
import type { ESLint, Linter } from "eslint";
import i18next from "eslint-plugin-i18next";
import preferArrowFunctions from "eslint-plugin-prefer-arrow-functions";
import react from "eslint-plugin-react";
import reactHooks from "eslint-plugin-react-hooks";
import simpleImportSort from "eslint-plugin-simple-import-sort";
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- The type doesn't exist.
// @ts-expect-error
import sortDestructureKeys from "eslint-plugin-sort-destructure-keys";
import storybook from "eslint-plugin-storybook";
import unicorn from "eslint-plugin-unicorn";
import unusedImports from "eslint-plugin-unused-imports";
import globals from "globals";
import ts from "typescript-eslint";
const config: Linter.Config[] = [
{ settings: { react: { version: "detect" } } },
{ files: ["**/*.{js,mjs,cjs,ts,jsx,tsx}"] },
{ languageOptions: { globals: globals.browser } },
// Base JS/ES rules
{
plugins: { js },
rules: {
...js.configs.recommended.rules,
"arrow-body-style": ["error", "always"],
curly: "warn",
"no-console": "warn",
"no-extra-boolean-cast": "error",
"no-nested-ternary": "error",
"no-unneeded-ternary": "error",
"object-shorthand": "warn",
},
},
// React rules
{
plugins: { react },
rules: {
...react.configs.recommended.rules,
"react/hook-use-state": "warn",
"react/jsx-curly-brace-presence": "warn",
"react/jsx-no-leaked-render": "warn",
"react/jsx-no-useless-fragment": "warn",
"react/jsx-sort-props": ["warn", { shorthandLast: true }],
"react/react-in-jsx-scope": "off",
"react/self-closing-comp": "warn",
"react/prop-types": "off",
},
},
// TypeScript rules
...([
...ts.configs.recommended,
{
rules: {
"@typescript-eslint/consistent-type-imports": "warn",
"@typescript-eslint/method-signature-style": ["error", "property"],
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/consistent-type-definitions": ["warn", "type"],
},
},
] as Linter.Config[]),
// Custom plugins rules
{
plugins: {
"@stylistic": stylisticJs,
"@tanstack/router": tanstackRouter as unknown as ESLint.Plugin,
i18next,
"prefer-arrow-functions": preferArrowFunctions as ESLint.Plugin,
"react-hooks": reactHooks,
"simple-import-sort": simpleImportSort,
"sort-destructure-keys": sortDestructureKeys,
unicorn,
"unused-imports": unusedImports,
},
rules: {
"@stylistic/no-multi-spaces": "warn",
"@stylistic/no-multiple-empty-lines": ["warn", { max: 1 }],
"@stylistic/no-trailing-spaces": "warn",
"@stylistic/object-curly-spacing": ["warn", "always"],
"@stylistic/padding-line-between-statements": [
"warn",
{ blankLine: "always", prev: "*", next: "return" },
],
"@tanstack/router/create-route-property-order": "error",
"i18next/no-literal-string": "warn",
"prefer-arrow-functions/prefer-arrow-functions": "error",
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
"simple-import-sort/exports": "warn",
"simple-import-sort/imports": [
"warn",
{
groups: [
// Packages. `react` related packages come first.
["^react", "^@?\\w"],
// Internal packages and relative paths.
[
"^(@/.*)(/.*|$)",
// Side effect imports.
"^\\u0000",
// Parent imports. Put `..` last.
"^\\.\\.(?!/?$)",
"^\\.\\./?$",
// Other relative imports. Put same-folder imports and `.` last.
"^\\./(?=.*/)(?!/?$)",
"^\\.(?!/?$)",
"^\\./?$",
],
// Style imports.
["^.+\\.s?css$"],
],
},
],
"sort-destructure-keys/sort-destructure-keys": "warn",
"unicorn/filename-case": ["error", { case: "kebabCase" }],
"unused-imports/no-unused-imports": "warn",
"unused-imports/no-unused-vars": [
"warn",
{ vars: "all", varsIgnorePattern: "^_", args: "after-used", argsIgnorePattern: "^_" },
],
},
},
// Storybook rules
...storybook.configs["flat/recommended"],
{ files: ["**/*.stories.{ts,tsx}"], rules: { "i18next/no-literal-string": "off" } },
{ ignores: ["!.storybook"] },
];
export default config;