-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: update developer tools (#3382)
- Loading branch information
1 parent
bf2672e
commit 9fcd553
Showing
53 changed files
with
576 additions
and
328 deletions.
There are no files selected for viewing
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,24 @@ | ||
import { createBuilder } from './util'; | ||
|
||
const update = createBuilder([ | ||
[ | ||
'Update config', | ||
() => require('../modules/eslint-plugin/scripts/generate-config'), | ||
], | ||
[ | ||
'Update overview', | ||
() => require('../modules/eslint-plugin/scripts/generate-overview'), | ||
], | ||
[ | ||
'Update docs', | ||
() => require('../modules/eslint-plugin/scripts/generate-docs'), | ||
], | ||
]); | ||
|
||
update({ | ||
scope: '@ngrx', | ||
packages: [{ name: 'eslint-plugin' }], | ||
}).catch((err) => { | ||
console.error(err); | ||
process.exit(1); | ||
}); |
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
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,101 @@ | ||
import { readFileSync, writeFileSync } from 'fs'; | ||
import { EOL } from 'os'; | ||
import { format, resolveConfig } from 'prettier'; | ||
import { rules } from '../src/rules'; | ||
import { configs } from '../src/configs'; | ||
|
||
const prettierConfig = resolveConfig.sync(__dirname); | ||
const OVERVIEW = './projects/ngrx.io/content/guide/eslint-plugin/overview.md'; | ||
const GH_CONFIGS = | ||
'https://github.com/ngrx/platform/blob/master/modules/eslint-plugin/src/configs'; | ||
|
||
generateRules(); | ||
generateConfigurations(); | ||
|
||
function generateRules() { | ||
const moduleRules = Object.entries(rules).reduce<Record<string, string[][]>>( | ||
(all, [ruleName, { meta }]) => { | ||
all[meta.ngrxModule] = (all[meta.ngrxModule] ?? []).concat([ | ||
[ | ||
`[@ngrx/${ruleName}]${ | ||
meta.docs?.url | ||
? '(' + | ||
meta.docs.url | ||
.replace('https://ngrx.io', '') | ||
.replace('.md', '') + | ||
')' | ||
: '' | ||
}`, | ||
meta.docs?.description ?? 'TODO', | ||
meta.type, | ||
`${meta.docs?.recommended}`, | ||
meta.fixable ? 'Yes' : 'No', | ||
meta.hasSuggestions ? 'Yes' : 'No', | ||
meta.schema.length ? 'Yes' : 'No', | ||
meta.docs?.requiresTypeChecking ? 'Yes' : 'No', | ||
], | ||
]); | ||
return all; | ||
}, | ||
{} | ||
); | ||
|
||
const tableHeader = `| Name | Description | Recommended | Category | Fixable | Has suggestions | Configurable | Requires type information | ||
| --- | --- | --- | --- | --- | --- | --- | --- |`; | ||
|
||
const configTable = Object.entries(moduleRules).map( | ||
([ngrxModule, pluginRules]) => { | ||
const tableBody = pluginRules | ||
.map((rule) => `|${rule.join('|')}|`) | ||
.join(EOL); | ||
const table = [tableHeader, tableBody].join(EOL); | ||
|
||
return [`### ${ngrxModule}`, table].join(EOL); | ||
} | ||
); | ||
|
||
const overview = readFileSync(OVERVIEW, 'utf-8'); | ||
const start = overview.indexOf('<!-- RULES-CONFIG:START -->'); | ||
const end = overview.indexOf('<!-- RULES-CONFIG:END -->'); | ||
|
||
const newOverview = format( | ||
`${overview.substring(0, start + '<!-- RULES-CONFIG:START -->'.length)} | ||
${configTable.join(EOL)} | ||
${overview.substring(end)}`, | ||
{ | ||
parser: 'markdown', | ||
...prettierConfig, | ||
} | ||
); | ||
|
||
writeFileSync(OVERVIEW, newOverview); | ||
} | ||
|
||
function generateConfigurations() { | ||
const tableHeader = `| Name | | ||
| --- |`; | ||
|
||
const config = Object.keys(configs); | ||
|
||
const overview = readFileSync(OVERVIEW, 'utf-8'); | ||
const start = overview.indexOf('<!-- CONFIGURATIONS-CONFIG:START -->'); | ||
const end = overview.indexOf('<!-- CONFIGURATIONS-CONFIG:END -->'); | ||
|
||
const configTable = config.map( | ||
(configName) => `| [${configName}](${GH_CONFIGS}/${configName}.ts) |` | ||
); | ||
const newOverview = format( | ||
`${overview.substring( | ||
0, | ||
start + '<!-- CONFIGURATIONS-CONFIG:START -->'.length | ||
)} | ||
${[tableHeader, ...configTable].join(EOL)} | ||
${overview.substring(end)}`, | ||
{ | ||
parser: 'markdown', | ||
...prettierConfig, | ||
} | ||
); | ||
|
||
writeFileSync(OVERVIEW, newOverview); | ||
} |
This file was deleted.
Oops, something went wrong.
3 changes: 1 addition & 2 deletions
3
modules/eslint-plugin/src/configs/all-requiring-type-checking.ts
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
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
3 changes: 1 addition & 2 deletions
3
modules/eslint-plugin/src/configs/effects-requiring-type-checking.ts
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
3 changes: 1 addition & 2 deletions
3
modules/eslint-plugin/src/configs/effects-strict-requiring-type-checking.ts
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
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
3 changes: 1 addition & 2 deletions
3
modules/eslint-plugin/src/configs/recommended-requiring-type-checking.ts
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
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
3 changes: 1 addition & 2 deletions
3
modules/eslint-plugin/src/configs/strict-requiring-type-checking.ts
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
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export const docsUrl = (ruleName: string) => | ||
`https://github.com/timdeschryver/eslint-plugin-ngrx/tree/main/docs/rules/${ruleName}.md`; | ||
`https://ngrx.io/guide/eslint-plugin/rules/${ruleName}.md`; |
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
Oops, something went wrong.