-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patheslint.config.js
More file actions
80 lines (76 loc) · 2.83 KB
/
Copy patheslint.config.js
File metadata and controls
80 lines (76 loc) · 2.83 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
/**
* ESLint configuration for Paperlyte
*
* Uses the new flat config format (ESLint 9+) with:
* - JavaScript recommended rules
* - TypeScript strict type checking
* - React Hooks rules for proper hook usage
* - React Refresh rules for HMR compatibility
* - Prettier integration for code formatting
*
* @see https://eslint.org/docs/latest/use/configure/configuration-files
*/
import js from '@eslint/js'
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import tseslint from 'typescript-eslint'
import prettierConfig from 'eslint-config-prettier'
import { defineConfig, globalIgnores } from 'eslint/config'
export default defineConfig([
// Ignore build output directory
globalIgnores(['dist']),
{
// Apply to all TypeScript and TSX files
files: ['**/*.{ts,tsx}'],
// Extend recommended configurations
extends: [
// ESLint JavaScript recommended rules
js.configs.recommended,
// TypeScript ESLint recommended rules (includes type checking)
tseslint.configs.recommended,
// React Hooks rules (prevents common mistakes with hooks)
reactHooks.configs.flat.recommended,
// React Refresh rules (ensures components can be hot-reloaded)
reactRefresh.configs.vite,
// Prettier config (disables conflicting ESLint rules)
prettierConfig,
],
languageOptions: {
// Use ES2020 features
ecmaVersion: 2020,
// Browser globals (window, document, etc.)
globals: globals.browser,
},
rules: {
// Production console statements should be routed through the `monitoring`
// utility or guarded behind `import.meta.env.DEV`. `warn`/`error` are
// allowed everywhere as genuine production diagnostics.
'no-console': ['error', { allow: ['warn', 'error'] }],
},
},
// Node.js globals for build-tool configs and server-side scripts.
// These files run in Node, not the browser, so process/Buffer/__dirname etc.
// must be available. The TS rules from the block above still apply via
// flat-config merging; this block only supplements the globals.
{
files: ['*.config.ts', 'scripts/**/*.ts', 'netlify/functions/**/*.ts'],
languageOptions: {
globals: globals.node,
},
// CLI scripts and serverless functions legitimately log to stdout/stderr;
// the no-console audit (HIGH-002) is scoped to browser-side production
// source (src/**), not Node build tooling.
rules: {
'no-console': 'off',
},
},
// Sanctioned logging locations: `monitoring` and `analytics/**` are the
// centralized, designated places where `console.log` is permitted.
{
files: ['src/utils/monitoring.ts', 'src/analytics/**'],
rules: {
'no-console': ['error', { allow: ['warn', 'error', 'log', 'group', 'groupEnd'] }],
},
},
])