{"id":19364412,"url":"https://github.com/shinyaigeek/eslint-plugin-reduce-bundle-size","last_synced_at":"2026-02-08T03:09:09.300Z","repository":{"id":40317248,"uuid":"492467635","full_name":"Shinyaigeek/eslint-plugin-reduce-bundle-size","owner":"Shinyaigeek","description":"eslint plugin to reduce your javascript application bundle size","archived":false,"fork":false,"pushed_at":"2024-08-31T03:04:16.000Z","size":537,"stargazers_count":2,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-22T04:05:23.565Z","etag":null,"topics":["bundle-size","eslint","eslint-plugin","eslint-rules"],"latest_commit_sha":null,"homepage":"","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/Shinyaigeek.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2022-05-15T11:30:05.000Z","updated_at":"2023-12-13T05:50:26.000Z","dependencies_parsed_at":"2025-03-21T17:02:00.099Z","dependency_job_id":"cd482f90-8427-4ac6-ba11-322387a2a871","html_url":"https://github.com/Shinyaigeek/eslint-plugin-reduce-bundle-size","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shinyaigeek%2Feslint-plugin-reduce-bundle-size","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shinyaigeek%2Feslint-plugin-reduce-bundle-size/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shinyaigeek%2Feslint-plugin-reduce-bundle-size/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shinyaigeek%2Feslint-plugin-reduce-bundle-size/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Shinyaigeek","download_url":"https://codeload.github.com/Shinyaigeek/eslint-plugin-reduce-bundle-size/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250451616,"owners_count":21432856,"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":["bundle-size","eslint","eslint-plugin","eslint-rules"],"created_at":"2024-11-10T07:37:20.174Z","updated_at":"2026-02-08T03:09:09.258Z","avatar_url":"https://github.com/Shinyaigeek.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# eslint-plugin-mangling-friendly\n\n**ESLint plugin for more mangling friendly code, for less bundle size**\n\n## Feature ✨\n\n- ESLint plugin for more mangling friendly code\n- some mangling process with safe needs coding rule\n- This plugin provides a restrict to accomplish the above coding rule\n\n## Setup\n\n```bash\nnpm install eslint-plugin-mangling-friendly -D # TBD\n```\n\nwrite your eslint config file\n\n```javascript\n// .eslintrc.js\nmodule.exports = {\n    ...,\n    parser: '@typescript-eslint/parser',\n    plugins: [..., 'mangling-friendly'],\n    rules: [\n        ...,\n        'mangling-friendly/ban-underscore-prefix-on-public-field': 'warn',\n        'mangling-friendly/enforce-underscore-prefix-on-private-field': 'warn',\n    ]\n}\n\n```\n\n## Rules\n\n### ban-underscore-prefix-on-public-field\n\nThis rule bans underscore prefix on public field.\nMangling object field is effective for reducing bundle size, but this is unsafe process. Mangling only private field is the way to reduce bundle size safely. However, current mangling tool(such as terser) cannot use the type information, so it cannot know whether private or not a property is, and Hard privating with (# sharp) will provide increased bundle size because this should be transpiled for more browser support, so we should add prefix `_` on private field and should not do that on the other field.\n\n#### examples\n\n```javascript\nclass Hoge {\n    private _hoge: string; // not throw warning\n    public hoge: string; // not throw warning\n    public _bar: string; // throw warning\n    public fuga() {} // not throw warning\n    public _hello() {} // throw warning\n}\n\nconst obj = {\n    fuga: \"hoge\" // not throw warning\n    _bar: \"hoge\" // throw warning\n}\n```\n\nfor more examples, plz see the test.\n\n### enforce-underscore-prefix-on-private-field\n\nThis rule enforces underscore prefix on private field.\nMangling object field is effective for reducing bundle size, but this is unsafe process. Mangling only private field is the way to reduce bundle size safely. However, current mangling tool(such as terser) cannot use the type information, so it cannot know whether private or not a property is, and Hard privating with (# sharp) will provide increased bundle size because this should be transpiled for more browser support, so we should add prefix `_` on private field and should not do that on the other field.\n\n#### examples\n\n```javascript\nclass Hoge {\n    private _hoge: string; // not throw warning\n    public hoge: string; // not throw warning\n    private bar: string; // throw warning\n    private fuga() {} // throw warning\n}\n```\n\nfor more examples, plz see the test.\n\nI strongly recommend that `ban-underscore-prefix-on-public-field` and `enforce-underscore-prefix-on-private-field` are used together, and mangled with the above mangling rule. \n\n```\nmangle: {\n    properties: {\n        regex: /^_/,\n    }\n},\n```\n\nFurther optimization is possible by using the ban-computed-property-access rule (described below) to prohibit computed property access, and by making all object properties subject to minify.\n\n### ban-computed-property-access\n\nThis rule bans computed property access. A computed property access can break minified property.\n\n```javascript\n\n// mangler can not minify such a fuga property as a default behavior\n\nhoge.fuga = \"fuga\";\nconsole.log(hoge.fuga);\n\n// into\n\na.fuga = \"fuga\";\nconsole.log(a.fuga);\n\n// because such a output code will break with property minifying.\n\nconst hogeProp = getRandomlyHogeProperty() // return fuga or bar;\nhoge.fuga = \"fuga\";\nhoge.bar = \"bar\";\nconsole.log(hoge[hogeProp]);\n```\n\n#### examples\n\n```javascript\nhoge[fuga] // throw warnings\nhoge.fuga // not throw warnings\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshinyaigeek%2Feslint-plugin-reduce-bundle-size","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshinyaigeek%2Feslint-plugin-reduce-bundle-size","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshinyaigeek%2Feslint-plugin-reduce-bundle-size/lists"}