← All recipes
Moderne licensed

Lint source code with ESLint

Recipe IDorg.openrewrite.codemods.ESLint
Artifactorg.openrewrite.recipe:rewrite-codemods

Run ESLint across the code to fix common static analysis issues in the code. This requires the code to have an existing ESLint configuration.

Single recipeMSAL

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.ESLint

If the recipe isn’t available locally, install it with:

mod config recipes jar install org.openrewrite.recipe:rewrite-codemods:0.27.2

Options

NameTypeDescription
patternsListThe lint target files. This can contain any of file paths, directory paths, and glob patterns.
e.g. lib/**/*.js
parserStringParser used by ESLint to parse the source files. Defaults to @typescript-eslint/parser. See ESLint documentation for more details.
e.g. esprima
parserOptionsListA 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 }
allowInlineConfigBooleanWhether inline config comments are allowed. Defaults to false. See ESLint documentation for more details.
e.g. true
envsListA list of env mappings for ESLint. The format is key: value.
e.g. browser: true
globalsListDefine global variables for rules that require knowledge of these.
e.g. var1, var2: writable
pluginsListA list of plugins for ESLint.
e.g. @typescript-eslint, prettier
extendListA list of extends for ESLint.
e.g. eslint:recommended, prettier
rulesListList 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 documentation
e.g. eqeqeq: warn, multiline-comment-style: ["error", "starred-block"], prettier/prettier
fixBooleanAutomatically fix violations when possible. Defaults to true.
e.g. false
configFileStringAllows 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