forked from DogStark/PetChain-MobileApp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.js
More file actions
110 lines (100 loc) · 4.88 KB
/
Copy patheslint.config.js
File metadata and controls
110 lines (100 loc) · 4.88 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
// @ts-check
const js = require('@eslint/js');
const tseslint = require('typescript-eslint');
const reactPlugin = require('eslint-plugin-react');
const reactHooksPlugin = require('eslint-plugin-react-hooks');
const importPlugin = require('eslint-plugin-import');
const prettierPlugin = require('eslint-plugin-prettier');
module.exports = tseslint.config(
// ── Global ignores ────────────────────────────────────────────────────────
{
ignores: ['node_modules/**', 'dist/**', 'coverage/**', 'eslint.config.js'],
},
// ── Base JS rules ─────────────────────────────────────────────────────────
js.configs.recommended,
// ── TypeScript rules ──────────────────────────────────────────────────────
...tseslint.configs.recommended,
// ── React + React Hooks + Import + Prettier ───────────────────────────────
{
files: ['**/*.{ts,tsx,js,jsx}'],
plugins: {
react: reactPlugin,
'react-hooks': reactHooksPlugin,
import: importPlugin,
prettier: prettierPlugin,
},
languageOptions: {
parserOptions: {
ecmaFeatures: { jsx: true },
},
globals: {
// React Native / browser-like globals available in RN
console: 'readonly',
setTimeout: 'readonly',
clearTimeout: 'readonly',
setInterval: 'readonly',
clearInterval: 'readonly',
Promise: 'readonly',
Buffer: 'readonly',
process: 'readonly',
__DEV__: 'readonly',
},
},
settings: {
react: {
version: 'detect',
},
},
rules: {
// ── Prettier (formatting as lint errors) ──────────────────────────────
'prettier/prettier': 'error',
// ── TypeScript ────────────────────────────────────────────────────────
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
],
'@typescript-eslint/consistent-type-imports': [
'error',
{ prefer: 'type-imports', fixStyle: 'inline-type-imports' },
],
'@typescript-eslint/no-non-null-assertion': 'warn',
// ── React ─────────────────────────────────────────────────────────────
'react/react-in-jsx-scope': 'off', // Not needed with React 17+ JSX transform
'react/prop-types': 'off', // TypeScript handles prop types
'react/display-name': 'warn',
// ── React Hooks ───────────────────────────────────────────────────────
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
// ── Imports ───────────────────────────────────────────────────────────
'import/no-duplicates': 'error',
// no-cycle is disabled: it traverses node_modules for RN packages and
// produces false positives / parse errors. Use TypeScript's own
// project references or madge for cycle detection instead.
'import/no-cycle': 'off',
'import/order': [
'error',
{
groups: ['builtin', 'external', 'internal', ['parent', 'sibling', 'index']],
'newlines-between': 'always',
alphabetize: { order: 'asc', caseInsensitive: true },
},
],
// ── General best practices ────────────────────────────────────────────
'no-console': ['warn', { allow: ['warn', 'error'] }],
'no-debugger': 'error',
eqeqeq: ['error', 'always', { null: 'ignore' }],
'prefer-const': 'error',
'no-var': 'error',
},
},
// ── Relaxed rules for test files ──────────────────────────────────────────
{
files: ['**/__tests__/**/*.{ts,tsx}', '**/*.test.{ts,tsx}', '**/__mocks__/**/*.{ts,tsx}'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/consistent-type-imports': 'off',
'no-console': 'off',
},
},
);