Gathering detailed insights and metrics for @zhcode/eslint-config-alloy
Gathering detailed insights and metrics for @zhcode/eslint-config-alloy
npm install @zhcode/eslint-config-alloy
Typescript
Module System
Node Version
NPM Version
JavaScript (73.11%)
TypeScript (15.93%)
Vue (10.03%)
CSS (0.72%)
HTML (0.17%)
Shell (0.05%)
Love this project? Help keep it running — sponsor us today! 🚀
Total Downloads
785
Last Day
1
Last Week
5
Last Month
18
Last Year
183
2,652 Stars
459 Commits
314 Forks
41 Watchers
6 Branches
16 Contributors
Updated on Feb 05, 2025
Minified
Minified + Gzipped
Latest Version
1.0.0
Package Id
@zhcode/eslint-config-alloy@1.0.0
Unpacked Size
923.39 kB
Size
167.08 kB
File Count
931
NPM Version
8.0.0
Node Version
14.17.4
Cumulative downloads
Total Downloads
Last Day
0%
1
Compared to previous day
Last Week
-44.4%
5
Compared to previous week
Last Month
100%
18
Compared to previous month
Last Year
-30.2%
183
Compared to previous year
35
English / 简体中文
The AlloyTeam ESLint config is not only a progressive ESLint config for your React/Vue/TypeScript projects but also the best reference for configuring your personalized ESLint rules.
Please choose the following configuration based on the technology stack used by your project:
Prettier is a code formatting tool that offers fewer options but is more professional than the style-related rules in ESLint.
Now that Prettier has become a necessary tool in front-end projects, eslint-config-alloy does not need to maintain the style-related rules in ESLint anymore, so we completely removed all Prettier related rules in the v3 version, and use ESLint to check logical errors which it's good at.
As for whether two spaces or four spaces are used for indentation and whether there is a semicolon at the end, you can configure it in the project's .prettierrc.js
. Of course, we also provide a recommended Prettier configuration for your reference.
Don't you remember how ESLint defeated JSHint and became the most popular JS code inspection tool? It is because of the plugin and configuration that ESLint advocates, which meets the individual needs of different technology stacks of different teams.
Therefore, eslint-config-alloy also inherits the philosophy of ESLint. It will not emphasize the need to use our config. Instead, we help you to make your config by reference our completed documents, examples, tests, websites, etc.
Relentless push automation
eslint-config-alloy
uses a high degree of automation to hand over all processes that can be managed automatically, including:
Also, through automated scripts, we can even divide and conquer thousands of ESLint configuration files, and each rule is managed in a separate directory:
bad.js
and good.js
in a single configuration are output to website by script, and you can even see the error message (which are run in a real ESLint script) in the bad.js
of websiteThe benefits of this are very obvious — test as a document, as a website. We can maintain the rules and tests in one place. Other tasks are handed over to an automated script, which greatly reduces the maintenance cost. In short, when we have a new rule to add, we only need to write three files test/index/another-rule/.eslintrc.js
, test/index/another-rule/bad.js
, test/index/another-rule/good.js
.
ESLint is updated very quickly, there is a new version almost every week, sometimes there are new rules, sometimes existing rules are deprecated, and related plug-ins (React/Vue/TypeScript) will be updated from time to time. Without automation tools, it is difficult to follow up.
And eslint-config-alloy
can receive the [greenkeeper issue] (https://github.com/AlloyTeam/eslint-config-alloy/issues/127) as soon as possible through the above automation tools, tell us which plugin has been updated, and the travis-ci build log will tell us which rules need to be added:
In this way, we can follow the latest rules in a time when the front-end community is changing rapidly, and always keep the vitality and advanced of eslint-config-alloy
.
1npm install --save-dev eslint @babel/eslint-parser eslint-config-alloy
Create an .eslintrc.js
in the root directory of your project, then copy the following content into it:
1module.exports = { 2 extends: [ 3 'alloy', 4 ], 5 env: { 6 // Your environments (which contains several predefined global variables) 7 // 8 // browser: true, 9 // node: true, 10 // mocha: true, 11 // jest: true, 12 // jquery: true 13 }, 14 globals: { 15 // Your global variables (setting to false means it's not allowed to be reassigned) 16 // 17 // myGlobal: false 18 }, 19 rules: { 20 // Customize your rules 21 }, 22};
1npm install --save-dev eslint @babel/eslint-parser eslint-plugin-react eslint-config-alloy
Create an .eslintrc.js
in the root directory of your project, then copy the following content into it:
1module.exports = { 2 extends: [ 3 'alloy', 4 'alloy/react', 5 ], 6 env: { 7 // Your environments (which contains several predefined global variables) 8 // 9 // browser: true, 10 // node: true, 11 // mocha: true, 12 // jest: true, 13 // jquery: true 14 }, 15 globals: { 16 // Your global variables (setting to false means it's not allowed to be reassigned) 17 // 18 // myGlobal: false 19 }, 20 rules: { 21 // Customize your rules 22 }, 23};
1npm install --save-dev eslint @babel/eslint-parser vue-eslint-parser eslint-plugin-vue eslint-config-alloy
Create an .eslintrc.js
in the root directory of your project, then copy the following content into it:
1module.exports = { 2 extends: [ 3 'alloy', 4 'alloy/vue', 5 ], 6 env: { 7 // Your environments (which contains several predefined global variables) 8 // 9 // browser: true, 10 // node: true, 11 // mocha: true, 12 // jest: true, 13 // jquery: true 14 }, 15 globals: { 16 // Your global variables (setting to false means it's not allowed to be reassigned) 17 // 18 // myGlobal: false 19 }, 20 rules: { 21 // Customize your rules 22 }, 23};
1npm install --save-dev eslint typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-config-alloy
Create an .eslintrc.js
in the root directory of your project, then copy the following content into it:
1module.exports = { 2 extends: [ 3 'alloy', 4 'alloy/typescript', 5 ], 6 env: { 7 // Your environments (which contains several predefined global variables) 8 // 9 // browser: true, 10 // node: true, 11 // mocha: true, 12 // jest: true, 13 // jquery: true 14 }, 15 globals: { 16 // Your global variables (setting to false means it's not allowed to be reassigned) 17 // 18 // myGlobal: false 19 }, 20 rules: { 21 // Customize your rules 22 }, 23};
1npm install --save-dev eslint typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-react eslint-config-alloy
Create an .eslintrc.js
in the root directory of your project, then copy the following content into it:
1module.exports = { 2 extends: [ 3 'alloy', 4 'alloy/react', 5 'alloy/typescript', 6 ], 7 env: { 8 // Your environments (which contains several predefined global variables) 9 // 10 // browser: true, 11 // node: true, 12 // mocha: true, 13 // jest: true, 14 // jquery: true 15 }, 16 globals: { 17 // Your global variables (setting to false means it's not allowed to be reassigned) 18 // 19 // myGlobal: false 20 }, 21 rules: { 22 // Customize your rules 23 }, 24};
ESLint will not lint .vue
, .ts
or .tsx
files in VSCode by default, you need to set your .vscode/settings.json
like this:
1{ 2 "eslint.validate": [ 3 "javascript", 4 "javascriptreact", 5 "vue", 6 "typescript", 7 "typescriptreact" 8 ] 9}
If you want to enable auto-fix-on-save, you need to set your .vscode/settings.json
like this:
1{ 2 "eslint.validate": ["javascript", "javascriptreact", "vue", "typescript", "typescriptreact"], 3 "editor.codeActionsOnSave": { 4 "source.fixAll.eslint": true 5 }, 6}
eslint-config-alloy
does not include all style-related rules in v3, so there is no need to install eslint-config-prettier
. Just install prettier
and related VSCode plugins.
Here is a .prettierrc.js
configuration used by AlloyTeam for reference only:
1// .prettierrc.js 2module.exports = { 3 // max 120 characters per line 4 printWidth: 120, 5 // use 2 spaces for indentation 6 tabWidth: 2, 7 // use spaces instead of indentations 8 useTabs: false, 9 // semicolon at the end of the line 10 semi: true, 11 // use single quotes 12 singleQuote: true, 13 // object's key is quoted only when necessary 14 quoteProps: 'as-needed', 15 // use double quotes instead of single quotes in jsx 16 jsxSingleQuote: false, 17 // no comma at the end 18 trailingComma: 'all', 19 // spaces are required at the beginning and end of the braces 20 bracketSpacing: true, 21 // end tag of jsx need to wrap 22 jsxBracketSameLine: false, 23 // brackets are required for arrow function parameter, even when there is only one parameter 24 arrowParens: 'always', 25 // format the entire contents of the file 26 rangeStart: 0, 27 rangeEnd: Infinity, 28 // no need to write the beginning @prettier of the file 29 requirePragma: false, 30 // No need to automatically insert @prettier at the beginning of the file 31 insertPragma: false, 32 // use default break criteria 33 proseWrap: 'preserve', 34 // decide whether to break the html according to the display style 35 htmlWhitespaceSensitivity: 'css', 36 // vue files script and style tags indentation 37 vueIndentScriptAndStyle: false, 38 // lf for newline 39 endOfLine: 'lf', 40 // formats quoted code embedded 41 embeddedLanguageFormatting: 'auto', 42};
A best practice for VSCode is to auto format code with Prettier and autofix errors with ESLint by setting .vscode/settings.json
to this:
1{ 2 "files.eol": "\n", 3 "editor.tabSize": 2, 4 "editor.formatOnSave": true, 5 "editor.defaultFormatter": "esbenp.prettier-vscode", 6 "eslint.validate": ["javascript", "javascriptreact", "vue", "typescript", "typescriptreact"], 7 "editor.codeActionsOnSave": { 8 "source.fixAll.eslint": true 9 } 10}
1# install dependencies 2npm i 3# build eslintrc like index.js, react.js, etc. 4npm run build 5# run tests 6npm test 7# autofix ESLint errors 8npm run eslint:fix 9# autofix prettier errors 10npm run prettier:fix 11# check if all rules are currently covered 12npm run test:rulesCoverage 13# publish new version 14npm version <major|minor|patch> 15git push --follow-tags 16npm publish
Our team initially used Airbnb rules, but because it was too strict, some rules still needed to be personalized, which led to more and more changes in the future and finally decided to maintain a new set. After more than two years of polishing, eslint-config-alloy
is now very mature and progressive and has been welcomed by many teams inside and outside the company.
The standard specification believes that everyone should not waste time in personalized specifications, but the entire community should unify a specification. This statement makes some sense, but it runs against the ESLint's design philosophy. Don't you remember how ESLint defeated JSHint and became the most popular JS code inspection tool? It is because of the plugin and configuration that ESLint advocates, which meets the individual needs of different technology stacks of different teams.
Therefore, eslint-config-alloy
also inherits the philosophy of ESLint. It will not force you to use our config. Instead, we help you to make your config by referencing our examples, tests, websites and so on.
airbnb
eslint-config-alloy
has officially maintained vue
, typescript
and react+typescript
rules. In contrast, airbnb's vue
and typescript
are maintained by third parties.airbnb
It's okay, eslint-config-alloy
believes that different teams and projects can have different configurations from the design concept. Although you choose to use airbnb
, you can still come to our website when you have personalized configuration needs.
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 2/25 approved changesets -- 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
license file not detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
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
Reason
26 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-02-10
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