@layerzerolabs/eslint-configuration 0.0.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/base.js +190 -0
- package/package.json +39 -0
- package/react-base.js +20 -0
- package/react-internal.js +17 -0
- package/server.js +25 -0
package/base.js
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
const typescriptEslint = require('@typescript-eslint/eslint-plugin');
|
|
2
|
+
const onlyWarn = require('eslint-plugin-only-warn');
|
|
3
|
+
const simpleImportSort = require('eslint-plugin-simple-import-sort');
|
|
4
|
+
const tsParser = require('@typescript-eslint/parser');
|
|
5
|
+
const globals = require('globals');
|
|
6
|
+
const espree = require('espree');
|
|
7
|
+
const js = require('@eslint/js');
|
|
8
|
+
const turboConfigModule = require('eslint-config-turbo/flat');
|
|
9
|
+
const turboConfig = turboConfigModule.default || turboConfigModule;
|
|
10
|
+
const prettierConfig = require('eslint-config-prettier/flat');
|
|
11
|
+
|
|
12
|
+
// Rules that work for both JavaScript and TypeScript
|
|
13
|
+
const commonRules = {
|
|
14
|
+
'no-constant-condition': 'off',
|
|
15
|
+
'no-empty': 'off',
|
|
16
|
+
'no-unused-vars': 'off',
|
|
17
|
+
'no-redeclare': 'off',
|
|
18
|
+
|
|
19
|
+
'simple-import-sort/imports': [
|
|
20
|
+
'warn',
|
|
21
|
+
{
|
|
22
|
+
groups: [
|
|
23
|
+
['^\\u0000'],
|
|
24
|
+
['^@?\\w'],
|
|
25
|
+
['^@(layerzerolabs|ui-internal|web3-ui-internal)/'],
|
|
26
|
+
['^@/'],
|
|
27
|
+
['^\\.'],
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
|
|
32
|
+
'simple-import-sort/exports': 'warn',
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// Rules that require TypeScript type information (only for .ts/.tsx files)
|
|
36
|
+
const typescriptRules = {
|
|
37
|
+
'@typescript-eslint/no-unused-vars': [
|
|
38
|
+
'warn',
|
|
39
|
+
{
|
|
40
|
+
argsIgnorePattern: '^_',
|
|
41
|
+
varsIgnorePattern: '^_',
|
|
42
|
+
caughtErrors: 'all',
|
|
43
|
+
caughtErrorsIgnorePattern: '^_',
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
|
|
47
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
48
|
+
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
49
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
50
|
+
'@typescript-eslint/no-non-null-assertion': 'off',
|
|
51
|
+
'@typescript-eslint/no-empty-interface': 'off',
|
|
52
|
+
|
|
53
|
+
'@typescript-eslint/consistent-type-imports': [
|
|
54
|
+
'warn',
|
|
55
|
+
{
|
|
56
|
+
prefer: 'type-imports',
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
|
|
60
|
+
'@typescript-eslint/no-floating-promises': 'warn',
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
module.exports = [
|
|
64
|
+
// ESLint recommended rules
|
|
65
|
+
js.configs.recommended,
|
|
66
|
+
|
|
67
|
+
// Turbo config (flat config format) - spread if array, otherwise include directly
|
|
68
|
+
...(Array.isArray(turboConfig) ? turboConfig : [turboConfig]),
|
|
69
|
+
|
|
70
|
+
// Prettier config
|
|
71
|
+
prettierConfig,
|
|
72
|
+
|
|
73
|
+
// Base configuration (common rules for all files)
|
|
74
|
+
{
|
|
75
|
+
plugins: {
|
|
76
|
+
'@typescript-eslint': typescriptEslint,
|
|
77
|
+
'only-warn': onlyWarn,
|
|
78
|
+
'simple-import-sort': simpleImportSort,
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
languageOptions: {
|
|
82
|
+
globals: {
|
|
83
|
+
...globals.node,
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
rules: {
|
|
88
|
+
...commonRules,
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
// Global ignores
|
|
93
|
+
{
|
|
94
|
+
ignores: [
|
|
95
|
+
'**/node_modules/',
|
|
96
|
+
'**/dist/',
|
|
97
|
+
'**/build/',
|
|
98
|
+
'**/.next/',
|
|
99
|
+
'**/.turbo/',
|
|
100
|
+
'**/coverage/',
|
|
101
|
+
'**/.eslintrc.*',
|
|
102
|
+
'**/eslint.config.*',
|
|
103
|
+
'**/tsup.config.*',
|
|
104
|
+
'**/vitest.config.ts',
|
|
105
|
+
'**/wagmi*.config.ts',
|
|
106
|
+
'**/cdk.out/',
|
|
107
|
+
'**/bin/',
|
|
108
|
+
'**/vm-tooling/docker/',
|
|
109
|
+
'**/tooling-configs/eslint/**',
|
|
110
|
+
'**/*.hbs',
|
|
111
|
+
'**/generated/**',
|
|
112
|
+
'**/generated-artifacts/**',
|
|
113
|
+
'**/generated-tron/**',
|
|
114
|
+
'**/generated-tron-artifacts/**',
|
|
115
|
+
'**/generated-zk/**',
|
|
116
|
+
'**/generated-zk-artifacts/**',
|
|
117
|
+
'**/generated_artifacts/**',
|
|
118
|
+
],
|
|
119
|
+
},
|
|
120
|
+
|
|
121
|
+
// TypeScript files
|
|
122
|
+
{
|
|
123
|
+
files: ['**/*.ts', '**/*.tsx'],
|
|
124
|
+
|
|
125
|
+
languageOptions: {
|
|
126
|
+
parser: tsParser,
|
|
127
|
+
parserOptions: {
|
|
128
|
+
project: true,
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
rules: {
|
|
132
|
+
...typescriptRules,
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
|
|
136
|
+
// JavaScript files
|
|
137
|
+
{
|
|
138
|
+
files: ['**/*.js', '**/*.jsx'],
|
|
139
|
+
|
|
140
|
+
languageOptions: {
|
|
141
|
+
parser: espree,
|
|
142
|
+
ecmaVersion: 'latest',
|
|
143
|
+
sourceType: 'module',
|
|
144
|
+
parserOptions: {},
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
|
|
148
|
+
// Config files and CommonJS files
|
|
149
|
+
{
|
|
150
|
+
files: ['**/*.config.{js,ts}', '**/*.cjs'],
|
|
151
|
+
|
|
152
|
+
languageOptions: {
|
|
153
|
+
globals: {
|
|
154
|
+
...globals.node,
|
|
155
|
+
},
|
|
156
|
+
|
|
157
|
+
parserOptions: {
|
|
158
|
+
project: null,
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
|
|
162
|
+
rules: {
|
|
163
|
+
'no-undef': 'off',
|
|
164
|
+
'@typescript-eslint/no-var-requires': 'off',
|
|
165
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
166
|
+
'@typescript-eslint/no-floating-promises': 'off',
|
|
167
|
+
'@typescript-eslint/consistent-type-imports': 'off',
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
|
|
171
|
+
// Test files
|
|
172
|
+
{
|
|
173
|
+
files: ['**/*.test.*', '**/*.spec.*', '**/tests/**', '**/test/**'],
|
|
174
|
+
|
|
175
|
+
languageOptions: {
|
|
176
|
+
parserOptions: {
|
|
177
|
+
project: null,
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
|
|
181
|
+
rules: {
|
|
182
|
+
'no-console': 'off',
|
|
183
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
184
|
+
'@typescript-eslint/no-non-null-assertion': 'off',
|
|
185
|
+
'@typescript-eslint/consistent-type-imports': 'off',
|
|
186
|
+
'@typescript-eslint/no-floating-promises': 'off',
|
|
187
|
+
'turbo/no-undeclared-env-vars': 'off',
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
];
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@layerzerolabs/eslint-configuration",
|
|
3
|
+
"version": "0.0.73",
|
|
4
|
+
"private": false,
|
|
5
|
+
"exports": {
|
|
6
|
+
"./base": "./base.js",
|
|
7
|
+
"./next": "./next.js",
|
|
8
|
+
"./node": "./node.js",
|
|
9
|
+
"./server": "./server.js",
|
|
10
|
+
"./react-base": "./react-base.js",
|
|
11
|
+
"./react-internal": "./react-internal.js"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"base.js",
|
|
15
|
+
"next.js",
|
|
16
|
+
"node.js",
|
|
17
|
+
"server.js",
|
|
18
|
+
"react-base.js",
|
|
19
|
+
"react-internal.js"
|
|
20
|
+
],
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@eslint/eslintrc": "^3.3.1",
|
|
23
|
+
"@eslint/js": "^9.37.0",
|
|
24
|
+
"@next/eslint-plugin-next": "15.1.3",
|
|
25
|
+
"@typescript-eslint/eslint-plugin": "^8.31.1",
|
|
26
|
+
"@typescript-eslint/parser": "^8.31.1",
|
|
27
|
+
"@vercel/style-guide": "6.0.0",
|
|
28
|
+
"eslint-config-prettier": "^10.1.2",
|
|
29
|
+
"eslint-config-turbo": "^2.5.8",
|
|
30
|
+
"eslint-plugin-only-warn": "1.1.0",
|
|
31
|
+
"eslint-plugin-simple-import-sort": "12.1.1",
|
|
32
|
+
"espree": "^10.3.0",
|
|
33
|
+
"globals": "^16.4.0"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "restricted",
|
|
37
|
+
"registry": "https://registry.npmjs.org/"
|
|
38
|
+
}
|
|
39
|
+
}
|
package/react-base.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const baseConfig = require('./base');
|
|
2
|
+
|
|
3
|
+
/** @type {import("eslint").Linter.Config} */
|
|
4
|
+
module.exports = Object.assign({}, baseConfig, {
|
|
5
|
+
extends: [...baseConfig.extends, 'plugin:react/recommended', 'plugin:react-hooks/recommended'],
|
|
6
|
+
plugins: [...baseConfig.plugins, 'react', 'react-hooks'],
|
|
7
|
+
rules: {
|
|
8
|
+
...baseConfig.rules,
|
|
9
|
+
'react/jsx-key': 'off',
|
|
10
|
+
'react/prop-types': 'off',
|
|
11
|
+
'react/react-in-jsx-scope': 'off',
|
|
12
|
+
'react-hooks/rules-of-hooks': 'error',
|
|
13
|
+
'react-hooks/exhaustive-deps': 'warn',
|
|
14
|
+
},
|
|
15
|
+
settings: {
|
|
16
|
+
react: {
|
|
17
|
+
version: 'detect',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const baseConfig = require('./react-base');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This is a custom ESLint configuration for use with
|
|
5
|
+
* internal (bundled by their consumer) libraries
|
|
6
|
+
* that utilize React.
|
|
7
|
+
*/
|
|
8
|
+
/** @type {import("eslint").Linter.Config} */
|
|
9
|
+
module.exports = Object.assign({}, baseConfig, {
|
|
10
|
+
globals: {
|
|
11
|
+
React: true,
|
|
12
|
+
JSX: true,
|
|
13
|
+
},
|
|
14
|
+
env: {
|
|
15
|
+
browser: true,
|
|
16
|
+
},
|
|
17
|
+
});
|
package/server.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const baseConfig = require('./base');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This is a custom ESLint configuration for use with Node.js server code.
|
|
5
|
+
*/
|
|
6
|
+
/** @type {import("eslint").Linter.Config} */
|
|
7
|
+
module.exports = Object.assign({}, baseConfig, {
|
|
8
|
+
env: {
|
|
9
|
+
node: true,
|
|
10
|
+
vitest: true,
|
|
11
|
+
},
|
|
12
|
+
overrides: [
|
|
13
|
+
...baseConfig.overrides,
|
|
14
|
+
{
|
|
15
|
+
files: ['**/__tests__/**/*', '**/*.test.*', '**/*.spec.*'],
|
|
16
|
+
extends: [],
|
|
17
|
+
rules: {
|
|
18
|
+
...baseConfig.rules,
|
|
19
|
+
'no-console': 'off',
|
|
20
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
21
|
+
'@typescript-eslint/no-non-null-assertion': 'off',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
});
|