Skip to content

Commit

Permalink
refactor: ESLint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
iliubinskii committed Jul 18, 2024
1 parent b043cea commit e7a55fc
Show file tree
Hide file tree
Showing 28 changed files with 270 additions and 213 deletions.
55 changes: 49 additions & 6 deletions .eslintrc.base.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const config = {
"plugin:misc/recommended",
"plugin:n/recommended",
"plugin:no-use-extend-native/recommended",
"plugin:node/recommended",
"plugin:promise/recommended",
"plugin:regexp/recommended",
"plugin:security/recommended-legacy",
Expand Down Expand Up @@ -95,11 +94,23 @@ const config = {
"import/named": "off",
"import/namespace": "off",
"import/no-deprecated": "off",
"import/no-extraneous-dependencies": [
"warn",
{
bundledDependencies: false,
devDependencies: false,
includeInternal: false,
includeTypes: true,
optionalDependencies: false,
peerDependencies: true
}
],
"import/no-internal-modules": "warn",
"import/no-named-as-default-member": "off",
"import/no-self-import": "warn",
"import/no-unresolved": "off",
"init-declarations": "off",
"jsdoc/require-description-complete-sentence": "warn",
"jsdoc/require-param-type": "off",
"jsdoc/require-returns-type": "off",
"misc/consistent-empty-lines": [
Expand Down Expand Up @@ -160,6 +171,10 @@ const config = {
]
}
],
"misc/consistent-optional-props": [
"warn",
{ classes: "combined", interfaces: "combined" }
],
"misc/no-nodejs-modules": "off",
"misc/no-shadow": "warn",
"misc/no-unnecessary-template-literal": "off",
Expand Down Expand Up @@ -197,6 +212,7 @@ const config = {
}
],
"misc/sort-export-specifiers": "off",
"n/no-extraneous-import": "off",
"n/no-missing-import": "off",
"no-duplicate-imports": "off",
"no-magic-numbers": ["warn", { ignore: [-1, 0, 0.5, 1, 2, 10, 100] }],
Expand All @@ -209,9 +225,6 @@ const config = {
"no-unused-vars": "off",
"no-use-before-define": "off",
"no-useless-assign/no-useless-assign": "warn",
"node/no-missing-import": "off",
"node/no-missing-require": "off",
"node/no-unsupported-features/es-syntax": "off",
"prefer-destructuring": "off",
"prettier/prettier": [
"warn",
Expand Down Expand Up @@ -291,12 +304,42 @@ const config = {
"./tests/**/*.tsx"
],
rules: {
"@typescript-eslint/no-extraneous-class": "off",
"i18n-text/no-en": "off",
"import/no-extraneous-dependencies": [
"warn",
{
bundledDependencies: false,
devDependencies: true,
includeInternal: false,
includeTypes: true,
optionalDependencies: false,
peerDependencies: true
}
],
"jsdoc/require-jsdoc": "off",
"misc/class-match-filename": "off",
"misc/no-at-sign-internal-import": "off",
"no-magic-numbers": "off",
"node/no-unpublished-import": "off"
"unicorn/no-null": "off"
}
},
{
files: ["./utils/**/*.ts", "./utils/**/*.tsx"],
rules: {
"import/no-extraneous-dependencies": [
"warn",
{
bundledDependencies: false,
devDependencies: true,
includeInternal: false,
includeTypes: true,
optionalDependencies: false,
peerDependencies: true
}
]
}
},
{ files: "./utils/**", rules: { "node/no-unpublished-import": "off" } },
{
files: ["./.eslintrc.*", "./.eslintrc.base.*"],
rules: {
Expand Down
9 changes: 1 addition & 8 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,6 @@ const config = {
{ classes: "combined", interfaces: "combined" }
],
"misc/typescript/no-unsafe-object-assignment": "off",
"node/no-unsupported-features/es-builtins": [
"error",
{ ignores: [], version: ">=20.0.0" }
],
"node/no-unsupported-features/node-builtins": [
"warn",
{ ignores: [], version: ">=20.0.0" }
],
"unicorn/no-null": "off"
},
overrides: [
Expand All @@ -69,6 +61,7 @@ const config = {
{
files: "./src/schema/routes.ts",
rules: {
"jsdoc/require-description-complete-sentence": "off",
"misc/comment-spacing": "off",
"misc/typescript/no-never": "off",
"misc/typescript/prefer-readonly-array": "off",
Expand Down
3 changes: 0 additions & 3 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run lint-commit-msg
36 changes: 29 additions & 7 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,14 +1,36 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

# Get the current Git branch name
BRANCH_NAME=$(git symbolic-ref --short HEAD)

# Forbid direct commits to master or develop
if [ "$BRANCH_NAME" = "master" ] || [ "$BRANCH_NAME" = "develop" ]; then
echo "Commits to $BRANCH_NAME branch are forbidden."
exit 1
fi

# Lint the staged files
npx lint-staged
TYPE_CHECK=no

PARSE_OPENAPI=no

STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM)

for file in $STAGED_FILES; do
case "$file" in
*.cjs|*.js|*.jsx|*.mjs|*.ts|*.tsx)
TYPE_CHECK=yes
;;
esac

case "$file" in
*.yaml)
PARSE_OPENAPI=yes
;;
esac
done

if [ "$TYPE_CHECK" = "yes" ]; then
npm run type-check
fi

if [ "$PARSE_OPENAPI" = "yes" ]; then
npm run parse-openapi
fi

npm run lint-staged-files
6 changes: 3 additions & 3 deletions api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import type express from "express";
let appCached: express.Express | undefined;

/**
* Handle the request
* @param req - Request
* @param res - Response
* Handle the request.
* @param req - Request.
* @param res - Response.
*/
export default async function handler(
req: Request,
Expand Down
5 changes: 2 additions & 3 deletions lint-staged.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
* @type {import('lint-staged').Config}
*/
const config = {
"*.{cjs,js,mjs,jsx,ts,tsx}": "eslint --max-warnings=0",
"*.{css,html,json,less,postcss,scss}": "prettier --write",
"*.{js,jsx,ts,tsx}": [() => "npm run type-check", "eslint --max-warnings=0"],
"*.md": "markdownlint",
"*.yaml": () => "npm run parse-openapi"
"*.md": "markdownlint"
};

export default config;
Loading

0 comments on commit e7a55fc

Please sign in to comment.