-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy patheslint.config.mjs
154 lines (142 loc) · 4.44 KB
/
eslint.config.mjs
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
import { FlatCompat } from "@eslint/eslintrc";
import pluginJs from "@eslint/js";
import pluginImport from "eslint-plugin-import";
import pluginReact from "eslint-plugin-react";
import tailwind from "eslint-plugin-tailwindcss";
import globals from "globals";
import tseslint from "typescript-eslint";
import securityPlugin from "eslint-plugin-security";
import prettier from "eslint-plugin-prettier";
import unicorn from "eslint-plugin-unicorn";
const compat = new FlatCompat({
baseDirectory: import.meta.dirname,
});
/** @type {import('eslint').Linter.Config[]} */
export default [
{ files: ["**/*.{js,mjs,cjs,ts,jsx,tsx}"] },
{ ignores: [".github/", ".husky/", "node_modules/", ".next/", "src/components/ui", "*.config.ts", "*.mjs"] },
{
languageOptions: {
globals: globals.browser,
parser: "@typescript-eslint/parser",
parserOptions: {
project: "./tsconfig.json",
},
},
settings: {
react: {
version: "detect",
},
},
plugins: {
import: pluginImport,
tailwindcss: tailwind,
security: securityPlugin,
prettier: prettier,
unicorn: unicorn,
react: pluginReact,
},
},
pluginJs.configs.recommended,
pluginReact.configs.flat.recommended,
securityPlugin.configs.recommended,
...tseslint.configs.recommended,
...tailwind.configs["flat/recommended"],
...compat.extends("next/core-web-vitals", "next/typescript"),
{
rules: {
// Prettier integration rules
"prettier/prettier": "warn",
// File Naming
"unicorn/filename-case": [
"error",
{
case: "kebabCase",
ignore: ["^.*\\.config\\.(js|ts|mjs)$", "^.*\\.d\\.ts$"],
},
],
// Custom Rules (Not covered by plugins)
"spaced-comment": ["error", "always", { exceptions: ["-", "+"] }],
"key-spacing": ["error", { beforeColon: false, afterColon: true }],
"no-useless-rename": "error",
// Import/Export Rules
"import/no-mutable-exports": "error",
"import/order": [
"error",
{
groups: ["builtin", "external", "internal", "parent", "sibling", "index"],
pathGroups: [
{
pattern: "react",
group: "external",
position: "before",
},
{
pattern: "{next,next/**}",
group: "external",
position: "before",
},
],
pathGroupsExcludedImportTypes: [],
"newlines-between": "always",
alphabetize: {
order: "asc",
caseInsensitive: true,
},
},
],
"import/newline-after-import": "error",
"import/no-unresolved": [
"error",
{
caseSensitive: true,
},
],
// Whitespace and Punctuation (Style Rules)
"no-trailing-spaces": "error",
"no-multiple-empty-lines": ["error", { max: 1, maxEOF: 1 }],
"space-before-function-paren": [
"error",
{
anonymous: "always",
named: "never",
asyncArrow: "always",
},
],
"space-in-parens": ["error", "never"],
"array-bracket-spacing": ["error", "never"],
"object-curly-spacing": ["error", "always"],
"func-call-spacing": ["error", "never"],
"computed-property-spacing": ["error", "never"],
// Naming Conventions
"no-underscore-dangle": ["error", { allow: ["_id", "__dirname"] }],
// Complexity
"complexity": ["error", { max: 10 }],
"max-lines": ["error", { max: 300, skipBlankLines: true, skipComments: true }],
"max-depth": ["error", 4],
// TypeScript-Specific Rules (customized)
"@typescript-eslint/prefer-nullish-coalescing": "error",
"@typescript-eslint/no-unnecessary-type-assertion": "error",
"@typescript-eslint/no-unnecessary-condition": "warn",
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-unused-vars": ["warn"],
// Tailwind CSS - Enforce Predefined Classes over Arbitrary Values
"tailwindcss/no-arbitrary-value": [
"warn",
{
config: "tailwind.config.ts",
},
],
// React unnecessary import rules
"react/jsx-no-useless-fragment": ["warn", { allowExpressions: true }],
// React JSX Pascal Case Rule
"react/jsx-pascal-case": [
"error",
{
allowAllCaps: false,
ignore: [],
},
],
},
},
];