forked from hiero-ledger/hiero-contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.mjs
More file actions
104 lines (93 loc) · 2.78 KB
/
Copy patheslint.config.mjs
File metadata and controls
104 lines (93 loc) · 2.78 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
// SPDX-License-Identifier: Apache-2.0
import js from '@eslint/js';
import { defineConfig } from 'eslint/config';
import prettierConfig from 'eslint-config-prettier';
import simpleImportSort from 'eslint-plugin-simple-import-sort';
import globals from 'globals';
// Custom inline plugin for header checking
const headerRule = {
create(context) {
return {
Program(node) {
const comments = context.sourceCode.getAllComments();
const hasHeader = comments.some(comment =>
comment.value.includes('SPDX-License-Identifier: Apache-2.0'),
);
if (!hasHeader) {
context.report({ node, message: 'Missing SPDX license header' });
}
},
};
},
};
export default defineConfig([
// Global ignores
{
ignores: ['**/node_modules/**', '**/dist/**'],
},
// Base recommended configs
js.configs.recommended,
// Main configuration for all JS files
{
files: ['**/*.js', '**/*.mjs', '**/*.cjs'],
plugins: {
'simple-import-sort': simpleImportSort,
local: {
rules: {
header: headerRule,
},
},
},
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
globals: {
...globals.node,
...globals.es2021,
__ENV: 'readonly',
},
},
rules: {
// Disable rules that conflict with Prettier
...prettierConfig.rules,
// Style & safety
'no-trailing-spaces': 'error',
'no-useless-escape': 'warn',
'prefer-const': 'error',
'comma-dangle': [
'error',
{
arrays: 'always-multiline',
objects: 'always-multiline',
imports: 'always-multiline',
exports: 'always-multiline',
functions: 'always-multiline',
},
],
// Import sorting
'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'off',
// SPDX header
'local/header': 'error',
},
},
// Config for eslint config files themselves
{
files: ['eslint.config.mjs'],
languageOptions: {
sourceType: 'module',
globals: {
...globals.node,
},
},
},
// Test files - relaxed rules (JS only)
{
files: ['**/*.spec.js', '**/*.test.js', '**/test/**/*.js'],
languageOptions: {
globals: {
...globals.mocha,
},
},
},
]);