forked from Fluxora-Org/Fluxora-Backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.js
More file actions
90 lines (87 loc) · 3.32 KB
/
Copy patheslint.config.js
File metadata and controls
90 lines (87 loc) · 3.32 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
import parser from '@typescript-eslint/parser';
import tsPlugin from '@typescript-eslint/eslint-plugin';
import prettierConfig from 'eslint-config-prettier';
export default [
{
files: ['**/*.ts'],
ignores: ['dist/**', 'node_modules/**', 'coverage/**'],
languageOptions: {
parser,
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
project: './tsconfig.eslint.json',
},
},
plugins: {
'@typescript-eslint': tsPlugin,
},
rules: {
// General strictness
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'@typescript-eslint/no-explicit-any': 'error',
// Enforce explicit return types on public API and indexer methods.
// Applies to exported functions and class methods.
'@typescript-eslint/explicit-module-boundary-types': [
'error',
{
allowArgumentsExplicitlyTypedAsAny: false,
allowDirectConstAssertionInArrowFunctions: true,
allowHigherOrderFunctions: false,
allowTypedFunctionExpressions: true,
},
],
// Prevent floating-point arithmetic on variables named "amount" or "balance".
// Using parseFloat / Number() on these fields silently drops decimal precision.
// All amount/balance values must remain as decimal strings per the serialization policy.
'no-restricted-syntax': [
'error',
{
// Disallow: parseFloat(amount), parseFloat(balance), parseFloat(x.amount), etc.
selector:
'CallExpression[callee.name="parseFloat"] > Identifier[name=/amount|balance/i]',
message:
'Do not convert amount/balance fields with parseFloat — keep them as decimal strings.',
},
{
selector:
'CallExpression[callee.name="parseFloat"] > MemberExpression > Identifier[name=/amount|balance/i]',
message:
'Do not convert amount/balance fields with parseFloat — keep them as decimal strings.',
},
{
// Disallow: Number(amount), Number(balance)
selector:
'CallExpression[callee.name="Number"] > Identifier[name=/amount|balance/i]',
message:
'Do not convert amount/balance fields with Number() — keep them as decimal strings.',
},
{
selector:
'CallExpression[callee.name="Number"] > MemberExpression > Identifier[name=/amount|balance/i]',
message:
'Do not convert amount/balance fields with Number() — keep them as decimal strings.',
},
{
// Disallow unary + on amount/balance: +amount, +balance
selector: 'UnaryExpression[operator="+"] > Identifier[name=/amount|balance/i]',
message:
'Do not coerce amount/balance fields with unary + — keep them as decimal strings.',
},
],
},
},
{
// Relax return-type enforcement in test files — not part of the public API surface.
files: ['tests/**/*.ts', 'src/**/*.test.ts'],
plugins: {
'@typescript-eslint': tsPlugin,
},
rules: {
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'warn',
},
},
prettierConfig,
];