Skip to content
This repository was archived by the owner on Dec 17, 2024. It is now read-only.

Commit ba8ea8e

Browse files
authored
feat: Support ESLint v7 (#190)
* deps: update ESLint v7 BREAKING CHANGE: Support minimum ESLint version is v7. * test: use ESLint class instead of CLIEngine * deps: update ESLint version in devDependencies and peerDependencies BREAKING CHANGE: drop ESLint v6 support * deps: update typescript-eslint version to v3 BREAKING CHANGE: Enable new rules in @typescript-eslint/recommended - @typescript-eslint/no-extra-non-null-assertion - @typescript-eslint/no-extra-semi - @typescript-eslint/no-non-null-asserted-optional-chain - ⚠️ @typescript-eslint/prefer-as-const * chore: revert changes in fixture * test: update snapshot for a disabled rule * deps: update eslint and typescript-eslint * deps: update typescript-eslint/* to v3.3.0 * deps: update ESLint and typescript-eslint/*
1 parent dc583e6 commit ba8ea8e

File tree

6 files changed

+260
-289
lines changed

6 files changed

+260
-289
lines changed

configs/typescript.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,21 @@
11
module.exports = {
22
parser: '@typescript-eslint/parser',
33
plugins: ['@typescript-eslint'],
4-
extends: [
5-
'plugin:@typescript-eslint/eslint-recommended',
6-
'plugin:@typescript-eslint/recommended',
7-
'prettier/@typescript-eslint'
8-
],
4+
extends: ['plugin:@typescript-eslint/recommended', 'prettier/@typescript-eslint'],
95
rules: {
10-
'@typescript-eslint/array-type': ['error', {default: 'array-simple'}],
6+
'@typescript-eslint/array-type': ['error', { default: 'array-simple' }],
117
'no-useless-constructor': 'off',
12-
'@typescript-eslint/type-annotation-spacing': 'warn',
138
'@typescript-eslint/unified-signatures': 'warn',
14-
'@typescript-eslint/ban-ts-ignore': 'off',
15-
'@typescript-eslint/camelcase': 'off',
16-
'@typescript-eslint/explicit-function-return-type': 'off',
9+
'@typescript-eslint/ban-ts-comment': 'off',
1710
'@typescript-eslint/explicit-member-accessibility': 'off',
18-
'@typescript-eslint/interface-name-prefix': 'off',
11+
'@typescript-eslint/explicit-module-boundary-types': 'off',
1912
'@typescript-eslint/no-empty-interface': 'off',
2013
'@typescript-eslint/no-explicit-any': 'off',
2114
'@typescript-eslint/no-inferrable-types': 'off',
2215
'@typescript-eslint/no-non-null-assertion': 'off',
2316
'@typescript-eslint/no-object-literal-type-assertion': 'off',
2417
'@typescript-eslint/no-triple-slash-reference': 'off',
2518
'@typescript-eslint/no-unused-vars': 'off',
26-
'@typescript-eslint/no-use-before-define': 'off',
2719
'@typescript-eslint/no-var-requires': 'off',
2820
'@typescript-eslint/prefer-interface': 'off',
2921
'@typescript-eslint/prefer-namespace-keyword': 'off',

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,22 @@
2727
},
2828
"devDependencies": {
2929
"@types/react": "^16.9.38",
30-
"eslint": "^6.8.0",
30+
"eslint": "^7.3.1",
3131
"jest": "^26.0.1",
3232
"prettier": "^2.0.5",
3333
"react": "^16.13.1",
3434
"standard-version": "^8.0.0",
3535
"typescript": "^3.9.5"
3636
},
3737
"peerDependencies": {
38-
"eslint": "^6.4.0",
38+
"eslint": "^7.0.0",
3939
"prettier": "^1.17.0 || ^2.0.0",
4040
"react": "^16.8.6",
4141
"typescript": "^3.4.5"
4242
},
4343
"dependencies": {
44-
"@typescript-eslint/eslint-plugin": "^2.34.0",
45-
"@typescript-eslint/parser": "^2.34.0",
44+
"@typescript-eslint/eslint-plugin": "^3.4.0",
45+
"@typescript-eslint/parser": "^3.4.0",
4646
"eslint-config-prettier": "^6.11.0",
4747
"eslint-plugin-jsx-a11y": "^6.3.1",
4848
"eslint-plugin-prettier": "^3.1.4",

test/__snapshots__/run.test.js.snap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ Object {
1919
},
2020
"sum.ts": Object {
2121
"errors": Array [
22-
"no-import-assign",
2322
"default-param-last",
2423
"prefer-regex-literals",
2524
"no-shadow",

test/lib/runLint.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
'use strict'
22

3-
const CLIEngine = require('eslint').CLIEngine
3+
const { ESLint } = require('eslint')
44
const path = require('path')
55

6-
const runLintWithFixtures = (configFile, target) => {
7-
const cli = new CLIEngine({
8-
configFile,
6+
const runLintWithFixtures = async (configFile, target) => {
7+
const eslint = new ESLint({
8+
overrideConfigFile: configFile,
99
ignore: false,
1010
useEslintrc: false,
1111
extensions: ['.js', '.jsx', '.ts', '.tsx'],
1212
})
13-
const lintResult = cli.executeOnFiles([target])
13+
const lintResult = await eslint.lintFiles([target])
1414
// console.log(JSON.stringify(lintResult, null, 2))
1515

16-
return lintResult.results.reduce((results, { filePath, messages }) => {
16+
return lintResult.reduce((results, { filePath, messages }) => {
1717
return Object.assign(results, {
1818
[path.basename(filePath)]: messages.reduce(
1919
(resultPerFile, { severity, ruleId }) => {

test/run.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
const runLint = require('./lib/runLint')
22

33
describe('fixtures', () => {
4-
it('should match the snapshot', () => {
5-
const result = runLint('./index.js', './test/fixtures')
4+
it('should match the snapshot', async () => {
5+
const result = await runLint('./index.js', './test/fixtures')
66
expect(result).toMatchSnapshot()
77
})
88
})

0 commit comments

Comments
 (0)