Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support ESLint v7 #190

Merged
merged 10 commits into from Jun 25, 2020
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()
})
})