From 78aa606e2b1cd431d7cee79862335a8286f0f68d Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Thu, 19 Nov 2020 19:21:06 +0300 Subject: [PATCH] refactor: rename `atrule` to `at-rule` --- README.md | 2 +- src/extractICSS.js | 4 ++-- test/createICSSRules.test.js | 8 ++++---- test/extractICSS.test.js | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 508a2ab..18b92c3 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ createICSSRules( ``` By default it will create pseudo selector rules (`:import` and `:export`). Pass -`atrule` for `mode` to instead generate `@icss-import` and `@icss-export`, which +`at-rule` for `mode` to instead generate `@icss-import` and `@icss-export`, which may be more resilient to post processing by other tools. ## License diff --git a/src/extractICSS.js b/src/extractICSS.js index ebacf09..08b8010 100644 --- a/src/extractICSS.js +++ b/src/extractICSS.js @@ -16,7 +16,7 @@ const getDeclsObject = (rule) => { * * @param {string} css * @param {boolean} removeRules - * @param {auto|rule|atrule} mode + * @param {'auto' | 'rule' | 'at-rule'} mode */ const extractICSS = (css, removeRules = true, mode = "auto") => { const icssImports = {}; @@ -42,7 +42,7 @@ const extractICSS = (css, removeRules = true, mode = "auto") => { } css.each((node) => { - if (node.type === "rule" && mode !== "atrule") { + if (node.type === "rule" && mode !== "at-rule") { if (node.selector.slice(0, 7) === ":import") { const matches = importPattern.exec(node.selector); diff --git a/test/createICSSRules.test.js b/test/createICSSRules.test.js index 1824de0..900bea8 100644 --- a/test/createICSSRules.test.js +++ b/test/createICSSRules.test.js @@ -66,7 +66,7 @@ test("create empty @icss-import statement", () => { "path/file": {}, }, {}, - "atrule" + "at-rule" ) ).toEqual("@icss-import 'path/file'"); }); @@ -80,7 +80,7 @@ test("create @icss-import statement", () => { }, }, {}, - "atrule" + "at-rule" ) ).toEqual("@icss-import 'path/file' {\n e: f\n}"); }); @@ -93,7 +93,7 @@ test("create @icss-export statement", () => { a: "b", c: "d", }, - "atrule" + "at-rule" ) ).toEqual("@icss-export {\n a: b;\n c: d\n}"); }); @@ -109,7 +109,7 @@ test("create @icss-import and @icss-export", () => { { c: "d", }, - "atrule" + "at-rule" ) ).toEqual("@icss-import 'colors' {\n a: b\n}\n@icss-export {\n c: d\n}"); }); diff --git a/test/extractICSS.test.js b/test/extractICSS.test.js index a759e53..8dd1685 100644 --- a/test/extractICSS.test.js +++ b/test/extractICSS.test.js @@ -170,7 +170,7 @@ test("not process at-rules when mode is pseudo", () => { }); }); -test("not process at-rules when mode is atrule", () => { +test("not process at-rules when mode is 'at-rule'", () => { expect( runExtract( ` @@ -181,7 +181,7 @@ test("not process at-rules when mode is atrule", () => { @icss-export { d: d} `, - "atrule" + "at-rule" ) ).toEqual({ icssImports: {