Skip to content

Commit

Permalink
feat: Support ESLint v7 (#190)
Browse files Browse the repository at this point in the history
* 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/*
  • Loading branch information
koba04 committed Jun 25, 2020
1 parent dc583e6 commit ba8ea8e
Show file tree
Hide file tree
Showing 6 changed files with 260 additions and 289 deletions.
16 changes: 4 additions & 12 deletions configs/typescript.js
@@ -1,29 +1,21 @@
module.exports = {
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
extends: [
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'prettier/@typescript-eslint'
],
extends: ['plugin:@typescript-eslint/recommended', 'prettier/@typescript-eslint'],
rules: {
'@typescript-eslint/array-type': ['error', {default: 'array-simple'}],
'@typescript-eslint/array-type': ['error', { default: 'array-simple' }],
'no-useless-constructor': 'off',
'@typescript-eslint/type-annotation-spacing': 'warn',
'@typescript-eslint/unified-signatures': 'warn',
'@typescript-eslint/ban-ts-ignore': 'off',
'@typescript-eslint/camelcase': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/explicit-member-accessibility': 'off',
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-object-literal-type-assertion': 'off',
'@typescript-eslint/no-triple-slash-reference': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/prefer-interface': 'off',
'@typescript-eslint/prefer-namespace-keyword': 'off',
Expand Down
8 changes: 4 additions & 4 deletions package.json
Expand Up @@ -27,22 +27,22 @@
},
"devDependencies": {
"@types/react": "^16.9.38",
"eslint": "^6.8.0",
"eslint": "^7.3.1",
"jest": "^26.0.1",
"prettier": "^2.0.5",
"react": "^16.13.1",
"standard-version": "^8.0.0",
"typescript": "^3.9.5"
},
"peerDependencies": {
"eslint": "^6.4.0",
"eslint": "^7.0.0",
"prettier": "^1.17.0 || ^2.0.0",
"react": "^16.8.6",
"typescript": "^3.4.5"
},
"dependencies": {
"@typescript-eslint/eslint-plugin": "^2.34.0",
"@typescript-eslint/parser": "^2.34.0",
"@typescript-eslint/eslint-plugin": "^3.4.0",
"@typescript-eslint/parser": "^3.4.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-prettier": "^3.1.4",
Expand Down
1 change: 0 additions & 1 deletion test/__snapshots__/run.test.js.snap
Expand Up @@ -19,7 +19,6 @@ Object {
},
"sum.ts": Object {
"errors": Array [
"no-import-assign",
"default-param-last",
"prefer-regex-literals",
"no-shadow",
Expand Down
12 changes: 6 additions & 6 deletions test/lib/runLint.js
@@ -1,19 +1,19 @@
'use strict'

const CLIEngine = require('eslint').CLIEngine
const { ESLint } = require('eslint')
const path = require('path')

const runLintWithFixtures = (configFile, target) => {
const cli = new CLIEngine({
configFile,
const runLintWithFixtures = async (configFile, target) => {
const eslint = new ESLint({
overrideConfigFile: configFile,
ignore: false,
useEslintrc: false,
extensions: ['.js', '.jsx', '.ts', '.tsx'],
})
const lintResult = cli.executeOnFiles([target])
const lintResult = await eslint.lintFiles([target])
// console.log(JSON.stringify(lintResult, null, 2))

return lintResult.results.reduce((results, { filePath, messages }) => {
return lintResult.reduce((results, { filePath, messages }) => {
return Object.assign(results, {
[path.basename(filePath)]: messages.reduce(
(resultPerFile, { severity, ruleId }) => {
Expand Down
4 changes: 2 additions & 2 deletions test/run.test.js
@@ -1,8 +1,8 @@
const runLint = require('./lib/runLint')

describe('fixtures', () => {
it('should match the snapshot', () => {
const result = runLint('./index.js', './test/fixtures')
it('should match the snapshot', async () => {
const result = await runLint('./index.js', './test/fixtures')
expect(result).toMatchSnapshot()
})
})

0 comments on commit ba8ea8e

Please sign in to comment.