Skip to content

Commit 0276413

Browse files
authored
devextreme-angular: update eslint to 9 version (#29130)
1 parent 9d0ea6c commit 0276413

40 files changed

+3233
-2804
lines changed

packages/devextreme-angular/.eslintrc

Lines changed: 0 additions & 83 deletions
This file was deleted.
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
/* eslint-disable spellcheck/spell-checker */
2+
import path from 'node:path';
3+
import { fileURLToPath } from 'node:url';
4+
import { FlatCompat } from '@eslint/eslintrc';
5+
import babelParser from '@babel/eslint-parser';
6+
import tsParser from '@typescript-eslint/parser';
7+
import stylistic from '@stylistic/eslint-plugin';
8+
import importPlugin from 'eslint-plugin-import';
9+
import { changeRulesToStylistic } from 'eslint-migration-utils';
10+
11+
const filename = fileURLToPath(import.meta.url);
12+
const dirname = path.dirname(filename);
13+
const compat = new FlatCompat({
14+
baseDirectory: dirname,
15+
});
16+
17+
export default [
18+
{
19+
ignores: [
20+
'src/index.ts',
21+
'src/common',
22+
'src/ui',
23+
'tests/src/server/component-names.ts',
24+
'**/node_modules',
25+
'**/dist'],
26+
},
27+
{
28+
plugins: {
29+
'@stylistic': stylistic,
30+
import: importPlugin,
31+
},
32+
},
33+
{
34+
languageOptions: {
35+
parser: tsParser,
36+
parserOptions: {
37+
project: './tsconfig.json',
38+
tsconfigRootDir: dirname,
39+
requireConfigFile: false,
40+
ecmaVersion: 6,
41+
sourceType: 'module',
42+
},
43+
},
44+
},
45+
...compat.extends('devextreme/spell-check'),
46+
...compat.extends('devextreme/javascript').map((config) => ({
47+
...config,
48+
files: ['**/*.js', '**/*.mjs'],
49+
languageOptions: {
50+
parser: babelParser,
51+
},
52+
})),
53+
...compat.extends('devextreme/typescript').map((config) => ({
54+
...config,
55+
rules: config.rules
56+
? changeRulesToStylistic(config.rules)
57+
: {},
58+
files: ['**/*.ts'],
59+
})),
60+
{
61+
rules: {
62+
'import/no-cycle': 'warn',
63+
'no-param-reassign': 'warn',
64+
'no-underscore-dangle': 'warn',
65+
'spellcheck/spell-checker': [1, {
66+
lang: 'en_US',
67+
comments: false,
68+
strings: false,
69+
identifiers: true,
70+
templates: false,
71+
skipIfMatch: ['^\\$?..$'],
72+
skipWords: [
73+
'unschedule',
74+
'subscribable',
75+
'renderer',
76+
'rerender',
77+
'dx',
78+
'descr',
79+
'params',
80+
'typings',
81+
'wildcard',
82+
'metadata',
83+
'namespace',
84+
'namespaces',
85+
],
86+
}],
87+
},
88+
},
89+
{
90+
files: ['**/*.js', '**/*.mjs'],
91+
languageOptions: {
92+
parser: babelParser,
93+
},
94+
rules: {
95+
'global-require': 'off',
96+
'import/no-unresolved': 'off',
97+
'import/no-extraneous-dependencies': 'off',
98+
'import/no-dynamic-require': 'warn',
99+
'new-cap': 'off',
100+
'no-undef': 'off',
101+
'no-unused-expressions': 'warn',
102+
'no-useless-escape': 'warn',
103+
},
104+
},
105+
{
106+
files: ['**/*.ts'],
107+
rules: {
108+
'@stylistic/max-len': ['error', {
109+
code: 150,
110+
}],
111+
'@typescript-eslint/no-explicit-any': 'warn',
112+
'@typescript-eslint/no-extraneous-class': 'warn',
113+
'@typescript-eslint/explicit-module-boundary-types': 'warn',
114+
'@typescript-eslint/prefer-for-of': 'warn',
115+
'@typescript-eslint/explicit-function-return-type': 'warn',
116+
'@typescript-eslint/no-unsafe-return': 'warn',
117+
'@typescript-eslint/restrict-plus-operands': 'warn',
118+
'@typescript-eslint/no-this-alias': 'warn',
119+
'@typescript-eslint/prefer-optional-chain': 'warn',
120+
'@typescript-eslint/init-declarations': 'warn',
121+
'@typescript-eslint/prefer-nullish-coalescing': 'warn',
122+
'@typescript-eslint/no-use-before-define': 'warn',
123+
'@typescript-eslint/member-ordering': 'warn',
124+
'@typescript-eslint/no-dynamic-delete': 'warn',
125+
'@typescript-eslint/naming-convention': 'warn',
126+
'@typescript-eslint/no-invalid-this': 'warn',
127+
'@typescript-eslint/no-unsafe-function-type': 'warn',
128+
'@typescript-eslint/no-wrapper-object-types': 'warn',
129+
// NOTE: this rule requires "strictNullChecks": true in tsconfig
130+
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'off',
131+
'class-methods-use-this': 'warn',
132+
'consistent-return': 'warn',
133+
'guard-for-in': 'warn',
134+
'import/extensions': 'warn',
135+
'import/no-extraneous-dependencies': 'warn',
136+
'max-classes-per-file': 'warn',
137+
'no-plusplus': 'warn',
138+
'no-restricted-syntax': 'warn',
139+
'prefer-spread': 'warn',
140+
'no-empty-pattern': 'warn',
141+
'no-empty': 'warn',
142+
'no-prototype-builtins': 'warn',
143+
},
144+
},
145+
{
146+
files: ['**/*.spec.ts'],
147+
rules: {
148+
'@typescript-eslint/ban-ts-comment': 'warn',
149+
'@typescript-eslint/no-shadow': 'warn',
150+
'@typescript-eslint/no-unused-expressions': 'warn',
151+
'@typescript-eslint/class-literal-property-style': 'warn',
152+
'@typescript-eslint/no-useless-constructor': 'warn',
153+
'@typescript-eslint/no-empty-function': 'warn',
154+
'@typescript-eslint/require-await': 'warn',
155+
'@typescript-eslint/no-floating-promises': 'warn',
156+
'import/order': 'warn',
157+
'no-restricted-globals': 'warn',
158+
'no-self-assign': 'warn',
159+
'no-new': 'warn',
160+
'no-return-assign': 'warn',
161+
},
162+
},
163+
];

packages/devextreme-angular/gulpfile.js

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,24 +45,23 @@ gulp.task('clean.generatedComponents', (done) => {
4545

4646
del.sync([
4747
`${outputFolderPath}/*/**`,
48-
...skipFromCleaningFiles.flatMap(keepPattern => {
48+
...skipFromCleaningFiles.flatMap((keepPattern) => {
4949
const pathParts = keepPattern.match(/[\*\/]$/) ? keepPattern.split('/') : [keepPattern];
5050

5151
const patternsToKeep = pathParts.reduce((acc, pathPart) => {
52-
53-
if(pathPart) {
54-
acc.path += '/' + pathPart;
52+
if (pathPart) {
53+
acc.path += `/${pathPart}`;
5554
acc.patterns.push(`!${acc.path}`);
5655
}
5756

5857
return acc;
5958
}, {
6059
patterns: [],
61-
path: outputFolderPath.replace(/\/$/,'')
60+
path: outputFolderPath.replace(/\/$/, ''),
6261
}).patterns;
6362

6463
return patternsToKeep;
65-
})
64+
}),
6665
]);
6766

6867
done();
@@ -262,11 +261,9 @@ gulp.task('generate-component-names', (done) => {
262261
done();
263262
});
264263

265-
gulp.task('copy.dist.dx-angular', () => {
266-
return gulp
267-
.src(`${buildConfig.npm.distPath}/**/*`)
268-
.pipe(gulp.dest(path.join(buildConfig.components.testsPath, 'node_modules/devextreme-angular')));
269-
});
264+
gulp.task('copy.dist.dx-angular', () => gulp
265+
.src(`${buildConfig.npm.distPath}/**/*`)
266+
.pipe(gulp.dest(path.join(buildConfig.components.testsPath, 'node_modules/devextreme-angular'))));
270267

271268
gulp.task('build.tests', gulp.series('clean.tests', 'generate-component-names', 'copy.dist.dx-angular', () => {
272269
const config = buildConfig.components;
@@ -289,7 +286,7 @@ const getKarmaConfig = function (testsPath) {
289286
return karmaConfig.parseConfig(path.resolve('./karma.conf.js'), {
290287
files: [{ pattern: testsPath, watched: false }],
291288
preprocessors,
292-
}, {throwErrors: true});
289+
}, { throwErrors: true });
293290
};
294291

295292
gulp.task('test.components.client', gulp.series('build.tests', (done) => {
Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,56 @@
11
/* global process */
22
process.env.CHROME_BIN = require('puppeteer').executablePath();
33

4-
var webpackConfig = require('./webpack.test');
4+
const webpackConfig = require('./webpack.test');
55

6-
module.exports = function(config) {
7-
config.set({
6+
module.exports = function (config) {
7+
config.set({
88

9-
basePath: './',
9+
basePath: './',
1010

11-
frameworks: ['jasmine'],
11+
frameworks: ['jasmine'],
1212

13-
port: 9876,
13+
port: 9876,
1414

15-
logLevel: config.LOG_ERROR,
15+
logLevel: config.LOG_ERROR,
1616

17-
colors: true,
17+
colors: true,
1818

19-
autoWatch: true,
19+
autoWatch: true,
2020

21-
browsers: ['ChromeHeadless'],
21+
browsers: ['ChromeHeadless'],
2222

23-
reporters: [
24-
'progress',
25-
'junit'
26-
],
23+
reporters: [
24+
'progress',
25+
'junit',
26+
],
2727

28-
client: {
29-
jasmine: {
30-
random: false,
31-
}
32-
},
28+
client: {
29+
jasmine: {
30+
random: false,
31+
},
32+
},
3333

34-
junitReporter: {
35-
outputFile: 'test-results.xml'
36-
},
34+
junitReporter: {
35+
outputFile: 'test-results.xml',
36+
},
3737

38-
// Karma plugins loaded
39-
plugins: [
40-
require('karma-jasmine'),
41-
require('karma-chrome-launcher'),
42-
require('karma-junit-reporter'),
43-
require('karma-webpack')
44-
],
38+
// Karma plugins loaded
39+
plugins: [
40+
require('karma-jasmine'),
41+
require('karma-chrome-launcher'),
42+
require('karma-junit-reporter'),
43+
require('karma-webpack'),
44+
],
4545

46-
webpack: webpackConfig,
46+
webpack: webpackConfig,
4747

48-
webpackMiddleware: {
49-
stats: 'errors-only'
50-
},
48+
webpackMiddleware: {
49+
stats: 'errors-only',
50+
},
5151

52-
singleRun: true,
52+
singleRun: true,
5353

54-
concurrency: Infinity
55-
});
54+
concurrency: Infinity,
55+
});
5656
};

0 commit comments

Comments
 (0)