An ESLint plugin enforcing design guidelines for the JavaScript/TypeScript Azure SDK.
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
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
).
Symbol | Meaning |
---|---|
🚩 | Error |
Warning | |
✖️ | Off |
✔️ | Fixable and autofix-enabled |
❌ | Not fixable |