Skip to content

Commit

Permalink
chore: ESlint configuration
Browse files Browse the repository at this point in the history
Adds specify rules to ESlint
Adds react and import plugins to ESlint

Part of #16
  • Loading branch information
rfgvieira committed Jun 26, 2024
1 parent aa63399 commit 4404758
Show file tree
Hide file tree
Showing 4 changed files with 824 additions and 12 deletions.
126 changes: 115 additions & 11 deletions dashboard/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,123 @@ module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
'plugin:storybook/recommended',
'plugin:@tanstack/eslint-plugin-query/recommended'
"eslint:recommended",
"plugin:@tanstack/eslint-plugin-query/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/typescript",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"plugin:storybook/recommended",
],
ignorePatterns: [".eslintrc.cjs", "*.config.js"],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaFeatures: {
jsx: true,
},
requireConfigFile: false,
ecmaVersion: 2021,
sourceType: "module",
project: ["./tsconfig.app.json", "./tsconfig.node.json"],
tsconfigRootDir: __dirname,
},
settings: {
react: {
version: "detect",
},
},
plugins: [
"react-refresh",
"import",
"react",
"react-hooks",
"@typescript-eslint",
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
"no-duplicate-imports": "warn",
"no-magic-numbers": [
"error",
{
detectObjects: false,
ignore: [-1, 0, 1, 2],
ignoreArrayIndexes: true,
ignoreDefaultValues: true,
},
],
"no-restricted-imports": [
"error",
{
patterns: ["../../*"],
},
],
"no-shadow": "off",
"no-underscore-dangle": ["error", { allow: ["__typename"] }],
"no-unused-vars": "off",
"no-use-before-define": "off",
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
],
"@typescript-eslint/prefer-optional-chain": "warn",
"@typescript-eslint/consistent-type-imports": "warn",
"@typescript-eslint/explicit-function-return-type": "warn",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-inferrable-types": "warn",
"@typescript-eslint/no-shadow": ["warn", { ignoreTypeValueShadow: true }],
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
},
],
"import/extensions": [
"error",
"ignorePackages",
{
js: "never",
jsx: "never",
ts: "never",
tsx: "never",
},
],
"import/no-cycle": ["error", { ignoreExternal: true }],
"import/no-extraneous-dependencies": [
"error",
{
devDependencies: [
"**/*{.,_}{test,spec}.{ts,tsx}",
".storybook/**",
"src/stories/**",
],
},
],
"import/order": [
"error",
{
groups: [
["builtin", "external"],
"internal",
"parent",
["index", "sibling"],
],
"newlines-between": "always-and-inside-groups",
},
],
"import/prefer-default-export": "off",
"react-hooks/exhaustive-deps": "warn",
"react-hooks/rules-of-hooks": "error",
"react/destructuring-assignment": "off",
"react/jsx-filename-extension": [
"error",
{
extensions: [".tsx"],
},
],
"react/jsx-key": ["error", { checkFragmentShorthand: true }],
"react/jsx-props-no-spreading": "off",
"react/prop-types": "off",
"react/react-in-jsx-scope": "off",
"react/require-default-props": "off",
},
}
};
3 changes: 3 additions & 0 deletions dashboard/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ dist-ssr
*.sw?

*storybook.log

# eslint cache
.eslintcache
4 changes: 3 additions & 1 deletion dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"build": "tsc -b && vite build",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build",
"lint": "eslint **/*.tsx **/*.ts --report-unused-disable-directives --max-warnings 0",
"lint": "eslint --cache --max-warnings=0 --ext .ts,.tsx,.js,.jsx src --fix",
"preview": "vite preview",
"prepare": "cd .. && husky dashboard/.husky",
"pycommit": "cd .. && cd backend && sh pre-commit",
Expand Down Expand Up @@ -46,6 +46,8 @@
"@vitejs/plugin-react": "^4.3.1",
"autoprefixer": "^10.4.19",
"eslint": "^8.57.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-react": "^7.34.3",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-react-refresh": "^0.4.7",
"eslint-plugin-storybook": "^0.8.0",
Expand Down
Loading

0 comments on commit 4404758

Please sign in to comment.