Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Git Hooks ignoring .tsconfig when checking types #12

Merged
merged 5 commits into from
Nov 28, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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', '**/*.tsx'],
robmorgan-tab marked this conversation as resolved.
Show resolved Hide resolved
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"
]
}
}