Skip to content

Commit

Permalink
feat: support ESLint 8.x
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDeBoey committed Nov 14, 2021
1 parent 3b7031e commit 067965a
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 22 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/validate.yml
@@ -0,0 +1,32 @@
name: ci

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: lts/*

- name: Cache Node dependencies
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: npm install

- name: Run tests
run: npm test
8 changes: 7 additions & 1 deletion .gitignore
@@ -1 +1,7 @@
node_modules/
node_modules
.DS_Store

# these cause more harm than good
# when working with contributors
package-lock.json
yarn.lock
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.

16 changes: 10 additions & 6 deletions package.json
Expand Up @@ -10,11 +10,6 @@
"bugs": {
"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"
},
"homepage": "https://github.com/standard/eslint-config-standard-jsx",
"keywords": [
"JavaScript Standard Style",
Expand Down Expand Up @@ -45,8 +40,14 @@
],
"license": "MIT",
"main": "index.js",
"dependencies": {},
"devDependencies": {
"eslint": "^8.2.0",
"eslint-plugin-react": "^7.27.0",
"tape": "^5.0.1"
},
"peerDependencies": {
"eslint": "^7.12.1",
"eslint": "^7.12.1 || ^8.0.0",
"eslint-plugin-react": "^7.21.5"
},
"repository": {
Expand All @@ -56,6 +57,9 @@
"scripts": {
"test": "tape test/*.js"
},
"engines": {
"node": "^10.12.0 || >=12.0.0"
},
"funding": [
{
"type": "github",
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)
}
})

0 comments on commit 067965a

Please sign in to comment.