-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.js
More file actions
88 lines (84 loc) · 2.98 KB
/
Copy patheslint.config.js
File metadata and controls
88 lines (84 loc) · 2.98 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
import js from '@eslint/js';
import typescript from 'typescript-eslint';
import react from 'eslint-plugin-react';
import reactHooks from 'eslint-plugin-react-hooks';
import eslintConfigPrettier from 'eslint-config-prettier/flat';
export default [
{
ignores: ['node_modules', 'dist', '.venv', 'build'],
},
js.configs.recommended,
...typescript.configs.recommended,
{
files: ['**/*.{js,jsx,ts,tsx}'],
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
globals: {
console: 'readonly',
process: 'readonly',
fetch: 'readonly',
Buffer: 'readonly',
},
},
plugins: {
react,
'react-hooks': reactHooks,
},
rules: {
// TypeScript
'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
},
],
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/explicit-function-return-types': 'off',
// Warn when using `value!` — the `!` tells TypeScript to trust you that a value
// isn't null/undefined. If you're wrong, it crashes at runtime. Handle null
// explicitly with `if (value)` or `value ?? fallback` instead.
'@typescript-eslint/no-non-null-assertion': 'warn',
// React
'react/react-in-jsx-scope': 'off', // React 17+ JSX transform
'react/prop-types': 'off', // Using TypeScript for type checking
'react/jsx-no-target-blank': 'warn',
'react/jsx-uses-react': 'off',
'react/jsx-uses-vars': 'warn',
// React Hooks
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
// General
'no-console': 'off', // Console logs are fine in dev
'no-unused-vars': 'off', // Handled by TypeScript rule above
'prefer-const': 'warn',
'no-var': 'error',
// Require `===` instead of `==`. JavaScript's `==` silently coerces types
// before comparing — `"1" == 1` is true. `===` checks value AND type, always.
eqeqeq: ['error', 'always'],
// Prefer `\`Hello ${name}\`` over `"Hello " + name`. Template literals are
// more readable and less error-prone when mixing strings and values.
'prefer-template': 'warn',
// Flag `+val`, `!!val`, `~val` type conversions. Use `Number(val)` and
// `Boolean(val)` instead — they state intent clearly and are easier to read.
'no-implicit-coercion': 'error',
// Warn when reassigning function parameters or their properties. Treat
// function arguments as read-only inputs — mutating them creates hidden side
// effects that are difficult to trace. Set to warn (not error) to allow
// React's `ref.current = node` pattern.
'no-param-reassign': ['warn', { props: true }],
},
settings: {
react: {
version: 'detect',
},
},
},
eslintConfigPrettier,
];