From 11008d279d4897b2f130b4ec96ad08192d40bb66 Mon Sep 17 00:00:00 2001 From: "mirlan.maksitaliev" Date: Tue, 2 Jun 2020 16:05:41 +0600 Subject: [PATCH] chore: eslint configuration --- .eslintignore | 4 +++ .eslintrc | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 15 ++++++--- 3 files changed, 99 insertions(+), 4 deletions(-) create mode 100644 .eslintignore create mode 100644 .eslintrc diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 00000000..e56874cc --- /dev/null +++ b/.eslintignore @@ -0,0 +1,4 @@ +src/types/* +src/api/operations/*/operation.tsx +src/react-app-env.d.ts +src/serviceWorker.ts diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 00000000..d821bc4b --- /dev/null +++ b/.eslintrc @@ -0,0 +1,84 @@ +{ + "extends": [ + "eslint:recommended", + "plugin:react/recommended", + "airbnb", + "react-app" + ], + "plugins": [ + "sort-destructure-keys", + "typescript-sort-keys", + "postro4no" + ], + "rules": { + "@typescript-eslint/array-type": [ + "warn", + { "default" : "generic" } + ], + "@typescript-eslint/indent": ["warn", 2], + "@typescript-eslint/member-delimiter-style": ["warn", { + "multiline": { + "delimiter": "comma", + "requireLast": true + }, + "singleline": { + "delimiter": "comma", + "requireLast": false + } + }], + "import/extensions": [ + "warn", + "never", + { + "svg": "always", + "css": "always", + "scss": "always" + } + ], + "import/no-duplicates": "warn", + "import/no-extraneous-dependencies": [ + "warn", + { "devDependencies": ["src/setupTests.ts"] } + ], + "jsx-quotes": [ + "warn", + "prefer-single" + ], + "no-param-reassign": [ + "warn", + { + "props": true, + "ignorePropertyModificationsFor": ["self", "acc"] + } + ], + "postro4no/function-args": "warn", + "postro4no/import": "warn", + "postro4no/object-props": "warn", + "react/jsx-filename-extension": [ + "warn", + { "extensions": [".tsx"] } + ], + "react/jsx-indent": ["warn", 2], + "sort-destructure-keys/sort-destructure-keys": [ + 1, + { "caseSensitive": false } + ], + "sort-keys": [ + "warn", + "asc", { + "caseSensitive": true, + "natural": true + } + ], + "typescript-sort-keys/interface": 1, + "typescript-sort-keys/string-enum": 1, + + "camelcase": "off", + "import/no-unresolved": "off", + "import/prefer-default-export": "off", + "indent": "off", + "no-unused-vars": "off", + "react/jsx-one-expression-per-line": "off", + "semi": "off" + } +} diff --git a/package.json b/package.json index f1c2b61c..3dc0a6bc 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,8 @@ "build": "GENERATE_SOURCEMAP=false react-scripts build && gzipper --verbose ./build", "test": "react-scripts test --passWithNoTests --watchAll=false", "eject": "react-scripts eject", - "generate": "graphql-codegen --config codegen.yml" + "generate": "graphql-codegen --config codegen.yml", + "lint": "eslint 'src/**/*.{ts,tsx}'" }, "dependencies": { "@apollo/react-common": "^3.1.4", @@ -38,13 +39,19 @@ "@types/react": "^16.9.0", "@types/react-dom": "^16.9.0", "commitizen": "^4.1.2", + "eslint": "6.8.0", + "eslint-config-airbnb": "18.1.0", + "eslint-plugin-import": "^2.20.1", + "eslint-plugin-jsx-a11y": "^6.2.3", + "eslint-plugin-postro4no": "^0.0.7", + "eslint-plugin-react": "^7.19.0", + "eslint-plugin-react-hooks": "2.5.0", + "eslint-plugin-sort-destructure-keys": "^1.3.4", + "eslint-plugin-typescript-sort-keys": "^1.2.0", "gzipper": "^3.7.0", "husky": "^4.2.5", "typescript": "^3.9.3" }, - "eslintConfig": { - "extends": "react-app" - }, "config": { "commitizen": { "path": "./node_modules/cz-conventional-changelog"