Skip to content

Commit

Permalink
chore: Add pre-commit/pre-push hooks (#2293)
Browse files Browse the repository at this point in the history
* chore: Add husky to manage pre-commits

* feat: Rewrite script commands

* chore: Install typescript eslint plugins and remove tslint

* chore: Add eslint and prettier config files

* chore: Update pre-commit file to use new package.json scripts

* chore: Remove eslint from package.json to avoid conflicts with react-scripts

* chore: Run tests in pre-push hook instead of pre-commit

* chore: Move husky install to the postinstall script

* chore: Update file permissions

* chore: Update rules

* chore: Update eslint rules and remove runs tests on push

* chore: Update prettierrc rules

* chore: Update eslint rules

* chore: Update .prettierignore file

* chore: Remove unrequired env var

* chore: Update eslint rules

* style: Apply prettier rules to project files

* refactor: Apply eslint rules to project files

* chore: Update pre-commit to runs eslint rules before prettier rules

* fix: eslint restrict-plus-operands rule (#2381)

* fix: eslint restrict-plus-operands rule

* feat: Use classnames dependency

* fix: eslint require-await rule (#2380)

* fix: Required await eslint rule

* feat: Return async method to avoid blockign the ui

* fix: Remove unnecessary returns

* fix: Remove unnecessary types (#2403)

* fix: Remove inferred boolean type and type the onClick method to void

* feat: Update eslintrc

* feat: Remove inferred RootState

* feat: Update var declaration

* chore: Update eslintrc

* fix: Update debounce var definition and types

* fix: Update builder api methods return types (#2411)

* fix: eslint typos

* fix: eslint no-case-declarations (#2417)

* chore: eslint disable next line (#2416)

* chore: Add eslint-disable-next-line

* chore: Add TODO to support imports in languages module

* fix: eslint strings (#2415)

* fix: eslint strings

* fix: Commented code

* feat: Update string typo casting

* fix: Remove unused empty objects (#2414)

* fix: Remove unused empty objects

* feat: Update ShortcutTooltip OwnProps type

* feat: Update Square Props type

* fix: eslint forbidden non-null assertion

* fix: eslint invalid type undefined of template literal expression

* fix: eslint unsafe return of an any typed value

* fix: Prettier

* chore: Re-order pre-commit
  • Loading branch information
cyaiox authored Nov 14, 2022
1 parent b762269 commit 519a0ed
Show file tree
Hide file tree
Showing 264 changed files with 2,108 additions and 1,421 deletions.
56 changes: 56 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"ignorePatterns": [
"src/contracts/*",
"src/ecsScene/*",
"scripts/*.js",
"src/modules/project/export.ts",
"src/modules/analytics/rollbar.ts",
"src/modules/editor/base64.ts",
"package.json",
"package-lock.json"
],
"plugins": ["@typescript-eslint"],
"extends": ["eslint:recommended", "react-app", "react-app/jest", "prettier"],
"env": {
"browser": true,
"es6": true
},
"rules": {
"@typescript-eslint/ban-types": "error",
"@typescript-eslint/ban-tslint-comment": "error",
"@typescript-eslint/quotes": ["error", "single", { "avoidEscape": true }],
"@typescript-eslint/no-misused-promises": ["error", { "checksVoidReturn": false }]
},
"overrides": [
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@typescript-eslint/recommended", "plugin:@typescript-eslint/recommended-requiring-type-checking", "prettier"],
"rules": {
"@typescript-eslint/no-unnecessary-type-assertion": "error",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_", "ignoreRestSiblings": true }],
"@typescript-eslint/no-unsafe-assignment": "off", // TODO: migrate code progressively to remove this line. https://typescript-eslint.io/rules/no-unsafe-assignment/
"@typescript-eslint/no-unsafe-call": "off", // TODO: migrate code progressively to remove this line. https://typescript-eslint.io/rules/no-unsafe-call/
"@typescript-eslint/no-unsafe-member-access": "off", // TODO: migrate code progressively to remove this line. https://typescript-eslint.io/rules/no-unsafe-member-access/
"@typescript-eslint/no-unsafe-argument": "off" // TODO: migrate code progressively to remove this line. https://typescript-eslint.io/rules/no-unsafe-argument/
},
"parserOptions": {
"project": ["./tsconfig.json"]
}
},
{
"files": ["*.spec.ts"],
"rules": {
"@typescript-eslint/unbound-method": "off"
}
},
{
"files": ["*.js"],
"rules": {
"@typescript-eslint/no-var-requires": "off"
}
}
]
}
18 changes: 18 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

FILES=$(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g' | { grep -E '(js|ts|tsx|json|yml|md|html|css)$' || true; })

if [ -z "$FILES" ]; then
exit 0
fi

echo "Running prettier"
npm run pre-commit:fix:prettier -- $FILES

TS_FILES=$(echo $FILES | { grep -E '(js|ts|tsx)$' || true; })

if [[ ! -z "$TS_FILES" ]];then
echo "Running lints"
npm run pre-commit:fix:code -- $TS_FILES
fi
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
src/contracts
src/ecsScene
src/components/Preview/loader.json
src/modules/analytics/rollbar.ts
8 changes: 8 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"semi": false,
"singleQuote": true,
"printWidth": 140,
"tabWidth": 2,
"trailingComma": "none",
"arrowParens": "avoid"
}
Loading

0 comments on commit 519a0ed

Please sign in to comment.