Skip to content

Commit

Permalink
馃敡 add eslint config with typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
Yago committed Aug 7, 2020
1 parent f9e6d9a commit fb302ae
Show file tree
Hide file tree
Showing 14 changed files with 3,851 additions and 48 deletions.
210 changes: 210 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
{
"env": {
"browser": true,
"jest": true,
"jquery": true,
"node": true
},
"extends": [
"airbnb",
"plugin:@typescript-eslint/recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:prettier/recommended",
"plugin:react/recommended",
"prettier",
"prettier/@typescript-eslint",
"prettier/react"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"plugins": [
"html",
"import",
"prettier",
"react-hooks",
"simple-import-sort"
],
"rules": {
"arrow-body-style": [
2,
"as-needed"
],
"camelcase": 0,
"comma-dangle": 0,
"consistent-return": 0,
"func-names": 0,
"import": 0,
"import/extensions": 0,
"import/no-extraneous-dependencies": [
"error",
{
"packageDir": "./"
}
],
"import/no-named-as-default": 0,
"import/order": "off",
"import/prefer-default-export": 0,
"jsx-a11y/accessible-emoji": 0,
"jsx-a11y/anchor-is-valid": [
"warn",
{
"aspects": [
"invalidHref"
]
}
],
"jsx-a11y/control-has-associated-label": [
2,
{
"ignoreElements": [
"link"
]
}
],
"jsx-a11y/href-no-hash": "off",
"max-len": 0,
"no-alert": 0,
"no-await-in-loop": 0,
"no-console": 0,
"no-debugger": 0,
"no-param-reassign": [
2,
{
"props": false
}
],
"no-restricted-syntax": [
2,
"ForInStatement",
"LabeledStatement",
"WithStatement"
],
"no-return-assign": [
"error",
"except-parens"
],
"no-shadow": [
2,
{
"allow": [
"resolve",
"reject",
"done",
"next",
"err",
"error"
],
"hoist": "all"
}
],
"no-underscore-dangle": 0,
"no-unused-expressions": [
2,
{
"allowTaggedTemplates": true
}
],
"no-unused-vars": [
"error",
{
"varsIgnorePattern": "React|tw"
}
],
"prefer-const": [
"error",
{
"destructuring": "all"
}
],
"prettier/prettier": [
"error",
{
"arrowParens": "avoid",
"singleQuote": true,
"trailingComma": "es5"
}
],
"quotes": [
2,
"single",
{
"allowTemplateLiterals": true,
"avoidEscape": true
}
],
"radix": 0,
"react-hooks/exhaustive-deps": "warn",
"react-hooks/rules-of-hooks": "error",
"react/display-name": 1,
"react/forbid-prop-types": 0,
"react/jsx-filename-extension": [
1,
{
"extensions": [
".js",
".jsx",
".ts",
".tsx"
]
}
],
"react/jsx-props-no-spreading": 0,
"react/no-array-index-key": 0,
"react/no-unescaped-entities": 0,
"react/prefer-stateless-function": 0,
"react/react-in-jsx-scope": 0,
"react/require-default-props": 0,
"simple-import-sort/sort": [
"error",
{
"groups": [
[
"^(assert|buffer|child_process|cluster|console|constants|crypto|dgram|dns|domain|events|fs|http|https|module|net|os|path|punycode|querystring|readline|repl|stream|string_decoder|sys|timers|tls|tty|url|util|vm|zlib|freelist|v8|process|async_hooks|http2|perf_hooks)(/.*|$)"
],
[
"^react",
"^@?\\w"
],
[
"^(@|assets|components|config|contexts|hooks|locales|pages|services|store|styles|utils)(/.*|$)"
],
[
"^\\u0000"
],
[
"^\\.\\.(?!/?$)",
"^\\.\\./?$"
],
[
"^\\./(?=.*/)(?!/?$)",
"^\\.(?!/?$)",
"^\\./?$"
],
[
"^.+\\.s?css$"
]
]
}
],
"space-before-function-paren": 0
},
"settings": {
"import/resolver": {
"node": {
"paths": [
"./src"
]
}
},
"react": {
"version": "detect"
}
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
5 changes: 5 additions & 0 deletions .huskyrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"hooks": {
"pre-commit": "lint-staged"
}
}
4 changes: 4 additions & 0 deletions .lintstagedrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"src/**/*.{.js,.jsx,.ts,.tsx}": "eslint --ext .js,.jsx,.ts,.tsx --max-warnings=0",
"src/**/*.{css,scss,styles.js,styles.jsx}": "stylelint"
}
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
}
29 changes: 26 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,32 @@
"repository": "https://github.com/antistatique/frontend-development-configuration",
"author": "Antistatique",
"license": "MIT",
"scripts": {
"lint:js": "eslint --ext '*/**/*.{js,jsx,ts,tsx}' --max-warnings=0"
},
"devDependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2"
"@testing-library/jest-dom": "^5.11.2",
"@testing-library/react": "^10.4.8",
"@testing-library/user-event": "^12.1.0",
"@typescript-eslint/eslint-plugin": "^3.8.0",
"@typescript-eslint/parser": "^3.8.0",
"babel-eslint": "^10.1.0",
"eslint": "^7.2.0",
"eslint-config-airbnb": "^18.1.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-html": "^6.0.2",
"eslint-plugin-import": "^2.21.2",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-prettier": "^3.1.3",
"eslint-plugin-react": "^7.20.0",
"eslint-plugin-react-hooks": "^4.0.4",
"eslint-plugin-simple-import-sort": "^5.0.3",
"husky": "^4.2.5",
"lint-staged": "^10.2.9",
"prettier": "^2.0.5",
"stylelint": "^13.6.0",
"stylelint-config-standard": "^20.0.0",
"stylelint-order": "^4.1.0",
"typescript": "^3.9.7"
}
}
11 changes: 11 additions & 0 deletions playground/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "../.eslintrc",
"rules": {
"import/no-extraneous-dependencies": [
"error",
{
"packageDir": ["./", "./playground/"]
}
]
}
}
8 changes: 8 additions & 0 deletions playground/config-overrides.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const rewireEslint = require('react-app-rewire-eslint');

module.exports = function override(config, env) {
// eslint-disable-next-line no-param-reassign
config = rewireEslint(config, env);
return config;
};
9 changes: 3 additions & 6 deletions playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,21 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@types/jest": "^24.0.0",
"@types/node": "^12.0.0",
"@types/jest": "^26.0.9",
"@types/node": "^14.0.27",
"@types/react": "^16.9.0",
"@types/react-dom": "^16.9.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-scripts": "3.4.1",
"typescript": "~3.7.2"
"typescript": "~3.9.7"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
Expand Down
1 change: 1 addition & 0 deletions playground/src/App.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { render } from '@testing-library/react';

import App from './App';

test('renders learn react link', () => {
Expand Down
40 changes: 20 additions & 20 deletions playground/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import React from 'react';

import logo from './logo.svg';

import './App.css';

function App() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.tsx</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
);
}
const App = (): JSX.Element => (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.tsx</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
);

export default App;
4 changes: 3 additions & 1 deletion playground/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';

import App from './App';
import * as serviceWorker from './serviceWorker';

import './index.css';

ReactDOM.render(
<React.StrictMode>
<App />
Expand Down

0 comments on commit fb302ae

Please sign in to comment.