{"id":28218619,"url":"https://github.com/nette/eslint-plugin","last_synced_at":"2025-06-11T05:31:48.144Z","repository":{"id":293494944,"uuid":"984217612","full_name":"nette/eslint-plugin","owner":"nette","description":"Nette-specific ESLint rules and config","archived":false,"fork":false,"pushed_at":"2025-05-29T19:36:19.000Z","size":20,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-29T20:38:21.748Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nette.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"dg","custom":"https://nette.org/donate"}},"created_at":"2025-05-15T15:18:08.000Z","updated_at":"2025-05-29T19:36:22.000Z","dependencies_parsed_at":"2025-05-16T00:31:38.617Z","dependency_job_id":null,"html_url":"https://github.com/nette/eslint-plugin","commit_stats":null,"previous_names":["nette/eslint-plugin"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nette%2Feslint-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nette%2Feslint-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nette%2Feslint-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nette%2Feslint-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nette","download_url":"https://codeload.github.com/nette/eslint-plugin/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nette%2Feslint-plugin/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259207376,"owners_count":22821658,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-05-18T02:10:24.516Z","updated_at":"2025-06-11T05:31:48.135Z","avatar_url":"https://github.com/nette.png","language":"JavaScript","readme":"# @nette/eslint-plugin\n\n[![npm version](https://img.shields.io/npm/v/@nette/eslint-plugin.svg)](https://www.npmjs.com/package/@nette/eslint-plugin)\n![License](https://img.shields.io/npm/l/@nette/eslint-plugin.svg)\n\nAn ESLint plugin with custom rules and shareable configuration for Nette-specific JavaScript and TypeScript linting, including support for Latte template files.\n\nInstallation\n============\n\n```bash\nnpm install --save-dev @nette/eslint-plugin eslint\n```\n\nFor TypeScript support, you will also need these additional dependencies:\n\n```bash\nnpm install --save-dev typescript typescript-eslint\n```\n\nFor Latte template support (HTML files with embedded JavaScript), you will also need:\n\n```bash\nnpm install --save-dev eslint-plugin-html\n```\n\n \u003c!----\u003e\n\nFeatures\n========\n\nThis plugin provides custom rules and configurations to improve code quality:\n\n### Custom Rules\n- **no-this-in-arrow-except**: Prevents using `this` inside arrow functions with configurable exceptions\n- **prefer-line-comments**: Enforces line comments (`//`) over block comments (`/* */`) for single-line comments\n\n### Latte Template Support\n- **Latte Processor**: Processes Latte template files to lint JavaScript code within templates\n- **File Type Support**: `.js.latte`, `.css.latte`, `.txt.latte`, `.latte` files\n- **n:syntax=\"off\"**: Respects syntax disable attribute in HTML elements\n\n \u003c!----\u003e\n\nUsage\n=====\n\nAdd `@nette/eslint-plugin` to your ESLint configuration.\n\n### Using Recommended Configuration\n\n```js\n// eslint.config.js\nimport nette from '@nette/eslint-plugin';\nimport { defineConfig } from 'eslint/config';\n\nexport default defineConfig([\n\t{\n\t\textends: [nette.configs.recommended],\n\t\t// ...your other config items\n\t},\n]);\n```\n\nUsing Latte Configuration\n------------------------\n\nThe [eslint-plugin-html](https://www.npmjs.com/package/eslint-plugin-html) plugin is used to check JavaScript inside `\u003cscript\u003e` tags in HTML pages. This package provides you with a preprocessor that allows you to use Latte tags inside JavaScript, for example:\n\n```latte\n\u003cscript\u003e\nlet name = {$name};\n\u003c/script\u003e\n```\n\nUse this configuration:\n\n```js\nimport nette from '@nette/eslint-plugin';\nimport pluginHtml from 'eslint-plugin-html';\nimport { defineConfig } from 'eslint/config';\n\nexport default defineConfig([\n\t{\n\t\tfiles: ['app/**/*.latte'],\n\n\t\tplugins: {\n\t\t\thtml: pluginHtml,       // Enables eslint-plugin-html\n\t\t},\n\t\tprocessor: '@nette/latte',  // Enabled Latte preprocessor\n\t},\n]);\n```\n\n\nUsing TypeScript Configuration\n------------------------------\n\nImport from typescript entrypoint:\n\n```js\nimport nette from '@nette/eslint-plugin/typescript';\n\nexport default defineConfig([\n\t{\n\t\textends: [nette.configs.typescript],\n\t\t// ...your other config items\n\t},\n]);\n```\n\nCustomizing Configuration\n------------------------\n\n```js\nexport default defineConfig([\n\t{\n\t\textends: [nette.configs.customize({\n\t\t\tbrowser: true,    // Include browser globals (default: true)\n\t\t\ttypescript: true, // Include TypeScript support (default: false)\n\t\t})],\n\t\t// ...your other config items\n\t},\n]);\n```\n\nUsing Rules\n-----------\n\n```js\nimport nette from '@nette/eslint-plugin';\nimport { defineConfig } from 'eslint/config';\n\nexport default defineConfig([\n\t{\n\t\tplugins: {\n\t\t\t'@nette': nette\n\t\t},\n\n\t\trules: {\n\t\t\t'@nette/no-this-in-arrow-except': 'error',\n\t\t\t'@nette/prefer-line-comments': 'error'\n\t\t},\n\t},\n]);\n```\n\n \u003c!----\u003e\n\nRule Details\n============\n\nno-this-in-arrow-except\n-----------------------\n\nPrevents using `this` in arrow functions with exceptions for specific cases. It has two modes:\n\n1. **Default mode** (`allowNestedInFunction: false`):\n\t - Allows `this` in arrow functions only when they are callbacks in class methods or directly passed to function calls\n\n2. **Opt-in mode** (`allowNestedInFunction: true`):\n\t - Also allows `this` in arrow functions when nested within any regular function\n\nExample configuration:\n\n```js\n{\n\trules: {\n\t\t'@nette/no-this-in-arrow-except': ['error', { allowNestedInFunction: true }]\n\t}\n}\n```\n\nprefer-line-comments\n--------------------\n\nEnforces the use of line comments (`//`) instead of block comments (`/* */`) for single-line comments.\nExceptions are made for:\n- Multi-line block comments\n- JSDoc comments (block comments starting with `*`)\n","funding_links":["https://github.com/sponsors/dg","https://nette.org/donate"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnette%2Feslint-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnette%2Feslint-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnette%2Feslint-plugin/lists"}