Skip to content

Commit

Permalink
Add Husky Custom ESlint and Prettier setup for Nx Workspace.
Browse files Browse the repository at this point in the history
  • Loading branch information
serifcolakel committed Mar 25, 2024
1 parent 2f5bb4e commit 681dfc1
Show file tree
Hide file tree
Showing 7 changed files with 1,267 additions and 38 deletions.
136 changes: 135 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,141 @@
{
"root": true,
"ignorePatterns": ["**/*"],
"plugins": ["@nx"],
"plugins": [
"@nx",
"react",
"@typescript-eslint",
"prettier",
"simple-import-sort",
"import"
],
"extends": [
"airbnb",
"airbnb-typescript",
"airbnb/hooks",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module",
"project": "./tsconfig.base.json"
},
"rules": {
"simple-import-sort/imports": "error",
"import/no-extraneous-dependencies": "off",
"import/no-named-as-default": "off",
"react/react-in-jsx-scope": "off",
"linebreak-style": "error",
"react/jsx-props-no-spreading": "off",
"no-console": "error",
"no-var": "error",
"react/jsx-sort-props": [
"error",
{
"shorthandFirst": true
}
],
"@typescript-eslint/no-floating-promises": "off",
"react/jsx-one-expression-per-line": "off",
"spaced-comment": ["error", "always"],
"eqeqeq": ["error", "smart"],
"no-else-return": "error",
"no-empty-function": "error",
"react/require-default-props": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/ban-ts-ignore": "off",
"max-len": [
"error",
{
"code": 120
}
],
"consistent-return": "off",
"array-callback-return": "warn",
"import/prefer-default-export": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/prefer-optional-chain": "error",
"@typescript-eslint/no-loss-of-precision": "off",
"react/button-has-type": "off",
"no-plusplus": "off",
"no-param-reassign": "off",
"@typescript-eslint/no-misused-promises": [
2,
{
"checksVoidReturn": {
"attributes": false
}
}
],
"padding-line-between-statements": [
"error",
{
"blankLine": "always",
"prev": "*",
"next": "return"
},
{
"blankLine": "always",
"prev": ["const", "let", "import"],
"next": "*"
},
{
"blankLine": "any",
"prev": ["import"],
"next": ["import"]
},
{
"blankLine": "never",
"prev": ["const", "let"],
"next": ["const", "let"]
},
{
"blankLine": "always",
"prev": ["multiline-const", "multiline-let"],
"next": ["*"]
},
{
"blankLine": "always",
"prev": ["*"],
"next": ["multiline-const", "multiline-let"]
},
{
"blankLine": "always",
"prev": ["*"],
"next": ["if", "switch", "for", "while", "try", "function", "class"]
},
{
"blankLine": "always",
"prev": ["if", "switch", "for", "while", "try", "function", "class"],
"next": ["*"]
},
{
"blankLine": "never",
"prev": ["case"],
"next": ["case"]
}
],
"object-curly-spacing": [
"error",
"always",
{
"objectsInObjects": true,
"arraysInObjects": true
}
],
"array-bracket-spacing": [
"error",
"always",
{
"objectsInArrays": true,
"arraysInArrays": false
}
]
},
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
Expand Down
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

pnpm run lint
13 changes: 12 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,16 @@
"activityBar.background": "#0C3049",
"titleBar.activeBackground": "#104367",
"titleBar.activeForeground": "#F6FAFE"
}
},
"editor.codeActionsOnSave": {
"source.fixAll": "explicit",
"source.fixAll.eslint": "explicit"
},
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact"
],
"eslint.format.enable": true
}
Loading

0 comments on commit 681dfc1

Please sign in to comment.