From ce99800f0f355f01e975a94d04c8f0fa4401320f Mon Sep 17 00:00:00 2001 From: Hassan Abouelela <47495861+HassanAbouelela@users.noreply.github.com> Date: Wed, 10 Feb 2021 16:04:03 +0300 Subject: Migrate Husky To v5 Signed-off-by: Hassan Abouelela <47495861+HassanAbouelela@users.noreply.github.com> --- .config/eslint/annotations_formatter.js | 14 ++++++++++++++ .config/husky/.gitignore | 1 + .config/husky/pre-commit | 4 ++++ .github/workflows/test_and_lint.yml | 2 +- README.md | 3 ++- annotations_formatter.js | 14 -------------- package.json | 8 ++------ 7 files changed, 24 insertions(+), 22 deletions(-) create mode 100644 .config/eslint/annotations_formatter.js create mode 100644 .config/husky/.gitignore create mode 100644 .config/husky/pre-commit delete mode 100644 annotations_formatter.js diff --git a/.config/eslint/annotations_formatter.js b/.config/eslint/annotations_formatter.js new file mode 100644 index 0000000..b3a421d --- /dev/null +++ b/.config/eslint/annotations_formatter.js @@ -0,0 +1,14 @@ +module.exports = function (results) { + let output = ""; + + for (const file of results.filter(r => r.messages.length > 0)) { + for (const message of file.messages) { + const path = file.filePath.substr(process.cwd().length + 1); + const severity = message.fatal || message.severity === 2 ? "error" : "warning"; + const text = `[ESLint] ${message.ruleId}: ${message.message}`; + output += `::${severity} file=${path},line=${message.line},col=${message.column}::${text}\n`; + } + } + + return output; +}; diff --git a/.config/husky/.gitignore b/.config/husky/.gitignore new file mode 100644 index 0000000..c9cdc63 --- /dev/null +++ b/.config/husky/.gitignore @@ -0,0 +1 @@ +_ \ No newline at end of file diff --git a/.config/husky/pre-commit b/.config/husky/pre-commit new file mode 100644 index 0000000..101f7b9 --- /dev/null +++ b/.config/husky/pre-commit @@ -0,0 +1,4 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +yarn lint \ No newline at end of file diff --git a/.github/workflows/test_and_lint.yml b/.github/workflows/test_and_lint.yml index 4767b3e..83e5cc1 100644 --- a/.github/workflows/test_and_lint.yml +++ b/.github/workflows/test_and_lint.yml @@ -44,4 +44,4 @@ jobs: run: yarn install - name: Lint - run: yarn run eslint --ext .ts,.tsx --format ./annotations_formatter.js src/ + run: yarn run eslint --ext .ts,.tsx --format .config/eslint/annotations_formatter.js src/ diff --git a/README.md b/README.md index b19152f..0f42f95 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,8 @@ The project uses [yarn](https://yarnpkg.com/) for dependency and script manageme and [webpack](https://webpack.js.org/) for building and development. A full setup guide is available on [Notion](https://www.notion.so/pythondiscord/Forms-6312360495ff45f487da5b1924184a2d), -along with a troubleshooting guide. +along with a troubleshooting guide.
+Run `yarn install --dev` and `yarn run pre-commit` to setup your dev environment. ## React & Dependency Info ### Project Info diff --git a/annotations_formatter.js b/annotations_formatter.js deleted file mode 100644 index b3a421d..0000000 --- a/annotations_formatter.js +++ /dev/null @@ -1,14 +0,0 @@ -module.exports = function (results) { - let output = ""; - - for (const file of results.filter(r => r.messages.length > 0)) { - for (const message of file.messages) { - const path = file.filePath.substr(process.cwd().length + 1); - const severity = message.fatal || message.severity === 2 ? "error" : "warning"; - const text = `[ESLint] ${message.ruleId}: ${message.message}`; - output += `::${severity} file=${path},line=${message.line},col=${message.column}::${text}\n`; - } - } - - return output; -}; diff --git a/package.json b/package.json index baa257e..cbf8293 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,8 @@ "start": "webpack serve --node-env=development", "build": "webpack", "test": "jest", - "lint": "eslint --cache src/" + "lint": "eslint --cache src/", + "pre-commit": "husky install .config/husky" }, "eslintConfig": { "extends": "react-app" @@ -76,10 +77,5 @@ "jest-svg-transformer": "1.0.0", "jest-watch-typeahead": "0.6.1", "webpack-dev-server": "3.11.2" - }, - "husky": { - "hooks": { - "pre-commit": "yarn lint" - } } } -- cgit v1.2.3