Skip to content

Latest commit

 

History

History
124 lines (104 loc) · 11 KB

File metadata and controls

124 lines (104 loc) · 11 KB

eslint-plugin-azure-sdk

An ESLint plugin enforcing design guidelines for the JavaScript/TypeScript Azure SDK.

Installation

You'll first need to install ESLint:

npm i eslint --save-dev

Next, install @azure/eslint-plugin-azure-sdk:

npm install @azure/eslint-plugin-azure-sdk --save-dev

Usage

The azure-sdk-for-js repository contains a base .eslintrc.json file at the root of the sdk directory.

To enable @azure/eslint-plugin-azure-sdk, you'll need to add another .eslintrc.json file at the same location as your package.json file as follows: (note that the path to the base .eslintrc.json file may be different)

{
  "plugins": ["@azure/azure-sdk"],
  "extends": ["../../.eslintrc.json", "plugin:@azure/azure-sdk/recommended"],
  "parserOptions": {
    "createDefaultProgram": true
  }
}

If the main TypeScript entrypoint to your package is not in src/index.ts, set settings.main in your .eslintrc configuration file to the entrypoint as follows (for example, if the entrypoint is index.ts):

{
  "plugins": ["@azure/azure-sdk"],
  "extends": ["../../.eslintrc.json", "plugin:@azure/azure-sdk/recommended"],
  "parserOptions": {
    "createDefaultProgram": true
  },
  "settings": {
    "main": "index.ts"
  }
}

If you need to modify or disable specific rules, you can do so in the rules section of your .eslintrc configuration file. For example, if you are not targeting Node, disable ts-config-moduleresolution as follows:

{
  "plugins": ["@azure/azure-sdk"],
  "extends": ["../../.eslintrc.json", "plugin:@azure/azure-sdk/recommended"],
  "parserOptions": {
    "createDefaultProgram": true
  },
  "rules": {
    "@azure/azure-sdk/ts-config-moduleresolution": "off"
  }
}

Some rules (see table below) are fixable using the --fix ESLint option (added in 1.3.0).

Supported Rules

Key

Symbol Meaning
🚩 Error
⚠️ Warning
✖️ Off
✔️ Fixable and autofix-enabled
Not fixable

Rules

Rule Default Fixable Release
github-source-headers 🚩 ✔️ 1.1.0
ts-apisurface-standardized-verbs 🚩 1.2.0
ts-apisurface-supportcancellation 🚩 1.2.0
ts-config-allowsyntheticdefaultimports 🚩 ✔️ 1.0.0
ts-config-declaration 🚩 ✔️ 1.0.0
ts-config-esmoduleinterop 🚩 ✔️ 1.0.0
ts-config-exclude 🚩 ✔️ 1.0.0
ts-config-forceconsistentcasinginfilenames 🚩 ✔️ 1.0.0
ts-config-importhelpers 🚩 ✔️ 1.0.0
ts-config-lib 🚩 ✔️ 1.0.0
ts-config-module 🚩 ✔️ 1.0.0
ts-config-moduleresolution 🚩 ✔️ 1.1.0
ts-config-no-experimentaldecorators 🚩 ✔️ 1.0.0
ts-config-sourcemap 🚩 ✔️ 1.0.0
ts-config-strict 🚩 ✔️ 1.0.0
ts-config-target 🚩 1.1.0
ts-doc-internal 🚩 1.1.0
ts-error-handling ✖️ 1.1.0
ts-modules-only-named 🚩 1.1.0
ts-naming-drop-noun 🚩 1.2.0
ts-naming-options 🚩 1.2.0
ts-naming-subclients 🚩 1.2.0
ts-no-const-enums ⚠️ ✔️ 1.1.0
ts-no-namespaces 🚩 1.2.0
ts-package-json-author 🚩 ✔️ 1.0.0
ts-package-json-bugs 🚩 ✔️ 1.0.0
ts-package-json-engine-is-present 🚩 ✔️ 1.1.0
ts-package-json-files-required 🚩 ✔️ 1.1.0
ts-package-json-homepage 🚩 1.0.0
ts-package-json-keywords 🚩 ✔️ 1.0.0
ts-package-json-license 🚩 ✔️ 1.0.0
ts-package-json-main-is-cjs 🚩 ✔️ 1.1.0
ts-package-json-module 🚩 ✔️ 1.1.0
ts-package-json-name 🚩 1.0.0
ts-package-json-repo 🚩 ✔️ 1.0.0
ts-package-json-required-scripts 🚩 1.0.0
ts-package-json-sideeffects 🚩 ✔️ 1.0.0
ts-package-json-types 🚩 1.1.0
ts-pagination-list 🚩 1.2.0
ts-use-interface-parameters ⚠️ 1.1.0
ts-use-promises 🚩 1.1.0
ts-versioning-semver 🚩 1.1.0