forked from opensearch-project/opensearch-api-specification
-
Notifications
You must be signed in to change notification settings - Fork 0
/
eslint.config.mjs
127 lines (126 loc) · 5.04 KB
/
eslint.config.mjs
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
import globals from 'globals'
import parserTs from '@typescript-eslint/parser'
import parserYml from "yaml-eslint-parser"
import pluginComments from 'eslint-plugin-eslint-comments'
import pluginJs from '@eslint/js'
import pluginLicenseHeader from 'eslint-plugin-license-header'
import pluginTs from '@typescript-eslint/eslint-plugin'
import pluginYml from 'eslint-plugin-yml'
import pluginCspell from '@cspell/eslint-plugin'
import pluginStylistic from '@stylistic/eslint-plugin'
import pluginJest from 'eslint-plugin-jest'
export default [
pluginJs.configs.recommended,
{
files: ['**/*.{js,ts}'],
languageOptions: {
parser: parserTs,
parserOptions: {
project: './tsconfig.json'
},
globals: {
...globals.jest,
...globals.node,
},
},
plugins: {
'@typescript-eslint': pluginTs,
'license-header': pluginLicenseHeader,
'eslint-comments': pluginComments,
'@cspell': pluginCspell,
'@stylistic': pluginStylistic,
'jest': pluginJest
},
rules: {
...pluginJs.configs.recommended.rules,
...pluginComments.configs.recommended.rules,
...pluginTs.configs["recommended-type-checked"].rules,
'@stylistic/object-curly-spacing': ["error", "always"],
'@stylistic/keyword-spacing': ["error", { "before": true, "after": true }],
'@stylistic/space-unary-ops': ["error", { "words": true, "nonwords": false }],
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/consistent-indexed-object-style': 'error',
'@typescript-eslint/consistent-type-assertions': 'error',
'@typescript-eslint/dot-notation': 'error',
'@typescript-eslint/explicit-function-return-type': 'error',
'@typescript-eslint/naming-convention': ['error',
{ selector: 'classProperty', modifiers: ['static', 'readonly'], format: ['UPPER_CASE'], leadingUnderscore: 'allow' },
{ selector: 'memberLike', modifiers: ['public'], format: ['snake_case'], leadingUnderscore: 'forbid' },
{ selector: 'memberLike', modifiers: ['private', 'protected'], format: ['snake_case'], leadingUnderscore: 'require' },
{ selector: 'variableLike', format: ['snake_case', 'UPPER_CASE'], leadingUnderscore: 'allow' },
{ selector: 'typeLike', format: ['PascalCase'] },
{ selector: 'objectLiteralProperty', format: null },
{ selector: 'typeProperty', format: null }
],
'@typescript-eslint/no-confusing-void-expression': 'error',
'@typescript-eslint/no-dynamic-delete': 'off',
'@typescript-eslint/no-invalid-void-type': 'error',
'@typescript-eslint/no-non-null-assertion': 'error',
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/no-unsafe-argument': 'error',
'@typescript-eslint/prefer-nullish-coalescing': 'error',
'@typescript-eslint/require-array-sort-compare': 'error',
'@typescript-eslint/strict-boolean-expressions': ['error',
{
allowString: true,
allowNumber: true,
allowNullableObject: true,
allowNullableBoolean: true,
allowNullableString: false,
allowNullableNumber: false,
allowNullableEnum: false,
allowAny: false,
allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing: false
}
],
'@typescript-eslint/require-await': 'error',
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'@typescript-eslint/unbound-method': 'off',
'jest/unbound-method': 'error',
'array-callback-return': 'off',
'indent': ['error', 2, { 'SwitchCase': 1 }],
'new-cap': 'off',
'no-constant-condition': 'off',
'no-return-assign': 'error',
'no-trailing-spaces': 'error',
'object-shorthand': 'error',
'space-in-parens': 'error',
'license-header/header': [
'error',
[
'/*',
'* Copyright OpenSearch Contributors',
'* SPDX-License-Identifier: Apache-2.0',
'*',
'* The OpenSearch Contributors require contributions made to',
'* this file be licensed under the Apache-2.0 license or a',
'* compatible open source license.',
'*/'
]
],
'@cspell/spellchecker': ['error', { customWordListFile: '.cspell', autoFix: true }]
}
},
...pluginYml.configs['flat/standard'],
{
files: ["**/*.yaml", "**/*.yml"],
languageOptions: {
parser: parserYml
},
plugins: {
'yml': pluginYml
},
rules: {
'yml/no-empty-document': 'off',
'yml/quotes': ['error', { prefer: 'single', avoidEscape: true }],
'yml/plain-scalar': ['error', 'always'],
'yml/no-trailing-zeros': 'error',
'yml/no-multiple-empty-lines': 'error',
'yml/sort-sequence-values': ['error', { pathPattern: '.*', order: { type: 'asc' } }]
}
}
]