Skip to content

Commit

Permalink
Enable id-denylist and id-length in base config (#200)
Browse files Browse the repository at this point in the history
This modifies the base config to forbid specific identifier names (e.g. `err`, `cb`) and variable and function names shorter than two characters, with some common and reasonable exceptions.
  • Loading branch information
rekmarks committed Sep 8, 2022
1 parent e654c81 commit 6560a01
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"setup": "yarn install && yarn allow-scripts && yarn patch-package",
"lint:eslint": "yarn eslint . --ext ts,js",
"lint:config-validation": "node ./scripts/validate-configs.js",
"lint:misc": "prettier '**/*.json' '**/*.md' '!**/CHANGELOG.md' '**/*.yml' --ignore-path .gitignore",
"lint:misc": "prettier '**/*.json' '!**/rules-snapshot.json' '**/*.md' '!**/CHANGELOG.md' '**/*.yml' --ignore-path .gitignore",
"lint": "yarn lint:eslint && yarn lint:misc --check && yarn lint:config-validation",
"lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write && yarn lint:config-validation --write"
},
Expand Down
22 changes: 22 additions & 0 deletions packages/base/rules-snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,28 @@
"getter-return": "error",
"grouped-accessor-pairs": "error",
"guard-for-in": "error",
"id-denylist": [
"error",
"buf",
"cat",
"err",
"cb",
"cfg",
"hex",
"int",
"msg",
"num",
"opt",
"sig"
],
"id-length": [
"error",
{
"min": 2,
"properties": "never",
"exceptionPatterns": ["_", "a", "b", "i", "j", "k"]
}
],
"implicit-arrow-linebreak": "off",
"import/default": "error",
"import/export": "error",
Expand Down
24 changes: 24 additions & 0 deletions packages/base/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,30 @@ module.exports = {
'func-name-matching': 'error',
'grouped-accessor-pairs': 'error',
'guard-for-in': 'error',
'id-denylist': [
// This sets this rule to 'error', the rest are the forbidden IDs.
'error',
// These are basically all useless contractions.
'buf',
'cat',
'err',
'cb',
'cfg',
'hex',
'int',
'msg',
'num',
'opt',
'sig',
],
'id-length': [
'error',
{
min: 2,
properties: 'never',
exceptionPatterns: ['_', 'a', 'b', 'i', 'j', 'k'],
},
],
'lines-between-class-members': 'error',
'max-statements-per-line': [
'error',
Expand Down

0 comments on commit 6560a01

Please sign in to comment.