Skip to content

Commit

Permalink
V3 (#23)
Browse files Browse the repository at this point in the history
* Update dependencies

* Add react hooks plugin

* Add plugin to reference rules not included in recommended

* Add jsx-a11y plugin and plugin tests

* Bump major

* Update node version

* Specify distribution for Node 18
  • Loading branch information
chawes13 authored Apr 4, 2023
1 parent 84eca47 commit 88f7806
Show file tree
Hide file tree
Showing 11 changed files with 4,168 additions and 3,383 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
language: node_js
node_js:
- '8'
- '18'
dist: focal
notifications:
email: false
deploy:
Expand Down
3 changes: 3 additions & 0 deletions babel.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["@launchpadlab/babel-preset/react"]
}
2 changes: 1 addition & 1 deletion es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
'es6': true,
},
'extends': './base.js',
'parser': 'babel-eslint',
'parser': '@babel/eslint-parser',
'parserOptions': {
'sourceType': 'module',
'ecmaFeatures': {
Expand Down
27 changes: 17 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
{
"name": "@launchpadlab/eslint-config",
"version": "2.7.0",
"version": "3.0.0",
"main": "index.js",
"license": "MIT",
"author": "dpikt",
"engines": {
"node": ">= 10"
},
"scripts": {
"test": "jest"
},
"dependencies": {
"babel-eslint": "^8.0.2",
"eslint-import-resolver-webpack": "^0.8.3",
"eslint-plugin-import": "^2.13.0",
"eslint-plugin-react": "^7.10.0"
"@babel/core": ">= 7.2.0",
"@babel/eslint-parser": "^7.21.3",
"eslint": "^8.0.0",
"eslint-import-resolver-webpack": "^0.13.2",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0"
},
"devDependencies": {
"eslint": "^5.0.0",
"jest": "^21.2.1",
"@launchpadlab/babel-preset": "^2.1.1",
"jest": "^29.5.0",
"react": "^16.8.6",
"webpack": "^3.8.1"
"webpack": "^5.0.0"
},
"peerDependencies": {
"eslint": ">= 3.0.0"
"resolutions": {
"babel-plugin-lodash/@babel/types": "~7.20.0"
}
}
4 changes: 4 additions & 0 deletions react.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ module.exports = {
'extends': [
'./es6.js',
'plugin:react/recommended',
'plugin:react-hooks/recommended',
'plugin:jsx-a11y/recommended',
],
'plugins': [
'react',
'react-hooks',
'jsx-a11y'
],
'rules': {
'react/prop-types': [
Expand Down
17 changes: 9 additions & 8 deletions test/all-configs.test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
const execSync = require('child_process').execSync
const { ESLint } = require('eslint')

// Basic sanity checks to make sure there are no syntax errors in the configs

function runConfig (config) {
execSync(`node_modules/.bin/eslint --config ${ config }.js test/test-input.js`, { stdio: 'inherit' })
async function runConfig (config) {
const cli = new ESLint({ overrideConfigFile: `${config}.js`})
return cli.lintFiles(['test/test-input.js'])
}

test('index', () => runConfig('index'))
test('base', () => runConfig('base'))
test('es6', () => runConfig('es6'))
test('react', () => runConfig('react'))
test('react-rails', () => runConfig('react-rails'))
test('index', async () => runConfig('index'))
test('base', async () => runConfig('base'))
test('es6', async () => runConfig('es6'))
test('react', async () => runConfig('react'))
test('react-rails', async () => runConfig('react-rails'))
16 changes: 16 additions & 0 deletions test/plugins.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const { ESLint } = require('eslint')

test('JSX A11y', async () => {
const cli = new ESLint({ overrideConfigFile: 'react.js' })
const results = await cli.lintFiles(['test/plugins/jsx-a11y.js'])
const issueCount = results.reduce((acc, result) => acc + result.errorCount + result.warningCount, 0)

expect(issueCount).toBeGreaterThan(0)
})

test('React Hooks', async () => {
const cli = new ESLint({ overrideConfigFile: 'react.js' })
const results = await cli.lintFiles(['test/plugins/react-hooks.js'])
const issueCount = results.reduce((acc, result) => acc + result.errorCount + result.warningCount, 0)
expect(issueCount).toBeGreaterThan(0)
})
9 changes: 9 additions & 0 deletions test/plugins/jsx-a11y.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react'

function JsxA11y() {
return (
<div onClick={() => null}>Click Me</div>
)
}

export default JsxA11y
19 changes: 19 additions & 0 deletions test/plugins/react-hooks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React, { useState, useEffect } from 'react'

function ReactHooks() {
const [count, setCount] = useState(0)

if (count) {
useEffect(() => {
if (count > 20) {
setCount(0)
}
}, [])
}

return (
<button onClick={() => setCount((c) => c+1)}>Count: {count}</button>
)
}

export default ReactHooks
1 change: 1 addition & 0 deletions test/test-input.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable */
function testInput () {
var thisFile = 'doesnt do anything'
return 'it is just an input for the tests!'
Expand Down
Loading

0 comments on commit 88f7806

Please sign in to comment.