@@ -20,6 +20,10 @@ var moduleDirectories = [
2020 "node_modules" ,
2121]
2222
23+ var warnNodesMessage =
24+ "It looks like you didn't end correctly your @import statement. " +
25+ "Some children nodes are attached to it"
26+
2327/**
2428 * Inline `@import`ed files
2529 *
@@ -35,7 +39,7 @@ function AtImport(options) {
3539 ( options . path || [ ] ) // fallback to empty array
3640 )
3741
38- return function ( styles ) {
42+ return function ( styles , result ) {
3943 // auto add from option if possible
4044 if (
4145 ! options . from &&
@@ -68,6 +72,7 @@ function AtImport(options) {
6872 var hashFiles = { }
6973
7074 parseStyles (
75+ result ,
7176 styles ,
7277 options ,
7378 insertRules ,
@@ -90,7 +95,9 @@ function AtImport(options) {
9095 * @param {Object } styles
9196 * @param {Object } options
9297 */
93- function parseStyles ( styles ,
98+ function parseStyles (
99+ result ,
100+ styles ,
94101 options ,
95102 cb ,
96103 importedFiles ,
@@ -100,6 +107,9 @@ function parseStyles(styles,
100107) {
101108 var imports = [ ]
102109 styles . eachAtRule ( "import" , function checkAtRule ( atRule ) {
110+ if ( atRule . nodes ) {
111+ result . warn ( warnNodesMessage , { node : atRule } )
112+ }
103113 if ( options . glob && glob . hasMagic ( atRule . params ) ) {
104114 imports = parseGlob ( atRule , options , imports )
105115 }
@@ -110,6 +120,7 @@ function parseStyles(styles,
110120 imports . forEach ( function ( atRule ) {
111121 helpers . try ( function transformAtImport ( ) {
112122 readAtImport (
123+ result ,
113124 atRule ,
114125 options ,
115126 cb ,
@@ -205,6 +216,7 @@ function addIgnoredAtRulesOnTop(styles, ignoredAtRules) {
205216 * @param {Object } options
206217 */
207218function readAtImport (
219+ result ,
208220 atRule ,
209221 options ,
210222 cb ,
@@ -261,6 +273,7 @@ function readAtImport(
261273 importedFiles [ resolvedFilename ] [ media ] = true
262274
263275 readImportedContent (
276+ result ,
264277 atRule ,
265278 parsedAtImport ,
266279 clone ( options ) ,
@@ -282,7 +295,9 @@ function readAtImport(
282295 * @param {String } resolvedFilename
283296 * @param {Function } cb
284297 */
285- function readImportedContent ( atRule ,
298+ function readImportedContent (
299+ result ,
300+ atRule ,
286301 parsedAtImport ,
287302 options ,
288303 resolvedFilename ,
@@ -310,7 +325,7 @@ function readImportedContent(atRule,
310325 )
311326
312327 if ( fileContent . trim ( ) === "" ) {
313- console . log ( helpers . message ( resolvedFilename + " is empty" , atRule . source ) )
328+ result . warn ( resolvedFilename + " is empty" , { node : atRule } )
314329 detach ( atRule )
315330 return
316331 }
@@ -337,6 +352,7 @@ function readImportedContent(atRule,
337352
338353 // recursion: import @import from imported file
339354 parseStyles (
355+ result ,
340356 newStyles ,
341357 options ,
342358 cb ,
@@ -506,3 +522,4 @@ module.exports = postcss.plugin(
506522 "postcss-import" ,
507523 AtImport
508524)
525+ module . exports . warnNodesMessage = warnNodesMessage
0 commit comments