Skip to content

Commit

Permalink
Configure Husky and Prettier formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
rusiruavb committed Jan 5, 2022
1 parent 3dbdf42 commit 27328c1
Show file tree
Hide file tree
Showing 14 changed files with 1,168 additions and 299 deletions.
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
build
dist/*
.idea/*
.vscode
node_modules/*
25 changes: 25 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"env": {
"es2021": true,
"node": true
},
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"sourceType": "module"
},
"plugins": ["@typescript-eslint"],
"rules": {
"indent": ["error", "tab"],
"linebreak-style": ["error", "windows"],
"quotes": ["error", "double"],
"semi": ["error", "always"],
"@typescript-eslint/no-explicit-any": "off",
"no-const-assign": "error",
"max-len": ["warn", { "code": 120, "ignoreUrls": true, "ignoreRegExpLiterals": true }],
"no-unused-vars": "error",
"no-console": "error",
"no-duplicate-imports": ["error", { "includeExports": true }],
"default-case": "error"
}
}
38 changes: 38 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

echo '๐Ÿ—๏ธ๐Ÿ‘ท Hi, my name is Bob. I am responsible for styling, testing and building your project before commit'

# Check Prettier standards
npm run check-format ||
(
echo '๐Ÿคข๐Ÿคฎ Prettier Check Failed. Your code styling not looking good. ๐Ÿคข๐Ÿคฎ Run npm run format, add changes and try commit again.';
false;
)

# Check ESLint Standards
npm run check-lint ||
(
echo '๐Ÿ˜ค๐Ÿ€ ESLint Check Failed. Your code may have some linting issues. ๐Ÿ‘‹๐Ÿ˜ค Make the required changes listed above, add changes and try to commit again.'
false;
)

# Check tsconfig standards
npm run check-types ||
(
echo 'โŒโŒ Failed Type check. โŒโŒ Are you seriously trying to write that? Make the changes required above.'
false;
)

# If everything passes... Now we can commit
echo '๐Ÿค”๐Ÿค” Alright.... Code looks good to me... Trying to build now. ๐Ÿค”๐Ÿค”'

npm run build ||
(
echo '๐Ÿ”จโŒ Better call Bob... Because your build failed ๐Ÿ”จโŒ Next build failed: View the errors above to see why.'
false;
)

# If everything passes... Now we can commit
echo 'โœ…โœ… You win this time... I am committing this now. โœ…โœ…'

5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
build
dist/*
.idea/*
.vscode
node_modules/*
9 changes: 9 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"trailingComma": "es5",
"tabWidth": 2,
"useTabs": true,
"semi": true,
"singleQuote": false,
"printWidth": 120,
"arrowParens": "always"
}
Loading

0 comments on commit 27328c1

Please sign in to comment.