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

V3 #23

Merged
merged 7 commits into from
Apr 4, 2023
Merged

V3 #23

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without specifying the dist, Travis fails to locate GLIB_C (still, somehow 🙃)

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"]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is needed in order to test the react plugins

}
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"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This aligns with @babel/eslint-parser's requirement

},
"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"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This plugin is kind of abandonware it seems. It relies on a deprecated method and pollutes the console with a bunch of messages about it. Since it's just a dev dependency, I really don't care about pinning it

}
}
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',
Comment on lines +5 to +6
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's time

Copy link

Choose a reason for hiding this comment

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

Out of curiosity, do you know if lp-components passes these a11y recommendations?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's very unlikely 😅 . But that's the point!

],
'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')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks ChatGPT ;)


// 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