Skip to content

Commit

Permalink
Added eslint and husky (config based on neo4j/nx repository)
Browse files Browse the repository at this point in the history
  • Loading branch information
“Bastien committed Dec 9, 2022
1 parent 7d7aff7 commit a3e829f
Show file tree
Hide file tree
Showing 8 changed files with 1,159 additions and 36 deletions.
162 changes: 162 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
{
"extends": ["eslint:recommended", "prettier"],
"plugins": ["react"],
"parser": "@babel/eslint-parser",
"env": {
"browser": true,
"node": true
},
"settings": {
"react": {
"version": "detect"
}
},
"ignorePatterns": ["node_modules/**", "packages/**/dist/**", "packages/**/coverage/**"],
"rules": {
"array-callback-return": "error",
"arrow-body-style": "off",
"block-scoped-var": "error",
"camelcase": "error",
"consistent-return": "error",
"consistent-this": ["error", "self"],
"constructor-super": "error",
"curly": ["error", "all"],
"default-case": "error",
"default-param-last": "error",
"dot-notation": "error",
"eqeqeq": "error",
"func-names": "error",
"func-style": [
"error",
"declaration",
{
"allowArrowFunctions": true
}
],
"grouped-accessor-pairs": "error",
"line-comment-position": "error",
"lines-between-class-members": "error",
"max-depth": "error",
"max-len": [
"error",
{
"code": 120,
"comments": 120,
"ignoreUrls": true,
"ignoreTemplateLiterals": true
}
],
"max-lines-per-function": ["off"],
"max-nested-callbacks": ["error", 5],
"max-statements": ["off"],
"max-statements-per-line": "error",
"no-alert": "error",
"no-array-constructor": "error",
"no-await-in-loop": "error",
"no-buffer-constructor": "error",
"no-caller": "error",
"no-confusing-arrow": "error",
"no-console": "warn",
"no-constructor-return": "error",
"no-constant-condition": "error",
"no-debugger": "warn",
"no-dupe-else-if": "error",
"no-else-return": "error",
"no-empty-function": [
"error",
{
"allow": ["constructors"]
}
],
"no-eq-null": "error",
"no-eval": "error",
"no-extend-native": "error",
"no-extra-bind": "error",
"no-extra-label": "error",
"no-implicit-coercion": "error",
"no-implicit-globals": "error",
"no-implied-eval": "error",
"no-import-assign": "error",
"no-invalid-this": "off",
"no-iterator": "error",
"no-labels": "error",
"no-lone-blocks": "error",
"no-lonely-if": "error",
"no-loop-func": "error",
"no-magic-numbers": "off",
"no-multi-assign": "error",
"no-multi-str": "error",
"no-nested-ternary": "error",
"no-new": "error",
"no-new-func": "error",
"no-new-object": "error",
"no-new-wrappers": "error",
"no-octal-escape": "error",
"no-param-reassign": "error",
"no-path-concat": "error",
"no-plusplus": [
"error",
{
"allowForLoopAfterthoughts": true
}
],
"no-proto": "error",
"no-restricted-globals": "error",
"no-return-assign": "error",
"no-return-await": "error",
"no-self-compare": "error",
"no-sequences": "error",
"no-setter-return": "error",
"no-sync": "error",
"no-tabs": "error",
"no-template-curly-in-string": "error",
"no-underscore-dangle": "error",
"no-unmodified-loop-condition": "error",
"no-unneeded-ternary": "error",
"no-unreachable": "error",
"no-unused-expressions": "error",
"no-useless-call": "error",
"no-useless-computed-key": "error",
"no-useless-concat": "error",
"no-useless-rename": "error",
"no-useless-return": "error",
"no-var": "error",
"no-void": ["error", { "allowAsStatement": true }],
"one-var": ["error", "never"],
"operator-assignment": "error",
"padding-line-between-statements": "error",
"prefer-arrow-callback": "warn",
"prefer-const": "warn",
"prefer-destructuring": [
"warn",
{
"VariableDeclarator": {
"array": true,
"object": true
},
"AssignmentExpression": {
"array": false,
"object": false
}
}
],
"prefer-numeric-literals": "warn",
"prefer-promise-reject-errors": "warn",
"prefer-rest-params": "warn",
"prefer-spread": "warn",
"prefer-template": "warn",
"radix": "error",
"require-atomic-updates": "error",
"require-await": "error",
"sort-keys": "off",
"spaced-comment": [
"warn",
"always",
{
"markers": ["/"]
}
],
"symbol-description": "error",
"yoda": "error"
}
}
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn run lint-staged
6 changes: 6 additions & 0 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"*.ts": ["prettier --write", "eslint --fix --max-warnings 0"],
"*.tsx": ["prettier --write", "eslint --fix --max-warnings 0"],
"*.json": ["prettier --write"],
"*.js": ["prettier --write"]
}
13 changes: 3 additions & 10 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
*.babelrc
*.json
*.html
*.css
*.yml
*.git
*.svn
*.hg
*.md
./node_modules
coverage
dist
node_modules
2 changes: 1 addition & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
"trailingComma": "all",
"bracketSpacing": true,
"endOfLine": "lf"
}
}
6 changes: 0 additions & 6 deletions gallery/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
Expand Down
13 changes: 12 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
"dev": "yarn webpack-dev-server --mode development",
"debug": "yarn --node-options='--inspect' webpack-dev-server --mode development",
"build": "yarn webpack --mode production && cp -r public/* dist/",
"format": "prettier --write \"**/*.{ts,tsx}\"",
"lint-staged": "lint-staged --config .lintstagedrc.json",
"prepare": "husky install",
"test": "yarn cypress open",
"test-headless": "yarn cypress run"
},
Expand Down Expand Up @@ -57,7 +60,6 @@
"lodash.isequal": "^4.5.0",
"material-ui-color-picker": "^3.5.1",
"neo4j-client-sso": "^1.2.2",
"prettier": "^2.7.1",
"react": "^17.0.2",
"react-cool-dimensions": "^2.0.7",
"react-dom": "^17.0.2",
Expand All @@ -79,6 +81,7 @@
"devDependencies": {
"@babel/cli": "^7.16.8",
"@babel/core": "^7.16.12",
"@babel/eslint-parser": "^7.19.1",
"@babel/plugin-transform-runtime": "^7.16.10",
"@babel/preset-env": "^7.16.11",
"@babel/preset-react": "^7.16.7",
Expand All @@ -90,7 +93,15 @@
"babel-loader": "^8.2.3",
"css-loader": "^3.6.0",
"cypress": "^9.5.3",
"eslint": "^8.26.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-react": "^7.30.1",
"eslint-plugin-react-hooks": "^4.6.0",
"file-loader": "^6.2.0",
"husky": "^8.0.1",
"lint-staged": "^13.0.3",
"prettier": "^2.7.1",
"react-hot-loader": "^4.13.0",
"serverless-finch": "^4.0.0",
"source-map-loader": "^4.0.0",
Expand Down
Loading

0 comments on commit a3e829f

Please sign in to comment.