d8b577111a
because upgrading them caused identity unit tests to fail. This allows us to upgrade other packages to address security alerts. |
||
---|---|---|
.. | ||
config | ||
docs/rules | ||
src | ||
tests | ||
.markdownlint.json | ||
CONTRIBUTING.md | ||
README.md | ||
ci.yml | ||
eslint.config.mjs | ||
eslint.perftests.config.mjs | ||
package.json | ||
prettier.json | ||
tsconfig.build.json | ||
tsconfig.json | ||
tsconfig.lintjson.json | ||
vitest.config.mts |
README.md
eslint-plugin-azure-sdk
An ESLint plugin enforcing design guidelines for the JavaScript/TypeScript Azure SDK.
Installing and Building
Note: This is an internal package that can only be used within the azure-sdk-for-js monorepo.
To enable @azure/eslint-plugin-azure-sdk
, you'll need to add it to the list of devDependencies
in your package.json
:
{
...,
"devDependencies": {
...,
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
...
},
...
}
The ESLint plugin must be built from source as part of your package's depdendencies. The fastest way to build a single package and its dependencies is to run the command rush build -t <package name>
. For example, to rebuild the Form Recognizer package and all of its dependencies, we run rush build -t @azure/ai-form-recognizer
. This will rebuild eslint-plugin-azure-sdk
if necessary and make it available for use by the package's NPM scripts.
You must rebuild eslint-plugin-azure-sdk
after making changes to its own source files, either using rush build
as described above, or by entering the common/tools/eslint-plugin-azure-sdk
directory (this directory) and running rushx build
. Since the plugin is linked internally as part of our monorepo, the package does not need to be installed again after it is rebuilt.
See the contribution guide for more details about contributing to the azure-sdk-for-js repository.
Configuration
ESLint will automatically use the configuration file sdk/.eslintrc.json
as explained in the docs. Optionally, you can have a custom .eslintrc.json
file at the same location as your package.json
file. A very simple one looks 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 |