NPM configuration for base typescript projects
Includes:
- Prettier
- Eslint
- Typescript
And configuration for saneish defaults, which can be extended
Most of these are the raw defaults/recommended settings from typescript, eslint and prettier.
export class FooBar {
get foo(): number {
return 1;
}
async bar(): Promise<string> {
return 'bar';
}
/**
* @param foo foo to bar
*/
fooBar(foo = 'foo'): string {
return `${foo}bar`;
}
}
- Install
eslint
using the extensions menu - Add the following to your settings.json
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"eslint.validate": ["javascript"],
IntelliJ has ESLint support by default,
- Open the settings in Languages & Frameworks > JavaScript > Code Quality Tools > ESLint
- Check Automatic ESLint Configuration
- Install LINZ Style
yarn add -D @linzjs/style
# Or
npm install @linzjs/style
- Create the base configuration files
# If on windows run `node node_modules\@linzjs\style\build\src\install.js`
# - tsconfig.json
# - .eslintrc.js
# - .prettierrc.js
npx linz-style-install
- Apply the formatting/linting to all source code
npx eslint src/**/*.ts