eslint.star¶
Set rules and presets in ESLint's JSON and YAML configs.
Supports the legacy (eslintrc) format: .eslintrc.json, .eslintrc,
.eslintrc.yaml, .eslintrc.yml and the eslintConfig key of package.json.
Flat configs (eslint.config.js) are JavaScript and can't be edited
safely; find reports them so a campaign can skip or flag those repos.
| Function | What it does |
|---|---|
find |
Finds the repo's ESLint config. |
set_rule |
Sets a rule's level, and optionally its options. |
add_extends |
Adds a preset to extends unless it is already there. |
find¶
Finds the repo's ESLint config.
Arguments
| Name | Description |
|---|---|
repo |
The repo passed to change(repo). |
Returns: The path of the first JSON or YAML config that exists, package.json
when it has an eslintConfig key, the path of a flat config when the
repo uses one, or None.
Example
Used in: prettier-eslint
set_rule¶
Sets a rule's level, and optionally its options.
Without options, a rule that already has options keeps them and only
its level changes, so ["error", "allow-null"] becomes
["warn", "allow-null"] rather than losing allow-null.
Arguments
| Name | Description |
|---|---|
repo |
The repo passed to change(repo). |
rule |
The rule, such as no-console or @typescript-eslint/no-unused-vars. |
level |
off, warn or error (or 0, 1, 2). |
options |
The rule's options, written after the level as in ["error", {"allow": ["warn"]}]; JSON configs only. |
Returns: True when the file changed; False when the repo has no editable config.
Example
Used in: prettier-eslint
add_extends¶
Adds a preset to extends unless it is already there.
Arguments
| Name | Description |
|---|---|
repo |
The repo passed to change(repo). |
preset |
The preset, such as plugin:security/recommended. |
Returns: True when the file changed; False when the repo has no editable JSON config.
Example