Gathering detailed insights and metrics for eslint-plugin-tree-shaking
Gathering detailed insights and metrics for eslint-plugin-tree-shaking
Gathering detailed insights and metrics for eslint-plugin-tree-shaking
Gathering detailed insights and metrics for eslint-plugin-tree-shaking
eslint-plugin-better-tree-shaking
ESLint plugin for better tree shaking
eslint-plugin-you-dont-need-momentjs
Check better alternatives you can use without momentjs
@emiplegiaqmnpm/aliquid-porro-quidem
The @emiplegiaqmnpm/aliquid-porro-quidem library is a 0 dependency library with several exports to support general app development. This library has several exports to limit what is loaded into memory & to make tree-shaking less intensive. Some of the und
npm install eslint-plugin-tree-shaking
Typescript
Module System
Min. Node Version
Node Version
NPM Version
96.3
Supply Chain
99.5
Quality
77.7
Maintenance
100
Vulnerability
100
License
TypeScript (99.55%)
Shell (0.29%)
JavaScript (0.16%)
Total Downloads
3,480,776
Last Day
881
Last Week
13,599
Last Month
99,177
Last Year
1,530,714
201 Stars
149 Commits
9 Forks
5 Watching
278 Branches
6 Contributors
Latest Version
1.12.2
Package Id
eslint-plugin-tree-shaking@1.12.2
Unpacked Size
57.61 kB
Size
10.63 kB
File Count
8
NPM Version
9.8.1
Node Version
18.20.4
Publised On
19 Jul 2024
Cumulative downloads
Total Downloads
Last day
-81.5%
881
Compared to previous day
Last week
-42.3%
13,599
Compared to previous week
Last month
-36.3%
99,177
Compared to previous month
Last year
22%
1,530,714
Compared to previous year
22
Marks all side-effects in module initialization that will interfere with tree-shaking
This plugin is intended as a means for library developers to identify patterns that will interfere with the tree-shaking algorithm of their module bundler (i.e. rollup or webpack).
JavaScript:
1myGlobal = 17; 2const x = { [globalFunction()]: "myString" }; 3 4export default 42;
Rollup output:
1myGlobal = 17; 2const x = { [globalFunction()]: "myString" }; 3 4var index = 42; 5 6export default index;
ESLint output:
1:1 error Cannot determine side-effects of assignment to global variable
2:13 error Cannot determine side-effects of calling global function
This plugin is most useful when you integrate ESLint with your editor.
You'll first need to install ESLint:
$ npm i eslint --save-dev
Next, install eslint-plugin-tree-shaking
:
$ npm install eslint-plugin-tree-shaking --save-dev
Note: If you installed ESLint globally (using the -g
flag) then you must also install eslint-plugin-tree-shaking
globally.
Add tree-shaking
to the plugins section of your .eslintrc
configuration file. You can omit the eslint-plugin-
prefix:
1{ 2 "plugins": ["tree-shaking"] 3}
Then add the rule no-side-effects-in-initialization
to the rules section:
1{ 2 "rules": { 3 "tree-shaking/no-side-effects-in-initialization": 2 4 } 5}
To prevent false positives, configure like this:
1{ 2 "rules": { 3 "tree-shaking/no-side-effects-in-initialization": [ 4 2, 5 { 6 "noSideEffectsWhenCalled": [ 7 { "function": "Object.freeze" }, 8 { 9 "module": "react", 10 "functions": ["createContext", "createRef"] 11 }, 12 { 13 "module": "zod", 14 "functions": ["array", "string", "nativeEnum", "number", "object", "optional"] 15 }, 16 { 17 "module": "my/local/module", 18 "functions": ["foo", "bar", "baz"] 19 } 20 ] 21 } 22 ] 23 } 24}
ESLint only ever analyzes one file at a time and by default, this plugin assumes that all imported functions have side-effects. If this is not the case, this plugin supports magic comments you can add before identifiers in imports and exports to specify that you assume an import or export to be a pure function. Examples:
By default, imported functions are assumed to have side-effects:
JavaScript:
1import { x } from "./some-file"; 2x();
ESLint output:
1:9 error Cannot determine side-effects of calling imported function
You can mark a side-effect free import with a magic comment:
JavaScript:
1import { /* tree-shaking no-side-effects-when-called */ x } from "./some-file"; 2x();
No ESLint errors
By default, exported functions are not checked for side-effects:
JavaScript:
1export const x = globalFunction;
No ESLint errors
You can check exports for side-effects with a magic comment:
JavaScript:
1export const /* tree-shaking no-side-effects-when-called */ x = globalFunction;
ESLint output:
1:65 error Cannot determine side-effects of calling global function
This plugin is in development. If you want to contribute, please read CONTRIBUTING.md.
This plugin implements a side-effect detection algorithm similar to what rollup uses to determine if code can be removed safely. However, there is no one-to-one correspondence. If you find that you have code that
please--if no-one else has done so yet--check the guidelines and file an issue!
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
all changesets reviewed
Reason
license file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 4
Details
Reason
8 existing vulnerabilities detected
Details
Reason
0 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-12-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More