forked from typescript-eslint/typescript-eslint
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEAT] Add tool to generate recommended config (typescript-eslint#204)
- Loading branch information
1 parent
9a2d3bc
commit 0a858be
Showing
4 changed files
with
44 additions
and
5 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
packages/eslint-plugin-typescript/lib/configs/recommended.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"rules": { | ||
"class-name-casing": "error", | ||
"no-unused-vars": "error" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
packages/eslint-plugin-typescript/tools/update-recommended.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
"use strict"; | ||
|
||
const path = require("path"); | ||
const fs = require("fs"); | ||
const requireIndex = require("requireindex"); | ||
|
||
/** | ||
* Generate recommended configuration | ||
* @returns {void} | ||
*/ | ||
function generate() { | ||
// replace this with Object.entries when node > 8 | ||
const allRules = requireIndex(path.resolve(__dirname, "../lib/rules")); | ||
const rules = Object.keys(allRules) | ||
.filter(key => allRules[key].meta.docs.recommended) | ||
.reduce((config, item) => { | ||
config[item] = "error"; | ||
return config; | ||
}, {}); | ||
|
||
const filePath = path.resolve(__dirname, "../lib/configs/recommended.json"); | ||
|
||
fs.writeFileSync(filePath, `${JSON.stringify({ rules }, null, 4)}\n`); | ||
} | ||
|
||
generate(); |