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
Add @azure/azure-sdk
to the plugins
section of your .eslintrc
configuration file. You can omit the eslint-plugin-
prefix:
{
"plugins": ["@azure/azure-sdk"]
}
Make sure to set your .eslintrc
configuration file's parserOptions.project
field to point to the tsconfig file at the root of your project as follows:
{
"parserOptions": {
"project": "./tsconfig.json"
}
}
For all rules to be enforced according to the standards set by the Design Guidelines, add this plugin's recommended
configuration to the extends
section of your .eslintrc
configuration file as follows:
{
"extends": ["plugin:@azure/azure-sdk/recommended"]
}
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
):
{
"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:
{
"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 |