I migrated my project from Husky v4 to v9 and followed the instructions to initialize Husky v9 using the npx husky-init command. However, the generated script contains lint errors that I can’t understand or resolve.
Script with lint errors
Lint errors:
Expected a JSON object, array or literal.json
Linter configuration(.eslintrc.json):
{
"env": {
"es6": true,
"node": true
},
"extends": [
"airbnb-base",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2022,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint",
"prettier"
],
"rules": {
"import/prefer-default-export": "off",
"import/no-extraneous-dependencies": [
"error",
{
"devDependencies": true
}
],
"prettier/prettier": "error",
"class-methods-use-this": "off",
"no-shadow": "off",
"@typescript-eslint/no-shadow": [
"error"
],
"@typescript-eslint/no-explicit-any": [
"warn"
],
"max-len": [
"error",
{
"code": 150,
"tabWidth": 4,
"ignoreComments": true,
"ignoreUrls": true,
"ignoreStrings": true,
"ignoreTemplateLiterals": true,
"ignoreRegExpLiterals": true
}
],
"import/extensions": [
"error",
"ignorePackages",
{
"ts": "never"
}
],
"@typescript-eslint/explicit-function-return-type": [
"error",
{
"allowExpressions": true
}
]
},
"settings": {
"import/resolver": {
"typescript": {
"alwaysTryTypes": true,
"project": "./tsconfig.json"
}
},
"node": {
"paths": [
"src"
],
"extensions": [
".js",
".jsx",
".ts",
".tsx"
]
}
}
}
Steps I’ve tried:
Checked the linter configurations.
Attempted to manually adjust the script, but the errors persist.
Here are the versions I’m using:
Husky: v9.0.11
Linter: ESLint v8.57.0
Has anyone faced this issue or knows a solution to remove the lint errors from this automatically generated script?
I would greatly appreciate any help!
Thank you!