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

feat: support ESLint 8.x #41

Merged
merged 3 commits into from Jan 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/validate.yml
@@ -0,0 +1,39 @@
name: validate
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like some of the things in this GH Action. I do think that we really should set up reusable GH Actions though, as there are no reasons whatsoever for this one to differ from https://github.com/standard/eslint-config-standard/blob/cade6a519f595c17d135408872dccf1f3767840a/.github/workflows/ci.yml


on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
main:
strategy:
matrix:
eslint: [7.12.1, 7, 8.0.0, 8]
node: [12.22.0, 12, 14.17.0, 14, 16.0.0, 16]
runs-on: ubuntu-latest
steps:
- name: 🛑 Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.9.1

- name: ⬇️ Checkout repo
uses: actions/checkout@v2

- name: ⎔ Setup node
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}

- name: 📥 Download deps
uses: bahmutov/npm-install@v1
with:
useLockFile: false

- name: Install ESLint v${{ matrix.eslint }}
run: npm install --no-save --force eslint@${{ matrix.eslint }}

- name: ▶️ Run tests
run: npm test
2 changes: 1 addition & 1 deletion .gitignore
@@ -1 +1 @@
node_modules/
node_modules
1 change: 1 addition & 0 deletions .npmrc
@@ -0,0 +1 @@
package-lock=false
3 changes: 0 additions & 3 deletions .travis.yml

This file was deleted.

10 changes: 5 additions & 5 deletions package.json
Expand Up @@ -11,9 +11,9 @@
"url": "https://github.com/standard/eslint-config-standard-jsx/issues"
},
"devDependencies": {
"eslint": "^7.12.1",
"eslint-plugin-react": "^7.21.5",
"tape": "^5.0.1"
"eslint": "^8.8.0",
"eslint-plugin-react": "^7.28.0",
"tape": "^5.5.0"
},
"homepage": "https://github.com/standard/eslint-config-standard-jsx",
"keywords": [
Expand Down Expand Up @@ -46,8 +46,8 @@
"license": "MIT",
"main": "index.js",
"peerDependencies": {
"eslint": "^7.12.1",
"eslint-plugin-react": "^7.21.5"
"eslint": "^8.8.0",
"eslint-plugin-react": "^7.28.0"
},
"repository": {
"type": "git",
Expand Down
20 changes: 8 additions & 12 deletions test/validate-config.js
@@ -1,26 +1,22 @@
const eslint = require('eslint')
const { ESLint } = require('eslint')
const test = require('tape')

test('load config in eslint to validate all rule syntax is correct', function (t) {
const CLIEngine = eslint.CLIEngine

const cli = new CLIEngine({
const cli = new ESLint({
useEslintrc: false,
configFile: 'eslintrc.json'
overrideConfigFile: 'eslintrc.json'
})

const code = 'var foo = 1\nvar bar = function () {}\nbar(foo)\n'

t.equal(cli.executeOnText(code).errorCount, 0)
t.equal(cli.lintText(code).errorCount, 0)
t.end()
})

test('space before an opening tag\'s closing bracket should not be allowed', t => {
const CLIEngine = eslint.CLIEngine

const cli = new CLIEngine({
const cli = new ESLint({
useEslintrc: false,
configFile: 'eslintrc.json'
overrideConfigFile: 'eslintrc.json'
})

const shouldPass = {
Expand Down Expand Up @@ -59,12 +55,12 @@ test('space before an opening tag\'s closing bracket should not be allowed', t =
t.plan(testPlansCount)

for (const testCase in shouldPass) {
const { errorCount } = cli.executeOnText(shouldPass[testCase])
const { errorCount } = cli.lintText(shouldPass[testCase])
t.equal(errorCount, 0)
}

for (const testCase in shouldFail) {
const { errorCount } = cli.executeOnText(shouldFail[testCase])
const { errorCount } = cli.lintText(shouldFail[testCase])
t.true(errorCount > 0)
}
})