{"id":20925654,"url":"https://github.com/bloczjs/eslint-plugin-blocz","last_synced_at":"2025-10-26T00:05:46.589Z","repository":{"id":97156757,"uuid":"203194115","full_name":"bloczjs/eslint-plugin-blocz","owner":"bloczjs","description":"Set preferred name for default imports","archived":false,"fork":false,"pushed_at":"2024-11-30T12:42:07.000Z","size":259,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-19T18:12:27.311Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bloczjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2019-08-19T14:55:26.000Z","updated_at":"2024-11-30T12:42:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"4582caa6-f0db-4bce-a354-32461879353f","html_url":"https://github.com/bloczjs/eslint-plugin-blocz","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bloczjs%2Feslint-plugin-blocz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bloczjs%2Feslint-plugin-blocz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bloczjs%2Feslint-plugin-blocz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bloczjs%2Feslint-plugin-blocz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bloczjs","download_url":"https://codeload.github.com/bloczjs/eslint-plugin-blocz/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243318758,"owners_count":20272144,"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":"2024-11-18T20:34:05.144Z","updated_at":"2025-10-26T00:05:46.509Z","avatar_url":"https://github.com/bloczjs.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"This ESLint plugin comes with multiple rules to help you apply some pattern on various topics (only imports for now) on a whole codebase.\n\n## Rules\n\n1. [Rules](#rules)\n   1. [preferred-export-default-naming](#preferred-export-default-naming)\n      1. [Configuration](#configuration)\n      2. [Example](#example)\n   2. [prevent-imports](#prevent-imports)\n      1. [Configuration](#configuration-1)\n      2. [Example](#example-1)\n\n### preferred-export-default-naming\n\nThis rule enforces a default name for export default \u0026 namespace. By default, default exports are preferred:\n\n```js\n/*\n  eslint blocz/preferred-export-default-naming: [\n    \"error\", { \"module\": \"react\", \"name\": \"React\" }\n  ]\n*/\n\n// ❌\nimport react from \"react\"; // Should be named React\nimport * as React from \"react\"; // Should be used with a default import\nimport * as react from \"react\";\n\n// ✅\nimport React from \"react\";\n```\n\nYou can specify if you would prefer to use a namespace:\n\n```js\n/*\n  eslint blocz/preferred-export-default-naming: [\n    \"error\", { \"module\": \"react\", \"name\": \"React\", preferNamespace: true }\n  ]\n*/\n\n// ❌\nimport * as react from \"react\"; // Should be named React\nimport React from \"react\"; // Should be used with a namespace import\nimport react from \"react\";\n\n// ✅\nimport * as React from \"react\";\n```\n\nBy default, this rule is auto-fixed, but this can be disabled with `autofix: false`.\n\n#### Configuration\n\nThis rule accepts an **array** of configs:\n\n| Option            | Type      | Description                                         |                 |\n| ----------------- | --------- | --------------------------------------------------- | --------------- |\n| `module`          | `string`  | Imported module name                                | Required        |\n| `name`            | `string`  | Name of the identifier that is imported             | Required        |\n| `autofix`         | `boolean` | Is this import auto fixed?                          | true (default)  |\n| `preferNamespace` | `boolean` | Should use a namespace instead of a default import? | false (default) |\n\n#### Example\n\n```jsonc\n{\n  \"plugins\": \"blocz\",\n  \"rules\": {\n    \"blocz/preferred-export-default-naming\": [\n      \"warn\",\n      {\n        \"module\": \"classnames\",\n        \"name\": \"classNames\",\n        \"autofix\": false // disable autofix\n      },\n      {\n        \"module\": \"react-dom\",\n        \"name\": \"ReactDOM\" // as autofix by default\n      },\n      {\n        \"module\": \"react\",\n        \"name\": \"React\",\n        \"preferNamespace\": true\n      }\n    ]\n  }\n}\n```\n\n### prevent-imports\n\nThis rule enforces a default name for export default \u0026 namespace. By default, default exports are preferred:\n\n```js\n/*\n  eslint blocz/prevent-imports: [\n    \"error\", { \"module\": \"react-dom\", \"names\": [\"findDOMNode\"] }\n  ]\n*/\n\n// ❌\nimport { findDOMNode } from \"react-dom\"; // findDOMNode shouldn’t be imported\n\nimport * as ReactDOM from \"react-dom\";\nReactDOM.findDOMNode(); // ❌ It recognizes that findDOMNode is from react-dom\n\nimport ReactDOM from \"react-dom\";\nReactDOM.findDOMNode(); // ❌ It recognizes that findDOMNode is from react-dom\n\n// ✅\nimport ReactDOM from \"react-dom\"; // findDOMNode isn't imported\nReactDOM.render(); // findDOMNode isn’t used\n```\n\nYou can specify a reason why multiple imports are forbidden:\n\n```tsx\n/*\n  eslint blocz/prevent-imports: [\n    \"error\", { \"module\": \"react\", \"names\": [\"FC\", \"FunctionComponent\", \"VFC\"], \"reason\": \"Prefer React.VoidFunctionComponent\" }\n  ]\n*/\n\n// ❌\nimport type { FC } from \"react\"; // Error: `You shouldn’t import \"FC\" from \"react\": Prefer React.VoidFunctionComponent`\nconst MyComponent: FC = () =\u003e {};\n\nimport React from \"react\";\nconst MyComponent: React.FunctionComponent = () =\u003e {}; // Error: `You shouldn’t use \"FunctionComponent\" from \"react\": Prefer React.VoidFunctionComponent`\n\nimport * as React from \"react\";\nconst MyComponent: React.VFC = () =\u003e {}; // Error: `You shouldn’t use \"VFC\" from \"react\": Prefer React.VoidFunctionComponent`\n\n// ✅\nimport * as React from \"react\";\nconst MyComponent: React.VoidFunctionComponent = () =\u003e {};\n```\n\n\u003e Note: some of those examples use TypeScript. You’ll need to enable `@typescript-eslint/parser` to be able to use it. See https://typescript-eslint.io/.\n\n#### Configuration\n\nThis rule accepts an **array** of configs:\n\n| Option   | Type       | Description                                |          |\n| -------- | ---------- | ------------------------------------------ | -------- |\n| `module` | `string`   | Imported module name                       | Required |\n| `names`  | `string[]` | Names of the all the forbidden identifiers | Required |\n| `reason` | `string`   | Reason for the interdiction                | Optional |\n\n#### Example\n\n```jsonc\n{\n  \"plugins\": \"blocz\",\n  \"rules\": {\n    \"blocz/prevent-imports\": [\n      \"warn\",\n      {\n        \"module\": \"react-dom\",\n        \"names\": [\"findDOMNode\", \"render\"],\n        \"reason\": \"Deprecated methods\"\n      },\n      {\n        \"module\": \"react\",\n        \"names\": [\"FC\", \"FunctionComponent\", \"VFC\"],\n        \"reason\": \"Prefer React.VoidFunctionComponent\"\n      }\n      {\n        \"module\": \"react\",\n        \"names\": \"Component\", // no reason\n      },\n\n    ]\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbloczjs%2Feslint-plugin-blocz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbloczjs%2Feslint-plugin-blocz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbloczjs%2Feslint-plugin-blocz/lists"}