From cd00f89467c3e548e2c7d90fb587eb618fbca124 Mon Sep 17 00:00:00 2001 From: Jerry Edebua Date: Thu, 27 Feb 2020 13:02:58 +0300 Subject: [PATCH] Integrate prettier into eslint --- .eslintignore | 25 ++++++++++ .eslintrc.json | 98 ++++++++++++++++++++++++++++++++++++++ .prettierignore | 24 +++++++++- package.json | 122 ++++++++++++++++++------------------------------ 4 files changed, 191 insertions(+), 78 deletions(-) create mode 100644 .eslintignore create mode 100644 .eslintrc.json diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000000..ce00366f19 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,25 @@ +*/node_modules/* +*/build/* +*/coverage/* + +*/public/* +*/views/* + +*fonts* +*logos* + +.* +*.png +*.sh +*.txt +*.snap +*.enc +Dockerfile +CHANGELOG +LICENSE + +marketing/*/* +licenses/* +certifications/* +api-docs/public/assets/* +server-monitor/out/scripts/prettify/* \ No newline at end of file diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000000..0c8fa4ec90 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,98 @@ +{ + "parserOptions": { + "ecmaVersion": 8, + "ecmaFeatures": { + "experimentalObjectRestSpread": true, + "jsx": true, + "spread": true + }, + "sourceType": "module" + }, + "env": { + "browser": true, + "node": true, + "jquery": true, + "es6": true, + "jest": true + }, + "plugins": ["react", "jsx-a11y"], + "extends": [ + "eslint:recommended", + "plugin:react/recommended", + "plugin:prettier/recommended" + ], + "parser": "babel-eslint", + "rules": { + "no-fallthrough": "error", + "no-unreachable": "error", + "no-cond-assign": "error", + "valid-typeof": "error", + "no-func-assign": "error", + "no-extra-semi": "error", + "linebreak-style": ["error", "unix"], + "no-unused-vars": [ + "error", + { + "varsIgnorePattern": "[iI]gnored", + "vars": "all", + "args": "after-used", + "ignoreRestSiblings": true, + "argsIgnorePattern": "[iI]gnored" + } + ], + "no-console": "error", + "no-undef": "error", + "no-empty": "error", + "no-case-declarations": "error", + "no-mixed-spaces-and-tabs": "error", + "no-useless-escape": "error", + "react/jsx-no-undef": "error", + "react/jsx-no-bind": [ + "error", + { + "allowArrowFunctions": true, + "allowBind": false, + "ignoreRefs": false + } + ], + "react/no-children-prop": "error", + "react/no-deprecated": "error", + "react/boolean-prop-naming": "error", + "react/no-is-mounted": "error", + "react/no-find-dom-node": "error", + "react/no-did-update-set-state": "error", + "react/no-unknown-property": "error", + "react/no-unused-prop-types": "error", + "react/jsx-no-duplicate-props": "error", + "react/no-unused-state": "error", + "react/jsx-uses-vars": "error", + "react/prop-types": "error", + "react/react-in-jsx-scope": "error", + "react/no-string-refs": "error", + "jsx-a11y/href-no-hash": [0], + "react/no-unescaped-entities": "error", + "react/display-name": [ + "error", + { + "ignoreTranspilerName": true + } + ], + "react/jsx-pascal-case": "error", + "array-callback-return": "error", + "no-loop-func": "error", + "jsx-a11y/anchor-is-valid": "error", + "prefer-const": [ + "error", + { + "destructuring": "any", + "ignoreReadBeforeAssign": false + } + ], + "no-var": "error" + }, + "settings": { + "react": { + "version": "16.5" + } + } +} diff --git a/.prettierignore b/.prettierignore index ed18bf2f38..5740dc0785 100644 --- a/.prettierignore +++ b/.prettierignore @@ -30,4 +30,26 @@ cleanup.sh *.local.sh *.local.yaml -nohup.out* \ No newline at end of file +nohup.out* + +*/public/* +*/views/* + +*fonts* +*logos* + +.* +*.png +*.sh +*.txt +*.snap +*.enc +Dockerfile +CHANGELOG +LICENSE + +marketing/*/* +licenses/* +certifications/* +api-docs/public/assets/* +server-monitor/out/scripts/prettify/* \ No newline at end of file diff --git a/package.json b/package.json index 217e70b4f5..75194615ce 100644 --- a/package.json +++ b/package.json @@ -1,80 +1,48 @@ { - "name": "app", - "version": "1.0.0", - "description": "One Complete DevOps and IT Ops platform.", - "main": "index.js", - "dependencies": {}, - "devDependencies": { - "eslint": "^6.8.0", - "eslint-plugin-jsx-a11y": "^6.2.3", - "eslint-plugin-react": "^7.17.0", - "husky": "^4.2.3", - "lint-staged": "^9.5.0", - "prettier": "^1.19.1" - }, - "scripts": { - "delete-all-local-branches": "git branch | grep -v 'master' | xargs git branch -D" - }, - "repository": { - "type": "git", - "url": "git+https://gitlab.com/fyipe-project/app.git" - }, - "keywords": [], - "author": "", - "license": "ISC", - "bugs": { - "url": "https://gitlab.com/fyipe-project/app/issues" - }, - "homepage": "https://gitlab.com/fyipe-project/app#readme", - "husky": { - "hooks": { - "pre-commit": "lint-staged" + "name": "app", + "version": "1.0.0", + "description": "One Complete DevOps and IT Ops platform.", + "main": "index.js", + "dependencies": {}, + "devDependencies": { + "babel-eslint": "^10.1.0", + "eslint": "^6.8.0", + "eslint-config-prettier": "^6.10.0", + "eslint-plugin-jsx-a11y": "^6.2.3", + "eslint-plugin-prettier": "^3.1.2", + "eslint-plugin-react": "^7.17.0", + "husky": "^4.2.3", + "lint-staged": "^9.5.0", + "prettier": "^1.19.1" + }, + "scripts": { + "delete-all-local-branches": "git branch | grep -v 'master' | xargs git branch -D", + "lint": "prettier '**/*' --write --config .prettierrc.json && eslint '**/*.js' -c .eslintrc.json --ignore-path .eslintignore --fix" + }, + "repository": { + "type": "git", + "url": "git+https://gitlab.com/fyipe-project/app.git" + }, + "keywords": [], + "author": "", + "license": "ISC", + "bugs": { + "url": "https://gitlab.com/fyipe-project/app/issues" + }, + "homepage": "https://gitlab.com/fyipe-project/app#readme", + "husky": { + "hooks": { + "pre-commit": "lint-staged" + } + }, + "lint-staged": { + "./**/*.{json,yml,yaml,md}": [ + "prettier --write --config .prettierrc.json", + "git add" + ], + "./**/*.{js}": [ + "eslint -c .eslintrc.json --ignore-path .eslintignore --fix", + "git add" + ] } - }, - "lint-staged": { - "./**/*.{js,jsx}": [ - "prettier --config .prettierrc.json --write", - "git add" - ], - "./dashboard/**/*.{js,jsx}": [ - "eslint dashboard/src -c dashboard/.eslintrc.json --ignore-path dashboard/.eslintignore", - "git add" - ], - "./backend/**/*.js": [ - "eslint backend/backend -c backend/.eslintrc.json --ignore-path backend/.eslintignore", - "git add" - ], - "./accounts/**/*.{js,jsx}": [ - "eslint accounts/src -c accounts/.eslintrc.json --ignore-path accounts/.eslintignore", - "git add" - ], - "./admin-dashboard/**/*.{js,jsx}": [ - "eslint admin-dashboard/src -c admin-dashboard/.eslintrc.json --ignore-path admin-dashboard/.eslintignore", - "git add" - ], - "./home/**/*.{js}": [ - "eslint home -c home/.eslintrc.json --ignore-path home/.eslintignore", - "git add" - ], - "./probe/**/*.{js}": [ - "eslint probe -c probe/.eslintrc.json --ignore-path probe/.eslintignore", - "git add" - ], - "./status-page/**/*.{js,jsx}": [ - "eslint status-page/src -c status-page/.eslintrc.json --ignore-path status-page/.eslintignore", - "git add" - ], - "./zapier/**/*.{js,jsx}": [ - "eslint zapier -c zapier/.eslintrc.json --ignore-path zapier/.eslintignore", - "git add" - ], - "./server-monitor/**/*.{js,jsx}": [ - "eslint server-monitor/lib -c server-monitor/.eslintrc.json --ignore-path server-monitor/.eslintignore", - "git add" - ], - "./http-test-server/**/*.{js,jsx}": [ - "eslint -c http-test-server/.eslintrc.json --ignore-path http-test-server/.eslintignore", - "git add" - ] - } }