eslint-config-agoda

Agoda's ESLint configuration and rules

Usage no npm install needed!

<script type="module">
  import eslintConfigAgoda from 'https://cdn.skypack.dev/eslint-config-agoda';
</script>

README

npm npm semantic-release Commitizen friendly dependabot badge

eslint-config-agoda

This package contains Agoda's ESLint configuration that can be shared and extended.

Installation

# yarn users
yarn add -D eslint-config-agoda

# npm users
npm install --save-dev 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

Usage

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": {}
}

Command line

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

Visual Studio Code

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

Typescript

Note that this config is created with typescript in mind, so remember to use project key to facilitate type-based rules as well.