Skip to content

Commit

Permalink
feat: add support for alias with tsconfig, eslint configuration and jest
Browse files Browse the repository at this point in the history
  • Loading branch information
ixartz committed Jun 3, 2022
1 parent 694823c commit 9de953e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
16 changes: 15 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@
"endOfLine": "auto"
}
],
"import/extensions": [
"error",
"ignorePackages",
{
"js": "never",
"jsx": "never",
"ts": "never",
"tsx": "never",
"": "never"
}
], // Avoid missing file extension errors when using '@/' alias
"@typescript-eslint/comma-dangle": "off", // Avoid conflict rule between Eslint and Prettier
"import/prefer-default-export": "off", // Named export is easier to refactor automatically
"simple-import-sort/imports": "error", // Import configuration for `eslint-plugin-simple-import-sort`
Expand All @@ -46,7 +57,10 @@
"extends": [
"plugin:jest/recommended",
"plugin:jest-formatting/recommended"
]
],
"rules": {
"jest/no-mocks-import": "off"
}
}
]
}
7 changes: 7 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ module.exports = {
transform: {
'^.+\\.ts$': ['ts-jest'],
},
moduleNameMapper: {
// Handle module aliases (this will be automatically configured for you soon)
'^@/(.*)$': '<rootDir>/src/$1',

'^__mocks__/(.*)$': '<rootDir>/__mocks__/$1',
},
clearMocks: true,
collectCoverage: true,
collectCoverageFrom: [
'./src/**/*.{js,ts}',
Expand Down
5 changes: 4 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,

"baseUrl": "."
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
},
"exclude": ["./dist/**/*", "./node_modules/**/*"]
}

0 comments on commit 9de953e

Please sign in to comment.