Node.js 从项目中找到所有未定义的变量
Node.js find all undefinded variable from project
我正在用 Node.js
开发后端 API
有时,我无法进行单元测试,并且 data is not defined
发生错误
有了typescript,我们可以用lint系统解决这个问题。
Angular 9项目,编译系统检测到该问题,自动解决该错误。
但是,如何使用 node.js 项目进行配置?
我检查了 esLint 工具,但是,它似乎在使用 ts
文件
eslint 解决了我的问题
此外,我在 git 提交之前使用 git 钩子检查 eslint
https://gist.github.com/linhmtran168/2286aeafe747e78f53bf
.eslintrc.json
{
"env": {
"es6": true,
"node": true
},
"extends": "eslint:recommended",
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 8,
"sourceType": "module"
},
"rules": {
"indent": [
"off",
4,
{
"FunctionDeclaration": {
"parameters": "first"
},
"FunctionExpression": {
"parameters": "first"
},
"SwitchCase": 1
}
],
"max-len": [
"error",
{
"code": 1000
}
],
"quotes": [
"off",
"single"
],
"semi": [
"warn",
"always"
],
"no-unused-vars": [
"off",
{
"args": "after-used",
"argsIgnorePattern": "^next$"
}
],
"comma-dangle": [
"off",
"always-multiline"
],
"arrow-parens": [
0,
"as-needed",
{
"requireForBlockBody": true
}
],
"eol-last": [
"off",
"always"
],
"no-multiple-empty-lines": [
"off",
{
"max": 1,
"maxEOF": 0
}
],
"prefer-const": "off",
"no-var": "off",
"prefer-arrow-callback": [
"off"
],
"object-curly-spacing": [
"off",
"always"
],
"camelcase": "off",
"eqeqeq": "off",
"no-console": "off",
"no-control-regex": 0,
"no-useless-escape": 0,
"no-constant-condition": "off",
"no-extra-boolean-cast": "off",
"no-empty": "off",
"no-redeclare": "off",
"no-self-assign": "off",
"no-async-promise-executor": "off"
}
}
我正在用 Node.js
开发后端 API
有时,我无法进行单元测试,并且 data is not defined
发生错误
有了typescript,我们可以用lint系统解决这个问题。
Angular 9项目,编译系统检测到该问题,自动解决该错误。
但是,如何使用 node.js 项目进行配置?
我检查了 esLint 工具,但是,它似乎在使用 ts
文件
eslint 解决了我的问题
此外,我在 git 提交之前使用 git 钩子检查 eslint
https://gist.github.com/linhmtran168/2286aeafe747e78f53bf
.eslintrc.json
{
"env": {
"es6": true,
"node": true
},
"extends": "eslint:recommended",
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 8,
"sourceType": "module"
},
"rules": {
"indent": [
"off",
4,
{
"FunctionDeclaration": {
"parameters": "first"
},
"FunctionExpression": {
"parameters": "first"
},
"SwitchCase": 1
}
],
"max-len": [
"error",
{
"code": 1000
}
],
"quotes": [
"off",
"single"
],
"semi": [
"warn",
"always"
],
"no-unused-vars": [
"off",
{
"args": "after-used",
"argsIgnorePattern": "^next$"
}
],
"comma-dangle": [
"off",
"always-multiline"
],
"arrow-parens": [
0,
"as-needed",
{
"requireForBlockBody": true
}
],
"eol-last": [
"off",
"always"
],
"no-multiple-empty-lines": [
"off",
{
"max": 1,
"maxEOF": 0
}
],
"prefer-const": "off",
"no-var": "off",
"prefer-arrow-callback": [
"off"
],
"object-curly-spacing": [
"off",
"always"
],
"camelcase": "off",
"eqeqeq": "off",
"no-console": "off",
"no-control-regex": 0,
"no-useless-escape": 0,
"no-constant-condition": "off",
"no-extra-boolean-cast": "off",
"no-empty": "off",
"no-redeclare": "off",
"no-self-assign": "off",
"no-async-promise-executor": "off"
}
}