diff --git a/lib/rules/block-no-empty/__tests__/index.js b/lib/rules/block-no-empty/__tests__/index.js index 2cb2ca68bc..01ae8ade77 100644 --- a/lib/rules/block-no-empty/__tests__/index.js +++ b/lib/rules/block-no-empty/__tests__/index.js @@ -133,6 +133,9 @@ testRule(rule, { }, { code: "a {\n/* foo */\ncolor: pink;\n}" + }, + { + code: '@import "foo.css";' } ], diff --git a/lib/rules/block-no-empty/index.js b/lib/rules/block-no-empty/index.js index 7190f1b920..e3552bee61 100644 --- a/lib/rules/block-no-empty/index.js +++ b/lib/rules/block-no-empty/index.js @@ -2,6 +2,7 @@ const _ = require("lodash"); const beforeBlockString = require("../../utils/beforeBlockString"); +const hasBlock = require("../../utils/hasBlock"); const hasEmptyBlock = require("../../utils/hasEmptyBlock"); const optionsMatches = require("../../utils/optionsMatches"); const report = require("../../utils/report"); @@ -47,6 +48,10 @@ const rule = function(primary, options = {}) { return; } + if (!hasBlock(statement)) { + return; + } + const hasCommentsOnly = statement.nodes.every( node => node.type === "comment" );