Installations
npm install eslint-config-nstarter
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
20.16.0
NPM Version
10.8.1
Score
54
Supply Chain
88.4
Quality
75.7
Maintenance
100
Vulnerability
96.1
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (75.41%)
TypeScript (22.44%)
CSS (1.07%)
Groovy (0.45%)
HTML (0.25%)
Dockerfile (0.21%)
Makefile (0.1%)
Shell (0.06%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
jiandaoyun
Download Statistics
Total Downloads
5,294
Last Day
1
Last Week
9
Last Month
83
Last Year
1,020
GitHub Statistics
1 Stars
514 Commits
2 Watchers
4 Branches
15 Contributors
Updated on Sep 04, 2024
Bundle Size
175.00 B
Minified
151.00 B
Minified + Gzipped
Package Meta Information
Latest Version
4.0.1
Package Id
eslint-config-nstarter@4.0.1
Unpacked Size
60.76 kB
Size
16.84 kB
File Count
8
NPM Version
10.8.1
Node Version
20.16.0
Published on
Aug 02, 2024
Total Downloads
Cumulative downloads
Total Downloads
5,294
Last Day
-50%
1
Compared to previous day
Last Week
-59.1%
9
Compared to previous week
Last Month
50.9%
83
Compared to previous month
Last Year
-10.6%
1,020
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
6
Peer Dependencies
5
Dev Dependencies
44
NStarter ESLint 规则
NStarter ESLint 规则在腾讯 Alloy ESLint 规则基础上定制而来,用于规范化 nstarter 系列项目的代码编写规范。
规则列表
名称 | 包含规则 | 解析器 |
---|---|---|
标准规则 | ESLint 规则 | @babel/eslint-parser |
TypeScript | ESLint 规则、@typescript-eslint | @typescript-eslint/parser |
设计理念
- 传承 ESLint 的理念,帮助大家建立自己的规则
- 高度的自动化:先进的规则管理,测试即文档即[网站][]
传承 [ESLint 的理念][],帮助大家建立自己的规则
大家还记得 ESLint 是怎么打败 JSHint 成为最受欢迎的 js 代码检查工具吗?就是因为 ESLint 推崇的插件化、配置化,满足了不同团队不同技术栈的个性的需求。
所以 eslint-config-nstarter 也传承了 ESLint 的设计理念,不会强调必须要使用我们这套规则,而是通过文档、示例、测试、网站等方便大家参考 nstarter 的规则,在此基础上做出自己的个性化。
高度的自动化:先进的规则管理,测试即文档即[网站][]
无情的推动自动化
eslint-config-nstarter 通过高度的自动化,将一切能自动化管理的过程都交给脚本处理,其中包括了:
- 通过 GitHub Actions,自动每周检查 ESLint 及相关插件是否有新版本,新版本中是否有新规则需要我们添加
- 自动检查我们的规则是否包含了 Prettier 的规则
- 自动检查我们的规则是否包含了已废弃(deprecated)的规则
除此之外,通过自动化的脚本,我们甚至可以将成百上千个 ESLint 配置文件分而治之,每个规则在一个单独的目录下管理:
- 通过脚本将单个的配置整合成最终的一个配置
- 通过脚本将单个配置中的 description 和 reason 构建成文档[网站][],方便大家查看
- 通过脚本将单个配置中的
bad.js
和good.js
输出到[网站][]中,甚至可以直接在[网站][]中看到bad.js
的(真实运行 ESLint 脚本后的)报错信息
这样的好处是显而易见的,测试即文档即[网站][],我们可以只在一个地方维护规则和测试,其他工作都交给自动化脚本,极大的降低了维护的成本。简单来说,当我们有个新规则需要添加时,只需要写三个文件 test/index/another-rule/.eslintrc.js
, test/index/another-rule/bad.js
, test/index/another-rule/good.js
即可。
使用方法
标准规则
安装:
1npm install --save-dev eslint eslint-config-nstarter
在你的项目根目录下创建 .eslintrc.js
,并将以下内容复制到文件中:
1module.exports = { 2 extends: [ 3 'nstarter', 4 ], 5 env: { 6 // 这里填入你的项目用到的环境 7 // 它们预定义了不同环境的全局变量,比如: 8 // 9 // browser: true, 10 // node: true, 11 // mocha: true, 12 // jest: true 13 }, 14 globals: { 15 // 这里填入你的项目需要的全局变量 16 // false 表示这个全局变量不允许被重新赋值,比如: 17 // 18 // myGlobal: false 19 }, 20 rules: { 21 // 这里填入你的项目需要的个性化配置 22 } 23};
TypeScript
安装:
1npm install --save-dev eslint typescript eslint-config-nstarter
在你的项目根目录下创建 .eslintrc.js
,并将以下内容复制到文件中:
1module.exports = { 2 extends: [ 3 'nstarter', 4 'nstarter/typescript', 5 ], 6 env: { 7 // 这里填入你的项目用到的环境 8 // 它们预定义了不同环境的全局变量,比如: 9 // 10 // browser: true, 11 // node: true, 12 // mocha: true, 13 // jest: true 14 }, 15 globals: { 16 // 这里填入你的项目需要的全局变量 17 // false 表示这个全局变量不允许被重新赋值,比如: 18 // 19 // myGlobal: false 20 }, 21 rules: { 22 // 这里填入你的项目需要的个性化配置 23 } 24};
Troubleshootings
在 VSCode 中使用
在 VSCode 中,默认 ESLint 并不能识别 .ts
文件,需要在「文件 => 首选项 => 设置」里做如下配置:
1{ 2 "eslint.validate": [ 3 "javascript", 4 "typescript" 5 ] 6}
VSCode 中的 autoFixOnSave 没有效果
如果需要针对 .ts
文件开启 ESLint 的 autoFix,则需要配置成:
1{ 2 "eslint.autoFixOnSave": true, 3 "eslint.validate": [ 4 "javascript", 5 { 6 "language": "typescript", 7 "autoFix": true 8 } 9 ] 10}
Testing
1npm test
常用命令
1# 安装依赖 2npm install 3 4# 构建 eslintrc 配置 5npm run build 6 7# 执行测试 8npm test 9 10# 自动修复格式错误 11npm run prettier:fix 12 13# 发布新版本 14npm version <major|minor|patch> 15git push --follow-tags 16npm publish
参考

No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/ci.yml:1
- Warn: no topLevel permission defined: .github/workflows/rulesCoverage.yml:1
- Info: no jobLevel write permissions found
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
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
license file not detected
Details
- Warn: project does not have a license file
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:9: update your workflow using https://app.stepsecurity.io/secureworkflow/jiandaoyun/nstarter-eslint-config/ci.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/jiandaoyun/nstarter-eslint-config/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/jiandaoyun/nstarter-eslint-config/ci.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:35: update your workflow using https://app.stepsecurity.io/secureworkflow/jiandaoyun/nstarter-eslint-config/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/rulesCoverage.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/jiandaoyun/nstarter-eslint-config/rulesCoverage.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/rulesCoverage.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/jiandaoyun/nstarter-eslint-config/rulesCoverage.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/rulesCoverage.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/jiandaoyun/nstarter-eslint-config/rulesCoverage.yml/master?enable=pin
- Warn: containerImage not pinned by hash: Dockerfile:4
- Warn: containerImage not pinned by hash: Dockerfile:13
- Warn: containerImage not pinned by hash: Dockerfile:17
- Warn: npmCommand not pinned by hash: Dockerfile:10
- Warn: npmCommand not pinned by hash: .github/workflows/ci.yml:24
- Warn: npmCommand not pinned by hash: .github/workflows/rulesCoverage.yml:30
- Info: 0 out of 4 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 3 third-party GitHubAction dependencies pinned
- Info: 0 out of 3 containerImage dependencies pinned
- Info: 0 out of 3 npmCommand dependencies pinned
Reason
11 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7
- Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-qw6h-vgh9-j6wx
- Warn: Project is vulnerable to: GHSA-c7qv-q95q-8v27
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j
- Warn: Project is vulnerable to: GHSA-rhx6-c78j-4q9w
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p
- Warn: Project is vulnerable to: GHSA-4vvj-4cpr-p986
Score
2.4
/10
Last Scanned on 2025-02-03
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