diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 967536e3..ac064b2d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -18,4 +18,4 @@ jobs: with: node-version: ${{ matrix.node-version }} - run: npm install - - run: npm test + - run: npm run ci diff --git a/index.js b/index.js index b9f9124d..17869882 100755 --- a/index.js +++ b/index.js @@ -55,7 +55,7 @@ function AtImport(options) { state, [], [], - postcss + postcss, ) applyRaws(bundle) diff --git a/lib/apply-conditions.js b/lib/apply-conditions.js index 5497cea1..76a8475a 100644 --- a/lib/apply-conditions.js +++ b/lib/apply-conditions.js @@ -15,7 +15,7 @@ module.exports = function applyConditions(bundle, atRule) { if (stmt.type === "import") { stmt.node.params = base64EncodedConditionalImport( stmt.fullUri, - stmt.conditions + stmt.conditions, ) return } diff --git a/lib/base64-encoded-import.js b/lib/base64-encoded-import.js index d34901cd..a928c62d 100644 --- a/lib/base64-encoded-import.js +++ b/lib/base64-encoded-import.js @@ -13,16 +13,16 @@ module.exports = function base64EncodedConditionalImport(prelude, conditions) { let params = `${prelude} ${formatImportPrelude( first.layer, first.media, - first.supports + first.supports, )}` for (const condition of conditions) { params = `'data:text/css;base64,${Buffer.from(`@import ${params}`).toString( - "base64" + "base64", )}' ${formatImportPrelude( condition.layer, condition.media, - condition.supports + condition.supports, )}` } diff --git a/lib/parse-statements.js b/lib/parse-statements.js index 1fb777e7..328db897 100644 --- a/lib/parse-statements.js +++ b/lib/parse-statements.js @@ -106,7 +106,7 @@ function parseImport(result, atRule, conditions, from) { return result.warn( "@import must precede all other statements (besides @charset or empty @layer)", - { node: atRule } + { node: atRule }, ) } while (prev) } @@ -115,7 +115,7 @@ function parseImport(result, atRule, conditions, from) { return result.warn( "It looks like you didn't end your @import statement correctly. " + "Child nodes are attached to it.", - { node: atRule } + { node: atRule }, ) } @@ -195,7 +195,7 @@ function parseImport(result, atRule, conditions, from) { `layers must be defined before support conditions in '${atRule.toString()}'`, { node: atRule, - } + }, ) } @@ -214,7 +214,7 @@ function parseImport(result, atRule, conditions, from) { `Multiple support conditions in '${atRule.toString()}'`, { node: atRule, - } + }, ) } diff --git a/lib/parse-styles.js b/lib/parse-styles.js index 1fad483d..68a1fef6 100644 --- a/lib/parse-styles.js +++ b/lib/parse-styles.js @@ -15,7 +15,7 @@ async function parseStyles( state, conditions, from, - postcss + postcss, ) { const statements = parseStatements(result, styles, conditions, from) @@ -45,7 +45,7 @@ async function parseStyles( throw stmt.node.error( `Incompatible @charset statements: ${stmt.node.params} specified in ${stmt.node.source.input.file} - ${charset.node.params} specified in ${charset.node.source.input.file}` + ${charset.node.params} specified in ${charset.node.source.input.file}`, ) } } @@ -80,14 +80,14 @@ async function resolveImportId(result, stmt, options, state, postcss) { stmt.uri, options, state, - postcss + postcss, ) return } else if (dataURL.isValid(stmt.from.slice(-1))) { // Data urls can't be used as a base url to resolve imports. throw stmt.node.error( - `Unable to import '${stmt.uri}' from a stylesheet that is embedded in a data url` + `Unable to import '${stmt.uri}' from a stylesheet that is embedded in a data url`, ) } @@ -108,7 +108,7 @@ async function resolveImportId(result, stmt, options, state, postcss) { return !path.isAbsolute(file) ? resolveId(file, base, options, atRule) : file - }) + }), ) // Add dependency messages: @@ -124,7 +124,7 @@ async function resolveImportId(result, stmt, options, state, postcss) { const importedContent = await Promise.all( resolved.map(file => { return loadImportContent(result, stmt, file, options, state, postcss) - }) + }), ) // Merge loaded statements @@ -138,13 +138,13 @@ async function loadImportContent( filename, options, state, - postcss + postcss, ) { const atRule = stmt.node const { conditions, from } = stmt const stmtDuplicateCheckKey = conditions .map(condition => - formatImportPrelude(condition.layer, condition.media, condition.supports) + formatImportPrelude(condition.layer, condition.media, condition.supports), ) .join(":") @@ -185,7 +185,7 @@ async function loadImportContent( content, filename, options, - postcss + postcss, ) const styles = importedResult.root @@ -213,7 +213,7 @@ async function loadImportContent( state, conditions, [...from, filename], - postcss + postcss, ) } diff --git a/lib/process-content.js b/lib/process-content.js index e0c2ac89..a0484039 100644 --- a/lib/process-content.js +++ b/lib/process-content.js @@ -11,7 +11,7 @@ module.exports = function processContent( content, filename, options, - postcss + postcss, ) { const { plugins } = options const ext = path.extname(filename) diff --git a/lib/resolve-id.js b/lib/resolve-id.js index aca3002d..3929a957 100644 --- a/lib/resolve-id.js +++ b/lib/resolve-id.js @@ -36,7 +36,7 @@ module.exports = function resolveId(id, base, options, node) { `Failed to find '${id}' in [ ${paths.join(",\n ")} - ]` + ]`, ) }) } diff --git a/test/custom-resolve.js b/test/custom-resolve.js index 130f9dab..094d3831 100644 --- a/test/custom-resolve.js +++ b/test/custom-resolve.js @@ -23,10 +23,10 @@ test.serial( { resolve: () => { return Promise.resolve( - path.resolve("test/fixtures/imports/custom-resolve-1.css") + path.resolve("test/fixtures/imports/custom-resolve-1.css"), ) }, - } + }, ) test.serial( @@ -41,7 +41,7 @@ test.serial( path.resolve("test/fixtures/imports/custom-resolve-1.css"), ] }, - } + }, ) test.serial( @@ -56,7 +56,7 @@ test.serial( path.resolve("test/fixtures/imports/custom-resolve-1.css"), ]) }, - } + }, ) test("should apply default resolver when custom doesn't return an absolute path", t => { @@ -68,7 +68,7 @@ test("should apply default resolver when custom doesn't return an absolute path" t.is(p, path.resolve("test/fixtures/imports", "bar.css")) return "/* comment */" }, - }) + }), ) .process(`@import "foo.css";`, { from: "test/fixtures/custom-resolve-file", diff --git a/test/custom-syntax-parser.js b/test/custom-syntax-parser.js index 729f6b29..aa32504e 100644 --- a/test/custom-syntax-parser.js +++ b/test/custom-syntax-parser.js @@ -16,7 +16,7 @@ test( checkFixture, "scss-parser", null, - { parser: scss } + { parser: scss }, ) test(".css importing .sss should work", checkFixture, "import-sss") @@ -26,7 +26,7 @@ test( checkFixture, { name: "sugar", ext: ".sss" }, null, - { parser: sugarss } + { parser: sugarss }, ) test( @@ -34,13 +34,13 @@ test( checkFixture, { name: "sugar-import-css", ext: ".sss" }, null, - { parser: sugarss } + { parser: sugarss }, ) test( ".css importing .sss importing .css should work", checkFixture, - "import-sss-css" + "import-sss-css", ) test( @@ -48,5 +48,5 @@ test( checkFixture, { name: "import-css-sss", ext: ".sss" }, null, - { parser: sugarss } + { parser: sugarss }, ) diff --git a/test/data-url.js b/test/data-url.js index 33e469f3..353b97b5 100644 --- a/test/data-url.js +++ b/test/data-url.js @@ -16,12 +16,12 @@ test("should error on relative urls from stylesheets in data urls", t => { .use(atImport()) .process( "@import url(data:text/css;base64,QGltcG9ydCB1cmwoZm9vLmNzcyk7CgpwIHsKICBjb2xvcjogYmx1ZTsKfQo=);", - { from: undefined } + { from: undefined }, ) .catch(error => t.regex( error.message, - /Unable to import '(?:.*?)' from a stylesheet that is embedded in a data url/ - ) + /Unable to import '(?:.*?)' from a stylesheet that is embedded in a data url/, + ), ) }) diff --git a/test/helpers/check-fixture.js b/test/helpers/check-fixture.js index de667398..849588f2 100644 --- a/test/helpers/check-fixture.js +++ b/test/helpers/check-fixture.js @@ -36,7 +36,7 @@ module.exports = function (t, file, opts, postcssOpts, warnings) { t.is( warning.text, warnings[index], - `unexpected warning: "${warning.text}"` + `unexpected warning: "${warning.text}"`, ) }) @@ -45,7 +45,7 @@ module.exports = function (t, file, opts, postcssOpts, warnings) { result.warnings().length, `expected ${warnings.length} warning(s), got ${ result.warnings().length - }` + }`, ) }) } diff --git a/test/import-events.js b/test/import-events.js index 638754ea..970baf17 100644 --- a/test/import-events.js +++ b/test/import-events.js @@ -18,7 +18,7 @@ test("should add dependency message for each import", t => { }) .then(result => { const deps = result.messages.filter( - message => message.type === "dependency" + message => message.type === "dependency", ) const expected = [ { diff --git a/test/import.js b/test/import.js index e0d0b8ab..e2a2bd17 100644 --- a/test/import.js +++ b/test/import.js @@ -23,7 +23,7 @@ test( "duplicates", { skipDuplicates: false, - } + }, ) test( @@ -32,7 +32,7 @@ test( "cyclical", { skipDuplicates: false, - } + }, ) test( @@ -41,7 +41,7 @@ test( "cyclical-skip-duplicates", { skipDuplicates: true, - } + }, ) test("should import stylesheets with same content", checkFixture, "same") @@ -64,7 +64,7 @@ test("should not fail with absolute and local import", t => { .use(atImport()) .process( "@import url('http://');\n@import 'test/fixtures/imports/foo.css';", - { from: undefined } + { from: undefined }, ) .then(result => t.is(result.css, "@import url('http://');\nfoo{}")) }) @@ -83,7 +83,7 @@ test("should keep @charset first", t => { test( "should handle multiple @charset statements", checkFixture, - "charset-import" + "charset-import", ) test("should error if incompatible @charset statements", t => { @@ -96,7 +96,7 @@ test("should error if incompatible @charset statements", t => { t.truthy(err) t.regex( err.message, - /Incompatible @charset statements:.+specified in.+specified in.+/s + /Incompatible @charset statements:.+specified in.+specified in.+/s, ) }) }) @@ -125,8 +125,8 @@ test("should contain a correct sourcemap", t => { process.platform === "win32" ? "test/sourcemap/out.css.win.map" : "test/sourcemap/out.css.map", - "utf8" - ).trim() + "utf8", + ).trim(), ) }) }) @@ -150,14 +150,14 @@ test( "empty-and-useless", { path: "test/fixtures/imports" }, null, - [`${path.resolve("test/fixtures/imports/empty.css")} is empty`] + [`${path.resolve("test/fixtures/imports/empty.css")} is empty`], ) test( "should be able to disable warnings for empty files", checkFixture, "empty-and-useless", - { path: "test/fixtures/imports", warnOnEmpty: false } + { path: "test/fixtures/imports", warnOnEmpty: false }, ) test("should work with no styles without throwing an error", t => { diff --git a/test/layer.js b/test/layer.js index 81b4ad9c..c80cc32f 100644 --- a/test/layer.js +++ b/test/layer.js @@ -10,13 +10,13 @@ test("should resolve layers of import statements", checkFixture, "layer") test( "should correctly wrap imported at rules in layers", checkFixture, - "layer-import-atrules" + "layer-import-atrules", ) test( "should correctly wrap imported at rules in anonymous layers", checkFixture, - "layer-import-atrules-anonymous" + "layer-import-atrules-anonymous", ) test( @@ -25,11 +25,11 @@ test( "layer-duplicate-anonymous-imports", { skipDuplicates: false, - } + }, ) test( "should correctly handle duplicate anonymous imports and skip duplicates is true", checkFixture, - "layer-duplicate-anonymous-imports-skip" + "layer-duplicate-anonymous-imports-skip", ) diff --git a/test/lint.js b/test/lint.js index 3082400c..6f531de3 100644 --- a/test/lint.js +++ b/test/lint.js @@ -18,7 +18,7 @@ test("should warn when not @charset and not @import statement before", t => { t.is(warnings.length, 1) t.is( warnings[0].text, - "@import must precede all other statements (besides @charset or empty @layer)" + "@import must precede all other statements (besides @charset or empty @layer)", ) }) }) @@ -32,14 +32,14 @@ test("should warn about all imports after some other CSS declaration", t => { @import "a.css"; @import "b.css"; `, - { from: undefined } + { from: undefined }, ) .then(result => { t.plan(2) result.warnings().forEach(warning => { t.is( warning.text, - "@import must precede all other statements (besides @charset or empty @layer)" + "@import must precede all other statements (besides @charset or empty @layer)", ) }) }) @@ -53,7 +53,7 @@ test("should warn if non-empty @layer before @import", t => { result.warnings().forEach(warning => { t.is( warning.text, - "@import must precede all other statements (besides @charset or empty @layer)" + "@import must precede all other statements (besides @charset or empty @layer)", ) }) }) @@ -67,14 +67,14 @@ test("should warn when import statements are not consecutive", t => { @layer a; @import "bar.css"; `, - { from: "test/fixtures/imports/foo.css" } + { from: "test/fixtures/imports/foo.css" }, ) .then(result => { t.plan(1) result.warnings().forEach(warning => { t.is( warning.text, - "@import must precede all other statements (besides @charset or empty @layer)" + "@import must precede all other statements (besides @charset or empty @layer)", ) }) }) @@ -149,7 +149,7 @@ test("should warn when a user didn't close an import with ;", t => { t.is( warnings[0].text, "It looks like you didn't end your @import statement correctly. " + - "Child nodes are attached to it." + "Child nodes are attached to it.", ) }) }) @@ -168,7 +168,7 @@ test("should warn on invalid url", t => { @import layer url(""); @import supports(foo: bar) url(""); `, - { from: undefined } + { from: undefined }, ) .then(result => { const warnings = result.warnings() @@ -183,7 +183,7 @@ test("should warn on invalid url", t => { t.is(warnings[7].text, `Unable to find uri in '@import layer url("")'`) t.is( warnings[8].text, - `Unable to find uri in '@import supports(foo: bar) url("")'` + `Unable to find uri in '@import supports(foo: bar) url("")'`, ) }) }) @@ -200,7 +200,7 @@ test("should warn on duplicate url's", t => { @import url('foo') layer(foo) "bar"; @import url('foo') supports(foo: bar) url(bar); `, - { from: undefined } + { from: undefined }, ) .then(result => { const warnings = result.warnings() @@ -211,15 +211,15 @@ test("should warn on duplicate url's", t => { t.is(warnings[3].text, `Multiple url's in '@import url('foo') url(bar)'`) t.is( warnings[4].text, - `Multiple url's in '@import url('foo') layer url(bar)'` + `Multiple url's in '@import url('foo') layer url(bar)'`, ) t.is( warnings[5].text, - `Multiple url's in '@import url('foo') layer(foo) "bar"'` + `Multiple url's in '@import url('foo') layer(foo) "bar"'`, ) t.is( warnings[6].text, - `Multiple url's in '@import url('foo') supports(foo: bar) url(bar)'` + `Multiple url's in '@import url('foo') supports(foo: bar) url(bar)'`, ) }) }) @@ -230,14 +230,14 @@ test("should warn on multiple layer clauses", t => { ` @import url('foo') layer layer(bar); `, - { from: undefined } + { from: undefined }, ) .then(result => { const warnings = result.warnings() t.is(warnings.length, 1) t.is( warnings[0].text, - `Multiple layers in '@import url('foo') layer layer(bar)'` + `Multiple layers in '@import url('foo') layer layer(bar)'`, ) }) }) @@ -248,14 +248,14 @@ test("should warn on when support conditions precede layer clauses", t => { ` @import url('foo') supports(selector(&)) layer(bar); `, - { from: undefined } + { from: undefined }, ) .then(result => { const warnings = result.warnings() t.is(warnings.length, 1) t.is( warnings[0].text, - `layers must be defined before support conditions in '@import url('foo') supports(selector(&)) layer(bar)'` + `layers must be defined before support conditions in '@import url('foo') supports(selector(&)) layer(bar)'`, ) }) }) @@ -266,14 +266,14 @@ test("should warn on multiple support conditions", t => { ` @import url('foo') supports(selector(&)) supports((display: grid)); `, - { from: undefined } + { from: undefined }, ) .then(result => { const warnings = result.warnings() t.is(warnings.length, 1) t.is( warnings[0].text, - `Multiple support conditions in '@import url('foo') supports(selector(&)) supports((display: grid))'` + `Multiple support conditions in '@import url('foo') supports(selector(&)) supports((display: grid))'`, ) }) }) diff --git a/test/media.js b/test/media.js index fce94ebc..38ce5c10 100644 --- a/test/media.js +++ b/test/media.js @@ -8,7 +8,7 @@ const checkFixture = require("./helpers/check-fixture") test( "should resolve media queries of import statements", checkFixture, - "media-import" + "media-import", ) test("should resolve media queries", checkFixture, "media-query") @@ -16,13 +16,13 @@ test("should resolve media queries", checkFixture, "media-query") test( "should resolve content inside import with media queries", checkFixture, - "media-content" + "media-content", ) test( "should resolve media query imports with charset", checkFixture, - "media-charset" + "media-charset", ) test("should correctly combine media queries", checkFixture, "media-combine") diff --git a/test/resolve.js b/test/resolve.js index 2be4794c..cde06384 100644 --- a/test/resolve.js +++ b/test/resolve.js @@ -19,21 +19,21 @@ test( checkFixture, "resolve-from", { path: null }, - { from: "test/fixtures/file.css" } + { from: "test/fixtures/file.css" }, ) test( `should resolve relative to 'path' which resolved with cwd`, checkFixture, "resolve-path-cwd", - { path: "test/fixtures/imports" } + { path: "test/fixtures/imports" }, ) test( `should resolve relative to 'path' which resolved with 'root'`, checkFixture, "resolve-path-root", - { root: "test/fixtures", path: "imports" } + { root: "test/fixtures", path: "imports" }, ) test("should resolve local modules", checkFixture, "resolve-local-modules", { @@ -46,7 +46,7 @@ test( "resolve-path-modules", { path: "test/fixtures/imports/modules", - } + }, ) test( @@ -54,7 +54,7 @@ test( checkFixture, "resolve-modules", { path: null }, - { from: "test/fixtures/imports/foo.css" } + { from: "test/fixtures/imports/foo.css" }, ) test( @@ -62,7 +62,7 @@ test( checkFixture, "resolve-npm-subpackages", { path: null }, - { from: "test/fixtures/imports/foo.css" } + { from: "test/fixtures/imports/foo.css" }, ) test( @@ -70,5 +70,5 @@ test( checkFixture, "resolve-custom-modules", { path: null, addModulesDirectories: ["shared_modules"] }, - { from: "test/fixtures/imports/foo.css" } + { from: "test/fixtures/imports/foo.css" }, ) diff --git a/test/supports-condition.js b/test/supports-condition.js index fc995f79..f985264d 100644 --- a/test/supports-condition.js +++ b/test/supports-condition.js @@ -8,5 +8,5 @@ const checkFixture = require("./helpers/check-fixture") test( "should resolve supports conditions of import statements", checkFixture, - "supports-condition-import" + "supports-condition-import", )