-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: unify
load-rules.ts
and utils/rules.ts
to rules/index.ts
- The `load-rules.ts` and `utils/rules.ts` are working like an index, using an index file in `src/rules/` allows us to remove them - The `update-rules.ts` is the generator of `utils/rules.ts` so it can be removed too
- Loading branch information
1 parent
fd8bc14
commit 6dcd659
Showing
18 changed files
with
90 additions
and
114 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,39 @@ | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { readdirSync } from "fs" | ||
import { join } from "path" | ||
import assert from "assert" | ||
import { rules } from "../../../src/rules/index" | ||
import { buildA11yRules } from "src/a11y" | ||
|
||
describe("Test src/rules/index.ts", () => { | ||
function getImportedRuleNames() { | ||
return rules.map((rule) => rule.meta.docs.ruleName) | ||
} | ||
|
||
function assertRulesImported(rulesToCheck: string[]) { | ||
const importedRules = getImportedRuleNames() | ||
rulesToCheck.forEach((ruleName) => { | ||
assert( | ||
importedRules.includes(ruleName), | ||
`Imported rules should include ${ruleName}`, | ||
) | ||
}) | ||
} | ||
|
||
it("should import all rule files", () => { | ||
const rulesDir = join(__dirname, "../../../src/rules") | ||
const ruleFiles = readdirSync(rulesDir) | ||
.filter( | ||
(file) => | ||
file.endsWith(".ts") && | ||
file !== "index.ts" && | ||
!file.endsWith(".test.ts"), | ||
) | ||
.map((file) => file.replace(".ts", "")) | ||
assertRulesImported(ruleFiles) | ||
}) | ||
|
||
it("should import all a11y rules", () => { | ||
const a11yRules = buildA11yRules().map((rule) => rule.meta.docs.ruleName) | ||
assertRulesImported(a11yRules) | ||
}) | ||
}) |
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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
import "./update-rules" | ||
import "./update-rulesets" | ||
import "./update-docs" | ||
import "./update-readme" | ||
|