Skip to content

Commit

Permalink
feat: add eslint-config-typescript-react
Browse files Browse the repository at this point in the history
  • Loading branch information
john-d-pelingo committed Dec 1, 2020
1 parent be649e2 commit 5eda24e
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 8 deletions.
55 changes: 55 additions & 0 deletions packages/eslint-config-typescript-react/.eslintrc.js
@@ -0,0 +1,55 @@
const config = {
env: {
browser: true,
es6: true,
node: true,
},
root: true,
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'import', 'jsx-a11y', 'jest', 'react-hooks'],
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'prettier',
'prettier/react',
'prettier/@typescript-eslint',
'plugin:import/typescript',
],
rules: {
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-var-requires': 'off',
'import/no-default-export': 'error',
'import/no-deprecated': 'warn',
'import/order': [
'error',
{
pathGroupsExcludedImportTypes: ['builtin'],
groups: [
'builtin',
'external',
'internal',
'unknown',
'parent',
'sibling',
'index',
],
'newlines-between': 'always',
alphabetize: { order: 'asc' },
},
],
'import/prefer-default-export': 'off',
'react-hooks/exhaustive-deps': 'warn',
'react/prop-types': 'off',
'react/react-in-jsx-scope': 'off',
},
settings: {
'import/ignore': ['node_modules'],
react: {
version: 'detect',
},
},
}

module.exports = config
5 changes: 5 additions & 0 deletions packages/eslint-config-typescript-react/README.md
@@ -0,0 +1,5 @@
# @jdp-dev/eslint-config

My shareable [ESLint](https://eslint.org/) config for
[TypeScript](https://www.typescriptlang.org/) [React](https://reactjs.org/)
projects.
6 changes: 6 additions & 0 deletions packages/eslint-config-typescript-react/__tests__/index.js
@@ -0,0 +1,6 @@
const test = require('tape')

test('entry point parses', (t) => {
t.doesNotThrow(() => require('..'), 'index does not throw')
t.end()
})
@@ -0,0 +1,20 @@
const eslint = require('eslint')
const test = require('tape')

test('load config in eslint to validate all rule syntax is correct', (t) => {
const cli = new eslint.CLIEngine({
useEslintrc: false,
configFile: 'index.js',
})

const code = `
const Hello = ({ name }: { name: string }) => {
return <div>Hello, {name}!</div>
}
`

const result = cli.executeOnText(code)

t.equal(result.errorCount, 0)
t.end()
})
1 change: 1 addition & 0 deletions packages/eslint-config-typescript-react/index.js
@@ -0,0 +1 @@
module.exports = require('./.eslintrc.js')
50 changes: 50 additions & 0 deletions packages/eslint-config-typescript-react/package.json
@@ -0,0 +1,50 @@
{
"name": "@jdp-dev/eslint-config-typescript-react",
"version": "0.0.3",
"description": "My shareable ESLint config for TypeScript React projects.",
"private": false,
"homepage": "https://github.com/john-d-pelingo/jdp-scripts",
"author": {
"email": "johndarrylpelingo@gmail.com",
"name": "John Darryl Pelingo",
"url": "https://johndpelingo.com"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/john-d-pelingo/jdp-scripts",
"directory": "packages/eslint-config"
},
"bugs": {
"url": "https://github.com/john-d-pelingo/jdp-scripts/issues"
},
"main": "index.js",
"scripts": {
"lint": "eslint . --config=.eslintrc.js",
"test": "npm run lint && tape __tests__/*.js"
},
"peerDependencies": {
"@typescript-eslint/eslint-plugin": "^4.9.0",
"@typescript-eslint/parser": "^4.9.0",
"eslint": "^7.14.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-react": "^7.21.5",
"eslint-plugin-react-hooks": "^4.2.0",
"react": "^17.0.1",
"typescript": "^4.1.2"
},
"dependencies": {
"@typescript-eslint/eslint-plugin": "^4.9.0",
"@typescript-eslint/parser": "^4.9.0",
"eslint": "^7.14.0",
"eslint-config-airbnb-typescript": "^12.0.0",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-react": "^7.21.5",
"eslint-plugin-react-hooks": "^4.2.0",
"react": "^17.0.1",
"typescript": "^4.1.2"
}
}
9 changes: 1 addition & 8 deletions yarn.lock
Expand Up @@ -249,7 +249,7 @@
semver "^7.3.2"
tsutils "^3.17.1"

"@typescript-eslint/experimental-utils@4.9.0", "@typescript-eslint/experimental-utils@^4.0.1":
"@typescript-eslint/experimental-utils@4.9.0":
version "4.9.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-4.9.0.tgz#23a296b85d243afba24e75a43fd55aceda5141f0"
integrity sha512-0p8GnDWB3R2oGhmRXlEnCvYOtaBCijtA5uBfH5GxQKsukdSQyI4opC4NGTUb88CagsoNQ4rb/hId2JuMbzWKFQ==
Expand Down Expand Up @@ -1278,13 +1278,6 @@ eslint-plugin-import@^2.22.1:
resolve "^1.17.0"
tsconfig-paths "^3.9.0"

eslint-plugin-jest@^24.1.3:
version "24.1.3"
resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-24.1.3.tgz#fa3db864f06c5623ff43485ca6c0e8fc5fe8ba0c"
integrity sha512-dNGGjzuEzCE3d5EPZQ/QGtmlMotqnYWD/QpCZ1UuZlrMAdhG5rldh0N0haCvhGnUkSeuORS5VNROwF9Hrgn3Lg==
dependencies:
"@typescript-eslint/experimental-utils" "^4.0.1"

eslint-plugin-jsx-a11y@^6.4.1:
version "6.4.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.4.1.tgz#a2d84caa49756942f42f1ffab9002436391718fd"
Expand Down

0 comments on commit 5eda24e

Please sign in to comment.