forked from MystenLabs/sui
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.eslintrc.js
164 lines (162 loc) · 3.95 KB
/
.eslintrc.js
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
155
156
157
158
159
160
161
162
163
164
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
module.exports = {
plugins: ['@tanstack/query', 'unused-imports', 'prettier', 'header', 'require-extensions'],
extends: [
'eslint:recommended',
'react-app',
'plugin:@tanstack/eslint-plugin-query/recommended',
'prettier',
'plugin:prettier/recommended',
'plugin:import/typescript',
],
settings: {
react: {
version: '18',
},
'import/resolver': {
typescript: true,
},
},
env: {
es2020: true,
},
root: true,
ignorePatterns: [
'node_modules',
'build',
'dist',
'coverage',
'apps/icons/src',
'next-env.d.ts',
'doc/book',
'external-crates',
'storybook-static',
'.next',
],
rules: {
'no-case-declarations': 'off',
'no-implicit-coercion': [2, { number: true, string: true, boolean: false }],
'@typescript-eslint/no-redeclare': 'off',
'@typescript-eslint/ban-types': [
'error',
{
types: {
Buffer: 'Buffer usage increases bundle size and is not consistently implemented on web.',
},
extendDefaults: true,
},
],
'no-restricted-globals': [
'error',
{
name: 'Buffer',
message: 'Buffer usage increases bundle size and is not consistently implemented on web.',
},
],
'header/header': [
2,
'line',
[' Copyright (c) Mysten Labs, Inc.', ' SPDX-License-Identifier: Apache-2.0'],
],
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
vars: 'all',
args: 'none',
ignoreRestSiblings: true,
},
],
},
overrides: [
{
files: ['sdk/**/*'],
rules: {
'require-extensions/require-extensions': 'error',
'require-extensions/require-index': 'error',
'@typescript-eslint/consistent-type-imports': ['error'],
'import/consistent-type-specifier-style': ['error', 'prefer-top-level'],
'import/no-cycle': ['error'],
},
},
{
files: ['apps/wallet/**/*'],
rules: {
'react/display-name': 'off',
'import/no-duplicates': ['error'],
'@typescript-eslint/consistent-type-imports': [
'error',
{
prefer: 'type-imports',
disallowTypeAnnotations: true,
fixStyle: 'inline-type-imports',
},
],
'@typescript-eslint/unified-signatures': 'error',
'@typescript-eslint/parameter-properties': 'error',
'no-console': ['warn'],
'@typescript-eslint/no-non-null-assertion': 'off',
},
},
{
files: ['apps/wallet/src/**/*.test.*', 'apps/wallet/src/**/*.spec.*'],
rules: {
// Allow any casting in tests:
'@typescript-eslint/no-explicit-any': 'off',
},
},
{
files: ['dapps/kiosk/**/*'],
rules: {
'no-unused-vars': 'off', // or "@typescript-eslint/no-unused-vars": "off",
'unused-imports/no-unused-imports': 'error',
'unused-imports/no-unused-vars': [
'warn',
{
vars: 'all',
varsIgnorePattern: '^_',
args: 'after-used',
argsIgnorePattern: '^_',
},
],
},
},
{
files: ['sdk/ledgerjs-hw-app-sui/**/*', 'apps/wallet/**/*'],
rules: {
// ledgerjs-hw-app-sui and wallet use Buffer
'no-restricted-globals': ['off'],
'@typescript-eslint/ban-types': ['off'],
},
},
{
files: ['*.test.*', '*.spec.*'],
rules: {
// Tests can violate extension rules:
'require-extensions/require-extensions': 'off',
'require-extensions/require-index': 'off',
'@typescript-eslint/consistent-type-imports': ['off'],
'import/consistent-type-specifier-style': ['off'],
// Reset to defaults to allow `Buffer` usage in tests (given they run in Node and do not impact bundle):
'no-restricted-globals': ['off'],
'@typescript-eslint/ban-types': ['error'],
},
},
{
files: ['*.stories.*'],
rules: {
// Story files have render functions that this rule incorrectly warns on:
'react-hooks/rules-of-hooks': 'off',
},
},
{
files: ['sdk/create-dapp/templates/**/*'],
rules: {
'header/header': 'off',
'require-extensions/require-extensions': 'off',
},
},
],
};