153 lines
8.0 KiB
JSON

{
"name": "lint",
"implementation": "/packages/eslint/src/executors/lint/lint.impl.ts",
"schema": {
"version": 2,
"outputCapture": "direct-nodejs",
"$schema": "http://json-schema.org/schema",
"title": "ESLint Lint Target",
"description": "ESLint Lint Target.",
"cli": "nx",
"type": "object",
"properties": {
"eslintConfig": {
"type": "string",
"description": "The name of the ESLint configuration file.",
"x-completion-type": "file",
"x-completion-glob": ".eslintrc?(.json)",
"x-priority": "important"
},
"lintFilePatterns": {
"type": "array",
"description": "One or more files/dirs/globs to pass directly to ESLint's `lintFiles()` method.",
"default": ["{projectRoot}"],
"items": { "type": "string" }
},
"format": {
"type": "string",
"description": "ESLint Output formatter (https://eslint.org/docs/user-guide/formatters).",
"default": "stylish",
"anyOf": [
{
"enum": [
"stylish",
"compact",
"codeframe",
"unix",
"visualstudio",
"table",
"checkstyle",
"html",
"jslint-xml",
"json",
"json-with-metadata",
"junit",
"tap"
]
},
{ "minLength": 1 }
],
"x-priority": "important"
},
"force": {
"type": "boolean",
"description": "Succeeds even if there was linting errors.",
"default": false
},
"silent": {
"type": "boolean",
"description": "Hide output text.",
"default": false
},
"fix": {
"type": "boolean",
"description": "Fixes linting errors (may overwrite linted files).",
"default": false,
"x-priority": "important"
},
"cache": {
"type": "boolean",
"description": "Only check changed files.",
"default": false
},
"cacheLocation": {
"type": "string",
"description": "Path to the cache file or directory.",
"x-completion-type": "directory",
"x-completion-glob": "tsconfig.*.json"
},
"outputFile": {
"type": "string",
"description": "File to write report to.",
"x-completion-type": "file"
},
"maxWarnings": {
"type": "number",
"description": "Number of warnings to trigger nonzero exit code - default: `-1`.",
"default": -1
},
"quiet": {
"type": "boolean",
"description": "Report errors only - default: `false`.",
"default": false,
"x-priority": "important"
},
"ignorePath": {
"type": "string",
"description": "The path of the `.eslintignore` file. Not supported for Flat Config.",
"x-completion-type": "file",
"x-completion-glob": ".eslintignore"
},
"noEslintrc": {
"type": "boolean",
"description": "The equivalent of the `--no-eslintrc` flag on the ESLint CLI, it is `false` by default.",
"default": false
},
"hasTypeAwareRules": {
"type": "boolean",
"description": "When set to `true`, the linter will invalidate its cache when any of its dependencies changes."
},
"cacheStrategy": {
"type": "string",
"description": "Strategy to use for detecting changed files in the cache.",
"default": "metadata",
"enum": ["metadata", "content"]
},
"rulesdir": {
"type": "array",
"description": "The equivalent of the `--rulesdir` flag on the ESLint CLI.",
"default": [],
"items": { "type": "string", "x-completion-type": "directory" }
},
"resolvePluginsRelativeTo": {
"type": "string",
"description": "The equivalent of the `--resolve-plugins-relative-to` flag on the ESLint CLI. Not supported for Flat Config.",
"x-completion-type": "directory"
},
"reportUnusedDisableDirectives": {
"type": "string",
"enum": ["off", "warn", "error"],
"description": "The equivalent of the `--report-unused-disable-directives` flag on the ESLint CLI."
},
"printConfig": {
"type": "string",
"description": "The equivalent of the `--print-config` flag on the ESLint CLI.",
"x-completion-type": "file"
},
"errorOnUnmatchedPattern": {
"type": "boolean",
"description": "When set to false, equivalent of the `--no-error-on-unmatched-pattern` flag on the ESLint CLI.",
"default": true
}
},
"examplesFile": "Linter can be configured in multiple ways. The basic way is to provide only `lintFilePatterns`, which is a mandatory property. This tells us where to look for files to lint.\n\n`project.json`:\n\n```json\n\"lint\": {\n \"executor\": \"@nx/eslint:lint\",\n \"options\": {\n \"lintFilePatterns\": [\"apps/frontend/**/*.ts\"]\n }\n}\n```\n\n## Examples\n\n{% tabs %}\n{% tab label=\"Fixing linter issues\" %}\n\nLinter provides an automated way of fixing known issues. To ensure that those changes are properly cached, we need to add an `outputs` property to the `lint` target. Omitting the `outputs` property would produce an invalid cache record. Both of these properties are set by default when scaffolding a new project.\n\n```json\n\"lint\": {\n \"executor\": \"@nx/eslint:lint\",\n \"outputs\": [\"{options.outputFile}\"],\n \"options\": {\n \"lintFilePatterns\": [\"apps/frontend/**/*.ts\"]\n }\n}\n```\n\nWith these settings, we can run the command with a `--fix` flag:\n\n```bash\nnx run frontend:lint --fix\n```\n\nWe can also set this flag via project configuration to always fix files when running lint:\n\n```json\n\"lint\": {\n \"executor\": \"@nx/eslint:lint\",\n \"outputs\": [\"{options.outputFile}\"],\n \"options\": {\n \"lintFilePatterns\": [\"apps/frontend/**/*.ts\"],\n \"fix\": true\n }\n}\n```\n\n{% /tab %}\n{% tab label=\"Custom output format\" %}\n\nESLint executor uses the `stylish` output format by default. You can change this by specifying the `format` property:\n\n```json\n\"lint\": {\n \"executor\": \"@nx/eslint:lint\",\n \"outputs\": [\"{options.outputFile}\"],\n \"options\": {\n \"lintFilePatterns\": [\"apps/frontend/**/*.ts\"],\n \"format\": \"compact\"\n }\n}\n```\n\n{% /tab %}\n{% tab label=\"Silence warnings\" %}\n\nMigrated or legacy projects tend to have an overwhelming amount of lint errors. We might want to change those temporarily to be warnings so they don't block the development. But they would still clutter the report. We can run the command with `--quiet` to hide warning (errors would still break the lint):\n\n```bash\nnx run frontend:lint --quiet\n```\n\nWe can also set this via project configuration as a default option.\n\n```json\n\"lint\": {\n \"executor\": \"@nx/eslint:lint\",\n \"outputs\": [\"{options.outputFile}\"],\n \"options\": {\n \"lintFilePatterns\": [\"apps/frontend/**/*.ts\"],\n \"quiet\": true\n }\n}\n```\n\n{% /tab %}\n{% tab label=\"Flat Config file\" %}\n\n`ESLint` provides several ways of specifying the configuration. The default one is using `.eslintrc.json` but you can override it by setting the `eslintConfig` flag. The new `Flat Config` is now also supported:\n\n```json\n\"lint\": {\n \"executor\": \"@nx/eslint:lint\",\n \"outputs\": [\"{options.outputFile}\"],\n \"options\": {\n \"lintFilePatterns\": [\"apps/frontend/**/*.ts\"],\n \"eslintConfig\": \"eslint.config.js\"\n }\n}\n```\n\n**Note:** In contrast to other configuration formats, the `Flat Config` requires that all configuration files are converted to `eslint.config.js`. Built-in migrations and generators support only `.eslintrc.json` at the moment.\n\n{% /tab %}\n{% /tabs %}\n\n---\n",
"presets": []
},
"hasher": "./src/executors/lint/hasher",
"description": "Run ESLint on a project.",
"aliases": [],
"hidden": false,
"path": "/packages/eslint/src/executors/lint/schema.json",
"type": "executor"
}