-
Notifications
You must be signed in to change notification settings - Fork 93
Expand file tree
/
Copy patheslint.config.js
More file actions
212 lines (208 loc) · 5.76 KB
/
eslint.config.js
File metadata and controls
212 lines (208 loc) · 5.76 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
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
import prettier from 'eslint-config-vaadin/prettier';
import testing from 'eslint-config-vaadin/testing';
import typescript from 'eslint-config-vaadin/typescript';
import esX from 'eslint-plugin-es-x';
import html from 'eslint-plugin-html';
import noOnlyTests from 'eslint-plugin-no-only-tests';
import simpleImportSort from 'eslint-plugin-simple-import-sort';
import globals from 'globals';
import licenseHeader from './custom-rules/eslint/license-header.js';
const LICENSE_HEADER = `
/**
* @license
* Copyright (c) 2000 - ${new Date().getFullYear()} Vaadin Ltd.
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
*/
`;
const PRO_LICENSE_HEADER = `
/**
* @license
* Copyright (c) 2000 - ${new Date().getFullYear()} Vaadin Ltd.
*
* This program is available under Vaadin Commercial License and Service Terms.
*
*
* See https://vaadin.com/commercial-license-and-service-terms for the full
* license.
*/
`;
const PRO_COMPONENTS = ['charts', 'board', 'crud', 'dashboard', 'grid-pro', 'rich-text-editor', 'map'];
export default [
{
ignores: [
'coverage/**/*.js',
'dist/**/*.js',
'**/dist/**/*',
'packages/**/vendor/*.js',
'packages/**/dist/*.js',
'packages/**/test/dom/__snapshots__/*.snap.js',
'packages/**/test/*.generated.test.js',
],
},
...typescript,
...testing,
...prettier,
{
plugins: {
'es-x': esX,
'no-only-tests': noOnlyTests,
'simple-import-sort': simpleImportSort,
'custom-rules': {
rules: {
'license-header': licenseHeader,
},
},
},
languageOptions: {
parserOptions: {
projectService: false,
},
},
rules: {
'@typescript-eslint/class-literal-property-style': 'off',
'@typescript-eslint/class-methods-use-this': 'off',
'@typescript-eslint/consistent-indexed-object-style': 'off',
'@typescript-eslint/no-dynamic-delete': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/no-extraneous-class': 'off',
'@typescript-eslint/max-params': ['error', { max: 5 }],
'@typescript-eslint/no-shadow': 'off',
'@typescript-eslint/no-unused-expressions': 'off',
'no-only-tests/no-only-tests': 'error',
'simple-import-sort/imports': [
'error',
{
groups: [
[
// Side-effects group
'^\\u0000',
// External group
'^',
// Vaadin group
'^@vaadin',
// Parent group
'^\\.\\.',
// Sibling group
'^\\.',
],
],
},
],
'arrow-body-style': 'off',
'consistent-return': 'off',
'func-names': 'off',
'no-await-in-loop': 'off',
'no-bitwise': 'off',
'no-multi-assign': 'off',
'no-param-reassign': 'off',
'one-var': 'off',
'prefer-destructuring': 'off',
'prefer-object-has-own': 'off',
'prefer-promise-reject-errors': 'off',
'preserve-caught-error': 'off',
radix: 'off',
},
},
{
files: ['packages/**/*', 'test/integration/**', 'dev/**/*', 'api-docs/js/**'],
languageOptions: {
globals: {
...globals.browser,
},
},
},
{
files: ['dev/**/*.html'],
plugins: { html },
},
{
files: ['packages/**/vaadin-*.js'],
rules: {
// Ban ES2020, ES2021 operators in source component files, as they aren't supported by Polymer analyzer
'es-x/no-optional-chaining': 'error',
'es-x/no-nullish-coalescing-operators': 'error',
'es-x/no-logical-assignment-operators': 'error',
'logical-assignment-operators': 'off',
},
},
{
files: ['packages/*/src/**/*.js'],
rules: {
'no-restricted-syntax': [
'error',
{
selector: 'ForInStatement',
message: 'for..in loops are slower than Object.{keys,values,entries} and have their caveats.',
},
{
selector: "CallExpression[callee.property.name='validate']",
message:
"Don't call validate() directly - it bypasses manual validation mode. Use _requestValidation() instead",
},
],
},
},
{
files: ['packages/*/src/**/*.d.ts'],
rules: {
'@typescript-eslint/no-unused-vars': ['error', { varsIgnorePattern: '^TItem' }],
},
},
{
files: ['packages/*/src/**/*.{ts,js}'],
rules: {
'custom-rules/license-header': ['error', { licenseHeader: LICENSE_HEADER }],
},
},
{
files: [`packages/@(${PRO_COMPONENTS.join('|')})/src/**/*.{ts,js}`],
rules: {
'custom-rules/license-header': ['error', { licenseHeader: PRO_LICENSE_HEADER }],
},
},
{
files: ['scripts/**/*.js', '*.config.js', 'wtr-utils.js', 'custom-rules/**/*.js', 'api-docs/.eleventy.js'],
languageOptions: {
globals: {
...globals.node,
},
},
rules: {
'no-console': 'off',
'preserve-caught-error': 'off',
},
},
{
files: ['packages/**/test/**', 'test/integration/**'],
languageOptions: {
globals: {
...globals.mocha,
},
},
rules: {
'no-await-in-loop': 'off',
'max-classes-per-file': 'off',
'simple-import-sort/imports': [
'error',
{
groups: [
[
// Testing tools group
'^(@web|@vaadin/chai-plugins|@vaadin/test-runner-commands|@vaadin/testing-helpers|sinon)',
// Side-effects group
'^\\u0000',
// External group
'^',
// Vaadin group
'^@vaadin',
// Parent group
'^\\.\\.',
// Sibling group
'^\\.',
],
],
},
],
},
},
];