From 3625d5a4bb1bb1dda2321e22a1b79719e7f50bbc Mon Sep 17 00:00:00 2001 From: Lisa Date: Sun, 19 Sep 2021 14:11:59 +0000 Subject: [PATCH] Install husky and prettier to format staged files --- .eslintrc.js | 23 +++-------------------- .husky/pre-commit | 4 ++++ .prettierrc.js | 6 ++---- package.json | 6 +++++- 4 files changed, 14 insertions(+), 25 deletions(-) create mode 100755 .husky/pre-commit diff --git a/.eslintrc.js b/.eslintrc.js index 614a09b..16c909c 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,9 +1,6 @@ module.exports = { root: true, - extends: [ - 'eslint:recommended', - 'plugin:react/recommended', - ], + extends: ['eslint:recommended', 'plugin:react/recommended'], env: { node: true, mocha: true, @@ -24,23 +21,9 @@ module.exports = { }, }, rules: { - indent: ['error', 2], - 'no-console': ['error', { 'allow': ['warn', 'error'] }], - 'space-before-function-paren': 0, - semi: ['warn', 'never'], - 'space-infix-ops': ['warn'], + 'no-console': ['error', { allow: ['warn', 'error'] }], 'no-var': 'error', 'prefer-const': 'error', - 'no-trailing-spaces': 'error', 'react/prop-types': 2, - 'max-len': [ - 1, - { - 'ignoreStrings': true, - 'ignoreComments': true, - 'ignoreTemplateLiterals': true - } - ], - 'no-multi-spaces': 2, }, -}; +} diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 0000000..35d6918 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +npx pretty-quick --staged diff --git a/.prettierrc.js b/.prettierrc.js index 5c4de1a..3f714ac 100644 --- a/.prettierrc.js +++ b/.prettierrc.js @@ -1,6 +1,4 @@ module.exports = { - bracketSpacing: false, - jsxBracketSameLine: true, singleQuote: true, - trailingComma: 'all', -}; + semi: false, +} diff --git a/package.json b/package.json index 9e91160..f501c08 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,8 @@ "update-changelog": "node ./tools/bin/update-changelog.js", "release": "node ./tools/release-wizard.js", "clear": ". scripts/clear.sh", - "postinstall": "npx jetify" + "postinstall": "npx jetify", + "prepare": "husky install" }, "dependencies": { "@ptomasroos/react-native-multi-slider": "^2.2.0", @@ -72,12 +73,15 @@ "dirty-chai": "^2.0.1", "eslint": "^6.4.0", "eslint-plugin-react": "^7.8.2", + "husky": "^6.0.0", "jase": "^1.2.0", "jest": "^24.9.0", "jetifier": "^1.6.6", "left-pad": "^1.3.0", "metro-react-native-babel-preset": "^0.56.0", "mocha": "^5.2.0", + "prettier": "2.4.0", + "pretty-quick": "^3.1.1", "react-native-version": "^3.1.0", "react-test-renderer": "16.9.0", "readline": "^1.3.0"