-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: move 'utils/rules.ts' to 'rules/index.ts' (#439)
- The `lib/load-rules.ts` file is confusing because it behaves like an index file for the src/rules folder, so adding a comment helps clarify its purpose. - Rename `tools/update-rules.ts` to `tools/update-rules-index.ts`. - Move `utils/rules.ts` to `rules/index.ts`
- Loading branch information
1 parent
fd8bc14
commit 8d9e0a2
Showing
17 changed files
with
98 additions
and
93 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
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,42 @@ | ||
// IMPORTANT! | ||
// This file has been automatically generated by "update-rules-index.ts", | ||
// in order to update its content, update "update-rules-index.ts" and execute "npm run update" | ||
import missingClientOnlyDirectiveValue from "./missing-client-only-directive-value" | ||
import noConflictSetDirectives from "./no-conflict-set-directives" | ||
import noDeprecatedAstroCanonicalurl from "./no-deprecated-astro-canonicalurl" | ||
import noDeprecatedAstroFetchcontent from "./no-deprecated-astro-fetchcontent" | ||
import noDeprecatedAstroResolve from "./no-deprecated-astro-resolve" | ||
import noDeprecatedGetentrybyslug from "./no-deprecated-getentrybyslug" | ||
import noExportsFromComponents from "./no-exports-from-components" | ||
import noSetHtmlDirective from "./no-set-html-directive" | ||
import noSetTextDirective from "./no-set-text-directive" | ||
import noUnusedCssSelector from "./no-unused-css-selector" | ||
import noUnusedDefineVarsInStyle from "./no-unused-define-vars-in-style" | ||
import preferClassListDirective from "./prefer-class-list-directive" | ||
import preferObjectClassList from "./prefer-object-class-list" | ||
import preferSplitClassList from "./prefer-split-class-list" | ||
import semi from "./semi" | ||
import sortAttributes from "./sort-attributes" | ||
import validCompile from "./valid-compile" | ||
import { buildA11yRules } from "../a11y" | ||
|
||
export const originalRules = [ | ||
missingClientOnlyDirectiveValue, | ||
noConflictSetDirectives, | ||
noDeprecatedAstroCanonicalurl, | ||
noDeprecatedAstroFetchcontent, | ||
noDeprecatedAstroResolve, | ||
noDeprecatedGetentrybyslug, | ||
noExportsFromComponents, | ||
noSetHtmlDirective, | ||
noSetTextDirective, | ||
noUnusedCssSelector, | ||
noUnusedDefineVarsInStyle, | ||
preferClassListDirective, | ||
preferObjectClassList, | ||
preferSplitClassList, | ||
semi, | ||
sortAttributes, | ||
validCompile, | ||
] | ||
export const rules = [...originalRules, ...buildA11yRules()] |
This file was deleted.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import path from "path" | ||
import { rules } from "./lib/load-rules" | ||
import { formatAndSave } from "./lib/utils" | ||
|
||
/** | ||
* Convert text to camelCase | ||
*/ | ||
function camelCase(str: string) { | ||
return str.replace(/[-_](\w)/gu, (_, c) => (c ? c.toUpperCase() : "")) | ||
} | ||
|
||
/** | ||
* Map rule name to import statement | ||
*/ | ||
function mapRuleNameToImport(name: string) { | ||
return `import ${camelCase(name)} from "./${name}"` | ||
} | ||
|
||
const currentFileName = path.basename(__filename) | ||
const ruleNames = rules.map((rule) => rule.meta.docs.ruleName) | ||
const content = `/* | ||
* IMPORTANT! | ||
* This file has been automatically generated by "${currentFileName}", | ||
* in order to update its content, update "${currentFileName}" and execute "npm run update" | ||
*/ | ||
${ruleNames.map(mapRuleNameToImport).join("\n")} | ||
import { buildA11yRules } from "../a11y" | ||
export const originalRules = [ | ||
${ruleNames.map(camelCase).join(",")}, | ||
] | ||
export const rules = [...originalRules, ...buildA11yRules()] | ||
` | ||
|
||
const filePath = path.resolve(__dirname, "../src/rules/index.ts") | ||
|
||
// Update file. | ||
void formatAndSave(filePath, content) |
This file was deleted.
Oops, something went wrong.
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