How to enable in projects?
Configure project to read packages started from @emahnovets
from github package registry by running
npm config set @emahnovets:registry=https://npm.pkg.github.com --userconfig ./.npmrc
Install npm package
npm install --save-dev eslint @emahnovets/eslint-config-typescript prettier
Create .eslintrc.js
file with following content
module . exports = {
extends : '@emahnovets/eslint-config-typescript' ,
parserOptions : {
project : './tsconfig.json' , // Specify path to your tsconfig file
}
}
Create .prettierrc.js
file locally:
module . exports = {
"printWidth" : 120 ,
"tabWidth" : 2 ,
"useTabs" : false ,
"semi" : true ,
"singleQuote" : true ,
"trailingComma" : "all" ,
"bracketSpacing" : true ,
"bracketSameLine" : false ,
"arrowParens" : "always" ,
"quoteProps" : "consistent" ,
"endOfLine" : "lf"
}
Create lint
script in your package.json
file
{
// ...
"scripts" : {
// ...
"lint" : " eslint --ext .js,.ts src" // specify file extensions and folders to run eslint
},
}
(optionally) configure VSCode to fix eslint errors on file save by creating .vscode/settings.json
file in your repo
{
"eslint.validate" : [
" javascript" ,
" typescript"
],
"eslint.packageManager" : " npm" ,
"editor.codeActionsOnSave" : {
"source.fixAll.eslint" : true
}
}