From b5f5723ec25582f220475cc41012123c69f7d81e Mon Sep 17 00:00:00 2001 From: Han Yeong-woo Date: Thu, 14 Dec 2023 11:24:41 +0900 Subject: [PATCH] Lazy import rules ESM version of #815 --- src/rules/__tests__/index.test.js | 4 +- src/rules/index.js | 452 ++++++++++++++++++------------ 2 files changed, 279 insertions(+), 177 deletions(-) diff --git a/src/rules/__tests__/index.test.js b/src/rules/__tests__/index.test.js index 19da133d..39f6c6f0 100644 --- a/src/rules/__tests__/index.test.js +++ b/src/rules/__tests__/index.test.js @@ -6,7 +6,9 @@ test("not empty", () => { expect(ruleEntries.length).toBeGreaterThan(0); }); -for (const [ruleName, rule] of ruleEntries) { +for (const [ruleName, rulePromise] of ruleEntries) { + const rule = await rulePromise; + test(`"${ruleName}" is a function`, () => { expect(rule).toBeInstanceOf(Function); }); diff --git a/src/rules/index.js b/src/rules/index.js index 8b9c46bf..dfd3a854 100644 --- a/src/rules/index.js +++ b/src/rules/index.js @@ -1,180 +1,280 @@ const rules = { - "at-each-key-value-single-line": ( - await import("./at-each-key-value-single-line/index.js") - ).default, - "at-else-closing-brace-newline-after": ( - await import("./at-else-closing-brace-newline-after/index.js") - ).default, - "at-else-closing-brace-space-after": ( - await import("./at-else-closing-brace-space-after/index.js") - ).default, - "at-else-empty-line-before": ( - await import("./at-else-empty-line-before/index.js") - ).default, - "at-else-if-parentheses-space-before": ( - await import("./at-else-if-parentheses-space-before/index.js") - ).default, - "at-extend-no-missing-placeholder": ( - await import("./at-extend-no-missing-placeholder/index.js") - ).default, - "at-function-named-arguments": ( - await import("./at-function-named-arguments/index.js") - ).default, - "at-function-parentheses-space-before": ( - await import("./at-function-parentheses-space-before/index.js") - ).default, - "at-function-pattern": (await import("./at-function-pattern/index.js")) - .default, - "at-if-closing-brace-newline-after": ( - await import("./at-if-closing-brace-newline-after/index.js") - ).default, - "at-if-closing-brace-space-after": ( - await import("./at-if-closing-brace-space-after/index.js") - ).default, - "at-if-no-null": (await import("./at-if-no-null/index.js")).default, - "at-import-no-partial-leading-underscore": ( - await import("./at-import-no-partial-leading-underscore/index.js") - ).default, - "load-no-partial-leading-underscore": ( - await import("./load-no-partial-leading-underscore/index.js") - ).default, - "at-import-partial-extension-blacklist": ( - await import("./at-import-partial-extension-blacklist/index.js") - ).default, - "at-import-partial-extension-whitelist": ( - await import("./at-import-partial-extension-whitelist/index.js") - ).default, - "at-import-partial-extension": ( - await import("./at-import-partial-extension/index.js") - ).default, - "at-mixin-argumentless-call-parentheses": ( - await import("./at-mixin-argumentless-call-parentheses/index.js") - ).default, - "at-mixin-named-arguments": ( - await import("./at-mixin-named-arguments/index.js") - ).default, - "at-mixin-parentheses-space-before": ( - await import("./at-mixin-parentheses-space-before/index.js") - ).default, - "at-mixin-pattern": (await import("./at-mixin-pattern/index.js")).default, - "at-rule-conditional-no-parentheses": ( - await import("./at-rule-conditional-no-parentheses/index.js") - ).default, - "at-root-no-redundant": (await import("./at-root-no-redundant/index.js")) - .default, - "at-rule-no-unknown": (await import("./at-rule-no-unknown/index.js")).default, - "at-use-no-redundant-alias": ( - await import("./at-use-no-redundant-alias/index.js") - ).default, - "at-use-no-unnamespaced": (await import("./at-use-no-unnamespaced/index.js")) - .default, - "block-no-redundant-nesting": ( - await import("./block-no-redundant-nesting/index.js") - ).default, - "comment-no-empty": (await import("./comment-no-empty/index.js")).default, - "comment-no-loud": (await import("./comment-no-loud/index.js")).default, - "declaration-nested-properties-no-divided-groups": ( - await import("./declaration-nested-properties-no-divided-groups/index.js") - ).default, - "declaration-nested-properties": ( - await import("./declaration-nested-properties/index.js") - ).default, - "dimension-no-non-numeric-values": ( - await import("./dimension-no-non-numeric-values/index.js") - ).default, - "dollar-variable-colon-newline-after": ( - await import("./dollar-variable-colon-newline-after/index.js") - ).default, - "dollar-variable-colon-space-after": ( - await import("./dollar-variable-colon-space-after/index.js") - ).default, - "dollar-variable-colon-space-before": ( - await import("./dollar-variable-colon-space-before/index.js") - ).default, - "dollar-variable-default": ( - await import("./dollar-variable-default/index.js") - ).default, - "dollar-variable-empty-line-after": ( - await import("./dollar-variable-empty-line-after/index.js") - ).default, - "dollar-variable-empty-line-before": ( - await import("./dollar-variable-empty-line-before/index.js") - ).default, - "dollar-variable-first-in-block": ( - await import("./dollar-variable-first-in-block/index.js") - ).default, - "dollar-variable-no-missing-interpolation": ( - await import("./dollar-variable-no-missing-interpolation/index.js") - ).default, - "dollar-variable-no-namespaced-assignment": ( - await import("./dollar-variable-no-namespaced-assignment/index.js") - ).default, - "dollar-variable-pattern": ( - await import("./dollar-variable-pattern/index.js") - ).default, - "double-slash-comment-empty-line-before": ( - await import("./double-slash-comment-empty-line-before/index.js") - ).default, - "double-slash-comment-inline": ( - await import("./double-slash-comment-inline/index.js") - ).default, - "double-slash-comment-whitespace-inside": ( - await import("./double-slash-comment-whitespace-inside/index.js") - ).default, - "function-disallowed-list": ( - await import("./function-disallowed-list/index.js") - ).default, - "function-calculation-no-interpolation": ( - await import("./function-calculation-no-interpolation/index.js") - ).default, - "function-color-relative": ( - await import("./function-color-relative/index.js") - ).default, - "function-no-unknown": (await import("./function-no-unknown/index.js")) - .default, - "function-quote-no-quoted-strings-inside": ( - await import("./function-quote-no-quoted-strings-inside/index.js") - ).default, - "function-unquote-no-unquoted-strings-inside": ( - await import("./function-unquote-no-unquoted-strings-inside/index.js") - ).default, - "map-keys-quotes": (await import("./map-keys-quotes/index.js")).default, - "media-feature-value-dollar-variable": ( - await import("./media-feature-value-dollar-variable/index.js") - ).default, - "no-dollar-variables": (await import("./no-dollar-variables/index.js")) - .default, - "no-duplicate-dollar-variables": ( - await import("./no-duplicate-dollar-variables/index.js") - ).default, - "no-duplicate-mixins": (await import("./no-duplicate-mixins/index.js")) - .default, - "no-global-function-names": ( - await import("./no-global-function-names/index.js") - ).default, - "operator-no-newline-after": ( - await import("./operator-no-newline-after/index.js") - ).default, - "operator-no-newline-before": ( - await import("./operator-no-newline-before/index.js") - ).default, - "operator-no-unspaced": (await import("./operator-no-unspaced/index.js")) - .default, - "partial-no-import": (await import("./partial-no-import/index.js")).default, - "percent-placeholder-pattern": ( - await import("./percent-placeholder-pattern/index.js") - ).default, - "property-no-unknown": (await import("./property-no-unknown/index.js")) - .default, - "selector-nest-combinators": ( - await import("./selector-nest-combinators/index.js") - ).default, - "selector-no-redundant-nesting-selector": ( - await import("./selector-no-redundant-nesting-selector/index.js") - ).default, - "selector-no-union-class-name": ( - await import("./selector-no-union-class-name/index.js") - ).default + get "at-each-key-value-single-line"() { + return import("./at-each-key-value-single-line/index.js").then( + m => m.default + ); + }, + get "at-else-closing-brace-newline-after"() { + return import("./at-else-closing-brace-newline-after/index.js").then( + m => m.default + ); + }, + get "at-else-closing-brace-space-after"() { + return import("./at-else-closing-brace-space-after/index.js").then( + m => m.default + ); + }, + get "at-else-empty-line-before"() { + return import("./at-else-empty-line-before/index.js").then(m => m.default); + }, + get "at-else-if-parentheses-space-before"() { + return import("./at-else-if-parentheses-space-before/index.js").then( + m => m.default + ); + }, + get "at-extend-no-missing-placeholder"() { + return import("./at-extend-no-missing-placeholder/index.js").then( + m => m.default + ); + }, + get "at-function-named-arguments"() { + return import("./at-function-named-arguments/index.js").then( + m => m.default + ); + }, + get "at-function-parentheses-space-before"() { + return import("./at-function-parentheses-space-before/index.js").then( + m => m.default + ); + }, + get "at-function-pattern"() { + return import("./at-function-pattern/index.js").then(m => m.default); + }, + get "at-if-closing-brace-newline-after"() { + return import("./at-if-closing-brace-newline-after/index.js").then( + m => m.default + ); + }, + get "at-if-closing-brace-space-after"() { + return import("./at-if-closing-brace-space-after/index.js").then( + m => m.default + ); + }, + get "at-if-no-null"() { + return import("./at-if-no-null/index.js").then(m => m.default); + }, + get "at-import-no-partial-leading-underscore"() { + return import("./at-import-no-partial-leading-underscore/index.js").then( + m => m.default + ); + }, + get "load-no-partial-leading-underscore"() { + return import("./load-no-partial-leading-underscore/index.js").then( + m => m.default + ); + }, + get "at-import-partial-extension-blacklist"() { + return import("./at-import-partial-extension-blacklist/index.js").then( + m => m.default + ); + }, + get "at-import-partial-extension-whitelist"() { + return import("./at-import-partial-extension-whitelist/index.js").then( + m => m.default + ); + }, + get "at-import-partial-extension"() { + return import("./at-import-partial-extension/index.js").then( + m => m.default + ); + }, + get "at-mixin-argumentless-call-parentheses"() { + return import("./at-mixin-argumentless-call-parentheses/index.js").then( + m => m.default + ); + }, + get "at-mixin-named-arguments"() { + return import("./at-mixin-named-arguments/index.js").then(m => m.default); + }, + get "at-mixin-parentheses-space-before"() { + return import("./at-mixin-parentheses-space-before/index.js").then( + m => m.default + ); + }, + get "at-mixin-pattern"() { + return import("./at-mixin-pattern/index.js").then(m => m.default); + }, + get "at-rule-conditional-no-parentheses"() { + return import("./at-rule-conditional-no-parentheses/index.js").then( + m => m.default + ); + }, + get "at-root-no-redundant"() { + return import("./at-root-no-redundant/index.js").then(m => m.default); + }, + get "at-rule-no-unknown"() { + return import("./at-rule-no-unknown/index.js").then(m => m.default); + }, + get "at-use-no-redundant-alias"() { + return import("./at-use-no-redundant-alias/index.js").then(m => m.default); + }, + get "at-use-no-unnamespaced"() { + return import("./at-use-no-unnamespaced/index.js").then(m => m.default); + }, + get "block-no-redundant-nesting"() { + return import("./block-no-redundant-nesting/index.js").then(m => m.default); + }, + get "comment-no-empty"() { + return import("./comment-no-empty/index.js").then(m => m.default); + }, + get "comment-no-loud"() { + return import("./comment-no-loud/index.js").then(m => m.default); + }, + get "declaration-nested-properties-no-divided-groups"() { + return import( + "./declaration-nested-properties-no-divided-groups/index.js" + ).then(m => m.default); + }, + get "declaration-nested-properties"() { + return import("./declaration-nested-properties/index.js").then( + m => m.default + ); + }, + get "dimension-no-non-numeric-values"() { + return import("./dimension-no-non-numeric-values/index.js").then( + m => m.default + ); + }, + get "dollar-variable-colon-newline-after"() { + return import("./dollar-variable-colon-newline-after/index.js").then( + m => m.default + ); + }, + get "dollar-variable-colon-space-after"() { + return import("./dollar-variable-colon-space-after/index.js").then( + m => m.default + ); + }, + get "dollar-variable-colon-space-before"() { + return import("./dollar-variable-colon-space-before/index.js").then( + m => m.default + ); + }, + get "dollar-variable-default"() { + return import("./dollar-variable-default/index.js").then(m => m.default); + }, + get "dollar-variable-empty-line-after"() { + return import("./dollar-variable-empty-line-after/index.js").then( + m => m.default + ); + }, + get "dollar-variable-empty-line-before"() { + return import("./dollar-variable-empty-line-before/index.js").then( + m => m.default + ); + }, + get "dollar-variable-first-in-block"() { + return import("./dollar-variable-first-in-block/index.js").then( + m => m.default + ); + }, + get "dollar-variable-no-missing-interpolation"() { + return import("./dollar-variable-no-missing-interpolation/index.js").then( + m => m.default + ); + }, + get "dollar-variable-no-namespaced-assignment"() { + return import("./dollar-variable-no-namespaced-assignment/index.js").then( + m => m.default + ); + }, + get "dollar-variable-pattern"() { + return import("./dollar-variable-pattern/index.js").then(m => m.default); + }, + get "double-slash-comment-empty-line-before"() { + return import("./double-slash-comment-empty-line-before/index.js").then( + m => m.default + ); + }, + get "double-slash-comment-inline"() { + return import("./double-slash-comment-inline/index.js").then( + m => m.default + ); + }, + get "double-slash-comment-whitespace-inside"() { + return import("./double-slash-comment-whitespace-inside/index.js").then( + m => m.default + ); + }, + get "function-disallowed-list"() { + return import("./function-disallowed-list/index.js").then(m => m.default); + }, + get "function-calculation-no-interpolation"() { + return import("./function-calculation-no-interpolation/index.js").then( + m => m.default + ); + }, + get "function-color-relative"() { + return import("./function-color-relative/index.js").then(m => m.default); + }, + get "function-no-unknown"() { + return import("./function-no-unknown/index.js").then(m => m.default); + }, + get "function-quote-no-quoted-strings-inside"() { + return import("./function-quote-no-quoted-strings-inside/index.js").then( + m => m.default + ); + }, + get "function-unquote-no-unquoted-strings-inside"() { + return import( + "./function-unquote-no-unquoted-strings-inside/index.js" + ).then(m => m.default); + }, + get "map-keys-quotes"() { + return import("./map-keys-quotes/index.js").then(m => m.default); + }, + get "media-feature-value-dollar-variable"() { + return import("./media-feature-value-dollar-variable/index.js").then( + m => m.default + ); + }, + get "no-dollar-variables"() { + return import("./no-dollar-variables/index.js").then(m => m.default); + }, + get "no-duplicate-dollar-variables"() { + return import("./no-duplicate-dollar-variables/index.js").then( + m => m.default + ); + }, + get "no-duplicate-mixins"() { + return import("./no-duplicate-mixins/index.js").then(m => m.default); + }, + get "no-global-function-names"() { + return import("./no-global-function-names/index.js").then(m => m.default); + }, + get "operator-no-newline-after"() { + return import("./operator-no-newline-after/index.js").then(m => m.default); + }, + get "operator-no-newline-before"() { + return import("./operator-no-newline-before/index.js").then(m => m.default); + }, + get "operator-no-unspaced"() { + return import("./operator-no-unspaced/index.js").then(m => m.default); + }, + get "partial-no-import"() { + return import("./partial-no-import/index.js").then(m => m.default); + }, + get "percent-placeholder-pattern"() { + return import("./percent-placeholder-pattern/index.js").then( + m => m.default + ); + }, + get "property-no-unknown"() { + return import("./property-no-unknown/index.js").then(m => m.default); + }, + get "selector-nest-combinators"() { + return import("./selector-nest-combinators/index.js").then(m => m.default); + }, + get "selector-no-redundant-nesting-selector"() { + return import("./selector-no-redundant-nesting-selector/index.js").then( + m => m.default + ); + }, + get "selector-no-union-class-name"() { + return import("./selector-no-union-class-name/index.js").then( + m => m.default + ); + } }; export default rules;