-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: support flat config chore: generate rules by scripts chore: run `lint:js` * chore: update `export` same as pre version * chore: update README.md
- Loading branch information
Showing
7 changed files
with
152 additions
and
53 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
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,37 @@ | ||
import process from 'node:process' | ||
import { resolve } from 'node:path' | ||
import fs from 'node:fs' | ||
|
||
const cwd = process.cwd() | ||
|
||
const rulesDir = resolve(cwd, 'src', 'rules') | ||
|
||
function camelCase(str: string) { | ||
return str | ||
.replace(/[^\w-]+/, '') | ||
.replace(/-([a-z])/g, (_, c) => c.toUpperCase()) | ||
} | ||
|
||
function generateRules() { | ||
const targetFile = 'index.ts' | ||
|
||
const header = '/* GENERATED BY SCRIPTS, DO NOT EDIT DIRECTLY */' | ||
|
||
const rules = fs.readdirSync(rulesDir) | ||
.filter(i => i !== targetFile) | ||
.map(i => i.replace('.ts', '')) | ||
|
||
const content = [ | ||
header, | ||
...rules.map(i => `import ${camelCase(i)}, { RULE_NAME as ${camelCase(i)}Name } from './${i}'`), | ||
'', | ||
'export default {', | ||
...rules.map(i => ` [${camelCase(i)}Name]: ${camelCase(i)},`), | ||
'}', | ||
'' | ||
].join('\n') | ||
|
||
fs.writeFileSync(resolve(rulesDir, targetFile), content) | ||
} | ||
|
||
generateRules() |
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,16 @@ | ||
/* GENERATED BY SCRIPTS, DO NOT EDIT DIRECTLY */ | ||
import neverExportInitializedStore, { RULE_NAME as neverExportInitializedStoreName } from './never-export-initialized-store' | ||
import noDuplicateStoreIds, { RULE_NAME as noDuplicateStoreIdsName } from './no-duplicate-store-ids' | ||
import noReturnGlobalProperties, { RULE_NAME as noReturnGlobalPropertiesName } from './no-return-global-properties' | ||
import preferSingleStorePerFile, { RULE_NAME as preferSingleStorePerFileName } from './prefer-single-store-per-file' | ||
import preferUseStoreNamingConvention, { RULE_NAME as preferUseStoreNamingConventionName } from './prefer-use-store-naming-convention' | ||
import requireSetupStorePropertiesExport, { RULE_NAME as requireSetupStorePropertiesExportName } from './require-setup-store-properties-export' | ||
|
||
export default { | ||
[neverExportInitializedStoreName]: neverExportInitializedStore, | ||
[noDuplicateStoreIdsName]: noDuplicateStoreIds, | ||
[noReturnGlobalPropertiesName]: noReturnGlobalProperties, | ||
[preferSingleStorePerFileName]: preferSingleStorePerFile, | ||
[preferUseStoreNamingConventionName]: preferUseStoreNamingConvention, | ||
[requireSetupStorePropertiesExportName]: requireSetupStorePropertiesExport | ||
} |
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