Lint source code with ESLint
Recipe ID
org.openrewrite.codemods.ESLintArtifact
org.openrewrite.recipe:rewrite-codemodsRun ESLint across the code to fix common static analysis issues in the code. This requires the code to have an existing ESLint configuration.
Usage
This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.
mod run . --recipe org.openrewrite.codemods.ESLintIf the recipe isn’t available locally, install it with:
mod config recipes jar install org.openrewrite.recipe:rewrite-codemods:0.27.2Options
| Name | Type | Description |
|---|---|---|
patterns | List | The lint target files. This can contain any of file paths, directory paths, and glob patterns. e.g. lib/**/*.js |
parser | String | Parser used by ESLint to parse the source files. Defaults to @typescript-eslint/parser. See ESLint documentation for more details.e.g. esprima |
parserOptions | List | A list of parser options for ESLint. The format is key: value. Defaults to ecmaVersion: "latest", ecmaFeatures: { jsx: true }, sourceType: "module". See ESLint documentation for more details.e.g. ecmaVersion: 6, ecmaFeatures: { jsx: true } |
allowInlineConfig | Boolean | Whether inline config comments are allowed. Defaults to false. See ESLint documentation for more details.e.g. true |
envs | List | A list of env mappings for ESLint. The format is key: value.e.g. browser: true |
globals | List | Define global variables for rules that require knowledge of these. e.g. var1, var2: writable |
plugins | List | A list of plugins for ESLint. e.g. @typescript-eslint, prettier |
extend | List | A list of extends for ESLint. e.g. eslint:recommended, prettier |
rules | List | List of rules to be checked by ESLint. Optionally, the severity and other rule options can also be specified as e.g. off, warn or ["error", "always"]. The severity off is useful when the rule is declared by an extended shareable config. For more information, see the ESLint documentatione.g. eqeqeq: warn, multiline-comment-style: ["error", "starred-block"], prettier/prettier |
fix | Boolean | Automatically fix violations when possible. Defaults to true.e.g. false |
configFile | String | Allows specifying the full ESLint configuration file contents as multiline JSON. See ESLint documentation for more details.
Note that this will override any other configuration options. e.g. {} |
Data tables
Structured output this recipe can produce.
- ESLint messagesErrors and warnings as reported by ESLint.
org.openrewrite.codemods.ESLintMessages - Source files that had resultsSource files that were modified by the recipe run.
org.openrewrite.table.SourcesFileResults - Source files that had search resultsSearch results that were found during the recipe run.
org.openrewrite.table.SearchResults - Source files that errored on a recipeThe details of all errors produced by a recipe run.
org.openrewrite.table.SourcesFileErrors - Recipe performanceStatistics used in analyzing the performance of recipes.
org.openrewrite.table.RecipeRunStats