add eslint and editorconfig

This commit adds a simple editorconfig generated via VSCode
and .eslintrc.json configuration created with 'npx eslint --init'.
The rules are react-specific typescript recommnedations with
the Airbnb style guide. Linting can be performed by running 'npm
run lint' or fix possible errors with 'npm run eslintfix'. These
commands are located in the pacakge.json 'scripts' configuration.
Place file extensions and directories to be ignored in .eslintignore.
This commit is contained in:
reemuru 2021-09-18 21:40:47 -05:00
parent e35f8c5e95
commit 67d236f7cf
No known key found for this signature in database
GPG Key ID: 5EDBFEFFA9E9A7AB
4 changed files with 69 additions and 7 deletions

12
.editorconfig Normal file
View File

@ -0,0 +1,12 @@
# EditorConfig is awesome: https://EditorConfig.org
# top-most EditorConfig file
root = true
[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = false
insert_final_newline = false

3
.eslintignore Normal file
View File

@ -0,0 +1,3 @@
*.css
*.svg
*.png

42
.eslintrc.json Normal file
View File

@ -0,0 +1,42 @@
{
"env": {
"browser": true,
"es2021": true
},
"extends": [
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
"airbnb"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": [
"react",
"react-hooks",
"@typescript-eslint"
],
"rules": {
"no-use-before-define": "off",
"@typescript-eslint/no-use-before-define": ["error"],
"react/jsx-filename-extension": [ "warn", {"extensions": [".tsx"]}],
"import/extensions": ["error","ignorePackages",{"ts": "never", "tsx": "never" }],
"@typescript-eslint/explicit-function-return-type": ["error",{"allowExpressions": true}],
"no-shadow": "off", "@typescript-eslint/no-shadow": ["error"],
"max-len": ["warn", { "code": 80 }],
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
"import/prefer-default-export": "off",
"react/prop-types": "off"
},
"settings": {
"import/resolver": {
"typescript": {}
}
}
}

View File

@ -22,13 +22,9 @@
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
"eject": "react-scripts eject",
"lint": "eslint src/*",
"eslintfix": "eslint src/* --fix"
},
"browserslist": {
"production": [
@ -43,6 +39,15 @@
]
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^4.31.1",
"@typescript-eslint/parser": "^4.31.1",
"eslint": "^7.32.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-import-resolver-typescript": "^2.5.0",
"eslint-plugin-import": "^2.24.2",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-react": "^7.25.2",
"eslint-plugin-react-hooks": "^4.2.0",
"monero-javascript": "^0.5.5"
}
}