Skip to content

Commit

Permalink
Merge pull request #12 from theappbusiness/fix/git-hook-typecheck
Browse files Browse the repository at this point in the history
Fix: Git Hooks ignoring .tsconfig when checking types
  • Loading branch information
robmorgan-tab authored Nov 28, 2022
2 parents bf3af49 + a837819 commit 7dcb99f
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 60 deletions.
86 changes: 86 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
const jsExtends = [
'eslint:recommended',
'plugin:import/recommended',
'prettier',
]

const tsExtends = [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/recommended',
'plugin:import/typescript',
'prettier',
]

const jsPlugins = ['prettier', 'import', 'jest-formatting']

const tsPlugins = ['@typescript-eslint', ...jsPlugins]

const jsParserOptions = {
ecmaVersion: 'latest',
sourceType: 'module',
}

const tsParserOptions = {
...jsParserOptions,
project: './tsconfig.json',
}

const jsRules = {
eqeqeq: 'error',
'import/no-default-export': 'error',
'import/no-unresolved': 'error',
'import/order': [
'error',
{
pathGroups: [
{
group: 'external',
pattern: '~shared/**',
position: 'after',
},
],
pathGroupsExcludedImportTypes: ['builtin'],
},
],
'prettier/prettier': [
'warn',
{
endOfLine: 'auto',
},
],
'jest-formatting/padding-around-describe-blocks': 2,
'jest-formatting/padding-around-test-blocks': 2,
}

const tsRules = {
...jsRules,
'@typescript-eslint/explicit-module-boundary-types': 'error',
'@typescript-eslint/explicit-function-return-type': 'error',
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
],
}

module.exports = {
env: {
node: true,
},
extends: jsExtends,
ignorePatterns: ['**/node_modules'],
parserOptions: jsParserOptions,
plugins: jsPlugins,
root: true,
rules: jsRules,
overrides: [
{
files: ['**/*.ts'],
extends: tsExtends,
parser: '@typescript-eslint/parser',
parserOptions: tsParserOptions,
plugins: tsPlugins,
rules: tsRules,
},
],
}
52 changes: 0 additions & 52 deletions .eslintrc.json

This file was deleted.

1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package-lock.json
package.json
.eslintrc.json
.prettierrc.js
tsconfig.json
bin
4 changes: 4 additions & 0 deletions lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
'**/*.{js,ts}': ['npm run format', 'npm run lint:fix'],
'**/*.ts': () => 'npm run typecheck',
}
7 changes: 0 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,5 @@
},
"dependencies": {
"prompts": "^2.4.2"
},
"lint-staged": {
"*.{js,ts}": [
"npm run typecheck",
"npm run format",
"npm run lint:fix"
]
}
}

0 comments on commit 7dcb99f

Please sign in to comment.