{ "githubRoot": "https://github.com/nrwl/nx/blob/master", "name": "linter", "packageName": "@nrwl/linter", "description": "The Linter plugin for Nx contains executors, generators and utilities used for linting JavaScript/TypeScript projects within an Nx workspace.", "root": "/packages/linter", "source": "/packages/linter/src", "documentation": [ { "id": "overview", "name": "Overview", "path": "/packages/linter", "file": "shared/linter-plugin", "content": "The Linter plugin contains executors, generator, plugin and utilities used for linting JavaScript/TypeScript projects within an Nx workspace.\n\n## Setting Up Linter\n\n### Installation\n\nIn any Nx workspace, you can install `@nrwl/linter` by running the following commands if `@nrwl/linter` package is not installed:\n\n```bash\nnpm i --save-dev @nrwl/linter\n```\n\n```bash\nyarn add --dev @nrwl/linter\n```\n\n## Lint\n\nYou can lint an application or a library with the following command:\n\n```bash\nnx lint my-app\n```\n\n```bash\nnx lint my-lib\n```\n\n## Utils\n\n- [convert-tslint-to-eslint](/packages/angular/generators/convert-tslint-to-eslint) - Converts a project linter from [TSLint](https://palantir.github.io/tslint/) to [ESLint](https://eslint.org/)\n" }, { "id": "eslint-plugin-nx", "name": "eslint-plugin-nx", "file": "shared/eslint-plugin-nx", "content": "A plugin containing a collection of recommended ESLint rule configurations wrapped as ESLint plugins and an Nx specific [enforce-module-boundaries](#enforce-module-boundaries) rule.\n\n## Setting Up ESLint Plugin\n\n### Installation\n\nIn any Nx workspace, you can install `@nrwl/eslint-plugin-nx` by running the following commands if the package is not already installed:\n\n{% tabs %}\n{%tab label=\"npm\"%}\n\n````bash\n```bash\nnpm i --save-dev @nrwl/eslint-plugin-nx\n````\n\n{% /tab %}\n{%tab label=\"yarn\"%}\n\n```bash\nyarn add --dev @nrwl/eslint-plugin-nx\n```\n\n{% /tab %}\n{% /tabs %}\n\n## ESLint plugins\n\nThe plugin contains the following rule configurations divided into sub-plugins.\n\n### JavaScript\n\nThe `@nrwl/nx/javascript` ESLint plugin contains best practices when using JavaScript.\n\n### TypeScript\n\nThe `@nrwl/nx/typescript` ESLint plugin contains best practices when using TypeSript.\n\n### Angular\n\nContains configurations matching best practices when using Angular framework:\n\n- @nrwl/nx/angular\n- @nrwl/nx/angular-template\n\n### React\n\nContains configurations matching best practices when using React framework:\n\n- @nrwl/nx/react-base\n- @nrwl/nx/react-jsx\n- @nrwl/nx/react-typescript\n\nYou can also use `@nrwl/nx/react` which includes all three `@nrwl/nx/react-*` plugins\n\n## enforce-module-boundaries\n\nThe `@nrwl/nx/enforce-module-boundaries` ESLint rule enables you to define strict rules for accessing resources between different projects in the repository. By enforcing strict boundaries it helps keep prevent unplanned cross-dependencies.\n\n### Usage\n\nYou can use `enforce-module-boundaries` rule by adding it to your ESLint rules configuration:\n\n```json\n{\n // ... more ESLint config here\n \"overrides\": [\n {\n \"files\": [\"*.ts\", \"*.tsx\", \"*.js\", \"*.jsx\"],\n \"rules\": {\n \"@nrwl/nx/enforce-module-boundaries\": [\n \"error\",\n {\n // ...rule specific configuration\n }\n ]\n }\n }\n // ... more ESLint overrides here\n ]\n}\n```\n\nRead more about proper usage of this rule:\n\n- [Enforce Project Boundaries](/core-features/enforce-project-boundaries)\n- [Ban Dependencies with Certain Tags](/recipe/ban-dependencies-with-tags)\n- [Tag in Multiple Dimensions](/recipe/tag-multiple-dimensions)\n- [Ban External Imports](/recipe/ban-external-imports)\n- [Tags Allow List](/recipe/tags-allow-list)\n- [Taming Code Organization with Module Boundaries in Nx](https://blog.nrwl.io/mastering-the-project-boundaries-in-nx-f095852f5bf4)\n" } ], "generators": [ { "name": "workspace-rules-project", "factory": "./src/generators/workspace-rules-project/workspace-rules-project#lintWorkspaceRulesProjectGenerator", "schema": { "$schema": "http://json-schema.org/schema", "$id": "NxWorkspaceRulesProject", "cli": "nx", "title": "Create the Workspace Lint Rules Project", "description": "Create the Workspace Lint Rules Project.", "type": "object", "examples": [ { "command": "nx g @nrwl/linter:workspace-rules-project", "description": "Create the Workspace Lint Rules Project" } ], "properties": {}, "required": [], "presets": [] }, "description": "Create the Workspace Lint Rules Project.", "hidden": true, "implementation": "/packages/linter/src/generators/workspace-rules-project/workspace-rules-project#lintWorkspaceRulesProjectGenerator.ts", "aliases": [], "path": "/packages/linter/src/generators/workspace-rules-project/schema.json" }, { "name": "workspace-rule", "factory": "./src/generators/workspace-rule/workspace-rule#lintWorkspaceRuleGenerator", "schema": { "$schema": "http://json-schema.org/schema", "$id": "NxWorkspaceRule", "cli": "nx", "title": "Create a new Workspace Lint Rule", "description": "Create a new Workspace Lint Rule.", "type": "object", "examples": [ { "command": "nx g @nrwl/linter:workspace-rule my-custom-rule", "description": "Create a new workspace lint rule called my-custom-rule" }, { "command": "nx g @nrwl/linter:workspace-rule --name=my-custom-rule --directory=a/b/c", "description": "Create a new workspace lint rule located at `tools/eslint-rules/a/b/c/my-custom-rule.ts`" } ], "properties": { "name": { "type": "string", "description": "The name of the new rule.", "$default": { "$source": "argv", "index": 0 } }, "directory": { "type": "string", "description": "Create the rule under this directory within `tools/eslint-rules/` (can be nested).", "alias": "dir", "default": "rules" } }, "required": ["name", "directory"], "presets": [] }, "description": "Create a new Workspace ESLint rule.", "implementation": "/packages/linter/src/generators/workspace-rule/workspace-rule#lintWorkspaceRuleGenerator.ts", "aliases": [], "hidden": false, "path": "/packages/linter/src/generators/workspace-rule/schema.json" } ], "executors": [ { "name": "lint", "implementation": "/packages/linter/src/executors/lint/lint.impl.ts", "schema": { "$schema": "http://json-schema.org/schema", "title": "Lint Target", "description": "Linter.", "cli": "nx", "type": "object", "properties": { "linter": { "description": "The tool to use for running lint checks.", "type": "string", "enum": ["eslint"], "default": "eslint" }, "config": { "type": "string", "description": "The name of the configuration file.", "x-completion-type": "file", "x-completion-glob": ".eslintrc.json)" }, "tsConfig": { "description": "The name of the TypeScript configuration file.", "oneOf": [ { "type": "string", "x-completion-type": "file", "x-completion-glob": "tsconfig.*.json" }, { "type": "array", "items": { "type": "string", "x-completion-type": "file", "x-completion-glob": "tsconfig.*.json" } } ] }, "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 } ] }, "exclude": { "type": "array", "description": "Files to exclude from linting.", "default": [], "items": { "type": "string", "x-completion-type": "file" } }, "files": { "type": "array", "description": "Files to include in linting.", "default": [], "items": { "type": "string", "x-completion-type": "file" } }, "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 }, "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" }, "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 } }, "additionalProperties": false, "required": ["linter"], "presets": [] }, "description": "**[DEPRECATED]**: Please use the eslint builder instead, an automated migration was provided in `v10.3.0`.", "aliases": [], "hidden": false, "path": "/packages/linter/src/executors/lint/schema.json" }, { "name": "eslint", "implementation": "/packages/linter/src/executors/eslint/lint.impl.ts", "schema": { "$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)" }, "lintFilePatterns": { "type": "array", "description": "One or more files/dirs/globs to pass directly to ESLint's `lintFiles()` method.", "default": [], "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 } ] }, "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 }, "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 }, "ignorePath": { "type": "string", "description": "The path of the `.eslintignore` file.", "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.", "x-completion-type": "directory" }, "reportUnusedDisableDirectives": { "type": "string", "default": "off", "enum": ["off", "warn", "error"], "description": "The equivalent of the `--report-unused-disable-directives` flag on the ESLint CLI." } }, "required": ["lintFilePatterns"], "presets": [] }, "hasher": "./src/executors/eslint/hasher", "description": "Run ESLint on a project.", "aliases": [], "hidden": false, "path": "/packages/linter/src/executors/eslint/schema.json" } ] }