TypeScript Configurations
About
Personal configurations for TypeScript projects. Sets up base path to src/
.
Includes:
Installation
npm install @jupl/ts
yarn add @jupl/ts
Usage
TypeScript
Add to tsconfig.json
:
{
"extends": "@jupl/ts",
"compilerOptions": {
"baseUrl": ".",
"paths": {
"~/*": ["src/*"]
}
}
}
Prettier
Install dependencies:
prettier
Add to .prettierrc.js
:
module.exports = require('@jupl/ts/format')
ESLint
Install any of the following dependencies based on your use case:
-
@next/eslint-plugin-next
(Next.js) -
@remix-run/eslint-config
(Remix) @typescript-eslint/eslint-plugin
@typescript-eslint/parser
eslint
eslint-config-prettier
-
eslint-import-resolver-node
(Yarn PnP) eslint-plugin-functional
eslint-plugin-import
eslint-plugin-jsdoc
-
eslint-plugin-prettier
(andprettier
) eslint-plugin-react
eslint-plugin-react-hooks
eslint-plugin-sonarjs
Add to .eslintrc.js
:
module.exports = {
...require('@jupl/ts/lint'),
// Additional options
}
Jest
Install dependencies:
babel-plugin-dynamic-import-node
-
babel-jest
(Yarn PnP) jest
ts-jest
Add to jest.config.js
:
const {pathsToModuleNameMapper} = require('ts-jest/utils')
const {compilerOptions} = require('./tsconfig')
module.exports = {
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, {
prefix: '<rootDir>/',
}),
preset: '@jupl/ts',
}