ESLint plugin to prefer arrow functions
Installations
npm install eslint-plugin-prefer-arrow
Score
85.6
Supply Chain
75.7
Quality
74.3
Maintenance
100
Vulnerability
98.9
License
Releases
Unable to fetch releases
Developer
TristonJ
Developer Guide
Module System
CommonJS
Min. Node Version
Typescript Support
No
Node Version
14.15.4
NPM Version
6.14.10
Statistics
55 Stars
66 Commits
10 Forks
2 Watching
5 Branches
8 Contributors
Updated on 21 Oct 2024
Bundle Size
4.73 kB
Minified
1.73 kB
Minified + Gzipped
Languages
JavaScript (100%)
Total Downloads
Cumulative downloads
Total Downloads
142,797,254
Last day
-6%
164,024
Compared to previous day
Last week
1%
912,755
Compared to previous week
Last month
9.2%
3,824,809
Compared to previous month
Last year
3.8%
43,567,573
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Peer Dependencies
1
Dev Dependencies
5
eslint-plugin-prefer-arrow
ESLint plugin to prefer arrow functions. By default, the plugin allows usage of function
as a member of an Object's prototype, but this can be changed with the property disallowPrototype
. Functions referencing this
will also be allowed. Alternatively, with the singleReturnOnly
option, this plugin only reports functions where converting to an arrow function would dramatically simplify the code.
Class methods will not produce errors unless the classPropertiesAllowed
flag is set.
This plugin will automatically fix your code using ESLint's --fix
option, as long as you use the singleReturnOnly
option.
Installation
Install the npm package
1# If eslint is installed globally 2npm install -g eslint-plugin-prefer-arrow 3 4# If eslint is installed locally 5npm install -D eslint-plugin-prefer-arrow
Add the plugin to the plugins
section and the rule to the rules
section in your .eslintrc
1"plugins": [ 2 "prefer-arrow" 3], 4"rules": { 5 "prefer-arrow/prefer-arrow-functions": [ 6 "warn", 7 { 8 "disallowPrototype": true, 9 "singleReturnOnly": false, 10 "classPropertiesAllowed": false 11 } 12 ] 13}
Configuration
disallowPrototype
: If set to true, the plugin will warn iffunction
is used anytime. Otherwise, the plugin allows usage offunction
if it is a member of an Object's prototype.singleReturnOnly
: If set to true, the plugin will only warn forfunction
declarations which only contain a return statement. These often look much better when declared as arrow functions without braces. Works well in conjunction with ESLint's built-in arrow-body-style set toas-needed
.classPropertiesAllowed
: If set to true, the plugin will warn about functions which could be replaced with arrow functions defined as class instance fields. Enable if you're using Babel's transform-class-properties plugin.allowStandaloneDeclarations
: If set to true, the plugin will ignore top-level function declarations (the plugin will still warn about "inner" functions, for example, function declarations inside other functions).
Autofixing
To autofix your code, simply run ESLint with the --fix
option. Note that this only works when the singleReturnOnly
option is set to true.
1eslint --fix src
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 3/20 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 14 are checked with a SAST tool
Reason
16 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-9vvw-cc9w-f27h
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-h6ch-v84p-w6p9
- Warn: Project is vulnerable to: GHSA-ww39-953v-wcq6
- Warn: Project is vulnerable to: GHSA-qh2h-chj9-jffq
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m / GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
Score
2.1
/10
Last Scanned on 2024-11-25
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