From 8c7ce90b4d2e4c36ae209707a2ad8e7b07c0ade1 Mon Sep 17 00:00:00 2001 From: Chika Date: Sun, 8 May 2022 15:24:05 +0300 Subject: [PATCH] code-style: add eslint rules & prettier --- .eslintignore | 7 ++++++ .eslintrc.json | 42 +++++++++++++++++++++++++++++++++- .prettierrc | 18 +++++++++++++++ .vscode/settings.json | 4 +++- next.config.js | 1 + package.json | 6 +++++ yarn.lock | 53 +++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 129 insertions(+), 2 deletions(-) create mode 100644 .eslintignore create mode 100644 .prettierrc diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..c1d7a54 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,7 @@ +.next +public +node_modules +yarn.lock +package-lock.json +**/*.test.js +coverage \ No newline at end of file diff --git a/.eslintrc.json b/.eslintrc.json index bffb357..7d18ed1 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,3 +1,43 @@ { - "extends": "next/core-web-vitals" + "env": { + "browser": true, + "es2021": true, + "node": true + }, + "extends": ["next", "prettier", "airbnb"], + "parserOptions": { + "ecmaFeatures": { + "jsx": true + }, + "ecmaVersion": 12, + "sourceType": "module" + }, + "plugins": ["react", "prettier"], + "rules": { + "linebreak-style": ["error", "windows"], + "comma-dangle": "off", + "react/react-in-jsx-scope": "off", + "react/jsx-props-no-spreading": "off", + "react/jsx-filename-extension": [ + 2, + { "extensions": [".js", ".jsx", ".ts", ".tsx"] } + ], + "react/forbid-prop-types": "off", + "react/require-default-props": [ + "error", + { + "ignoreFunctionalComponents": true + } + ], + "import/extensions": "off", + "object-curly-newline": [ + "error", + { + "ObjectExpression": "always", + "ObjectPattern": { "multiline": true }, + "ImportDeclaration": "never", + "ExportDeclaration": { "multiline": true, "minProperties": 3 } + } + ] + } } diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..26ad837 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,18 @@ +{ + "endOfLine": "auto", + "arrowParens": "always", + "bracketSpacing": true, + "htmlWhitespaceSensitivity": "ignore", + "insertPragma": false, + "jsxBracketSameLine": false, + "jsxSingleQuote": false, + "printWidth": 80, + "proseWrap": "preserve", + "quoteProps": "as-needed", + "requirePragma": false, + "semi": true, + "singleQuote": true, + "tabWidth": 2, + "trailingComma": "es5", + "useTabs": false +} diff --git a/.vscode/settings.json b/.vscode/settings.json index 1d92916..040b005 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -9,10 +9,12 @@ "**/node_modules": true }, "explorerExclude.backup": null, + + "editor.defaultFormatter": "esbenp.prettier-vscode", "editor.formatOnSave": true, "editor.codeActionsOnSave": { "source.organizeImports": true, - "source.fixAll": true + "source.fixAll.eslint": true }, "workbench.editor.labelFormat": "short" } diff --git a/next.config.js b/next.config.js index b56a6bd..ba20707 100644 --- a/next.config.js +++ b/next.config.js @@ -5,6 +5,7 @@ const withGraphQL = require('next-plugin-graphql'); /** @type {import('next').NextConfig} */ const nextConfig = { reactStrictMode: true, + eslint: { ignoreDuringBuilds: true }, compiler: { styledComponents: true, }, diff --git a/package.json b/package.json index 9b48920..da4665c 100644 --- a/package.json +++ b/package.json @@ -7,10 +7,12 @@ "build": "next build", "start": "next start", "lint": "next lint", + "lint:fix": "next lint --fix", "graphql:codegen": "apollo client:codegen --target typescript", "graphql:schema": "apollo client:download-schema services/crm/graphql/schema.graphql" }, "dependencies": { + "@ant-design/icons": "^4.7.0", "@apollo/client": "^3.6.0", "antd": "^4.19.5", "axios": "^0.26.1", @@ -39,8 +41,12 @@ "@types/styled-components": "^5.1.25", "apollo": "^2.33.10", "eslint": "8.13.0", + "eslint-config-airbnb": "^19.0.4", "eslint-config-next": "12.1.5", + "eslint-config-prettier": "^8.5.0", + "eslint-plugin-prettier": "^4.0.0", "msw": "^0.39.2", + "prettier": "2.6.2", "typescript": "4.6.3" }, "msw": { diff --git a/yarn.lock b/yarn.lock index ec2aad1..6bac504 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1993,6 +1993,11 @@ concat-map@0.0.1: resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= +confusing-browser-globals@^1.0.10: + version "1.0.11" + resolved "https://registry.yarnpkg.com/confusing-browser-globals/-/confusing-browser-globals-1.0.11.tgz#ae40e9b57cdd3915408a2805ebd3a5585608dc81" + integrity sha512-JsPKdmh8ZkmnHxDk55FZ1TqVLvEQTvoByJZRN9jzI0UjxK/QgAmsphz7PGtqgPieQZ/CQcHWXCR7ATDNhGe+YA== + console-control-strings@^1.0.0, console-control-strings@~1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/console-control-strings/-/console-control-strings-1.1.0.tgz#3d7cf4464db6446ea644bf4b39507f9851008e8e" @@ -2372,6 +2377,25 @@ escape-string-regexp@4.0.0, escape-string-regexp@^4.0.0: resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== +eslint-config-airbnb-base@^15.0.0: + version "15.0.0" + resolved "https://registry.yarnpkg.com/eslint-config-airbnb-base/-/eslint-config-airbnb-base-15.0.0.tgz#6b09add90ac79c2f8d723a2580e07f3925afd236" + integrity sha512-xaX3z4ZZIcFLvh2oUNvcX5oEofXda7giYmuplVxoOg5A7EXJMrUyqRgR+mhDhPK8LZ4PttFOBvCYDbX3sUoUig== + dependencies: + confusing-browser-globals "^1.0.10" + object.assign "^4.1.2" + object.entries "^1.1.5" + semver "^6.3.0" + +eslint-config-airbnb@^19.0.4: + version "19.0.4" + resolved "https://registry.yarnpkg.com/eslint-config-airbnb/-/eslint-config-airbnb-19.0.4.tgz#84d4c3490ad70a0ffa571138ebcdea6ab085fdc3" + integrity sha512-T75QYQVQX57jiNgpF9r1KegMICE94VYwoFQyMGhrvc+lB8YF2E/M/PYDaQe1AJcWaEgqLE+ErXV1Og/+6Vyzew== + dependencies: + eslint-config-airbnb-base "^15.0.0" + object.assign "^4.1.2" + object.entries "^1.1.5" + eslint-config-next@12.1.5: version "12.1.5" resolved "https://registry.yarnpkg.com/eslint-config-next/-/eslint-config-next-12.1.5.tgz#658cc61194a32dfd917a3db199351396ea5db1d1" @@ -2387,6 +2411,11 @@ eslint-config-next@12.1.5: eslint-plugin-react "7.29.1" eslint-plugin-react-hooks "4.3.0" +eslint-config-prettier@^8.5.0: + version "8.5.0" + resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-8.5.0.tgz#5a81680ec934beca02c7b1a61cf8ca34b66feab1" + integrity sha512-obmWKLUNCnhtQRKc+tmnYuQl0pFU1ibYJQ5BGhTVB08bHe9wC8qUeG7c08dj9XX+AuPj1YSGSQIHl1pnDHZR0Q== + eslint-import-resolver-node@0.3.4: version "0.3.4" resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.4.tgz#85ffa81942c25012d8231096ddf679c03042c717" @@ -2459,6 +2488,13 @@ eslint-plugin-jsx-a11y@6.5.1: language-tags "^1.0.5" minimatch "^3.0.4" +eslint-plugin-prettier@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-4.0.0.tgz#8b99d1e4b8b24a762472b4567992023619cb98e0" + integrity sha512-98MqmCJ7vJodoQK359bqQWaxOE0CS8paAz/GgjaZLyex4TTk3g9HugoO89EqWCrFiOqn9EVvcoo7gZzONCWVwQ== + dependencies: + prettier-linter-helpers "^1.0.0" + eslint-plugin-react-hooks@4.3.0: version "4.3.0" resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.3.0.tgz#318dbf312e06fab1c835a4abef00121751ac1172" @@ -2632,6 +2668,11 @@ fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== +fast-diff@^1.1.2: + version "1.2.0" + resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.2.0.tgz#73ee11982d86caaf7959828d519cfe927fac5f03" + integrity sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w== + fast-glob@^3.2.9: version "3.2.11" resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.11.tgz#a1172ad95ceb8a16e20caa5c5e56480e5129c1d9" @@ -4407,6 +4448,18 @@ prelude-ls@^1.2.1: resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g== +prettier-linter-helpers@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz#d23d41fe1375646de2d0104d3454a3008802cf7b" + integrity sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w== + dependencies: + fast-diff "^1.1.2" + +prettier@2.6.2: + version "2.6.2" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.6.2.tgz#e26d71a18a74c3d0f0597f55f01fb6c06c206032" + integrity sha512-PkUpF+qoXTqhOeWL9fu7As8LXsIUZ1WYaJiY/a7McAQzxjk82OF0tibkFXVCDImZtWxbvojFjerkiLb0/q8mew== + process-nextick-args@~2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2"