Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add eslint-config-typescript-react
- Loading branch information
1 parent
be649e2
commit 5eda24e
Showing
7 changed files
with
138 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const test = require('tape') | ||
|
||
test('entry point parses', (t) => { | ||
t.doesNotThrow(() => require('..'), 'index does not throw') | ||
t.end() | ||
}) |
20 changes: 20 additions & 0 deletions
20
packages/eslint-config-typescript-react/__tests__/validate-config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('./.eslintrc.js') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters