This package contains Agoda's ESLint configuration that can be shared and extended.
# yarn users
yarn add -D eslint-config-agoda
# npm users
npm install --save-dev eslint-config-agoda
# pnpm users
pnpm add -D eslint-config-agoda
You will also need to have all peer dependencies installed on your project. To do so, please run:
# will use yarn/npm depending on detected configuration.
npx install-peerdeps --dev eslint-config-agoda
Modify your .eslintrc
configuration file, to extend from Agoda's config:
"extends": "agoda"
Example .eslintrc
file for Typescript environment:
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json"
},
"extends": ["agoda"],
"rules": {}
}
Setup following script in package.json
to enable linting via CLI.
"lint": "eslint --ext .ts,.tsx --ignore-path .gitignore ./packages/",
Above example is using packages directory (like it would be done for a
monorepo), so should be replaced by ./src/
in case of regular codebase
You can enable linting to run in background and check currently opened files by setting following configuration:
workspace settings .vscode/settings.json
"eslint.validate": [
{
"language": "typescript",
"autoFix": true
},
{
"language": "typescriptreact",
"autoFix": true
}
],
"eslint.options": {
"extensions": [".ts", ".tsx"]
},
"typescript.tsdk": "node_modules\\typescript\\lib",
"eslint.alwaysShowStatus": true,
"eslint.autoFixOnSave": true,
"editor.formatOnSave": false,
"javascript.format.enable": false
Note that this config is created with typescript in mind, so remember to use
project
key to facilitate type-based rules as well.