notes/node_modules/stylelint-scss/src/rules/partial-no-import/README.md

1.5 KiB
Raw Blame History

partial-no-import

Disallow non-CSS @imports in partial files.

// path/to/_file.scss:
/*         ↑ in partial files */

  @import "path/to/file.scss"
/*↑ Disallow imports */

The rule skips CSS files (doesn't report any @imports in them).

The rule also ignores cases when Sass considers an @import command just a plain CSS import:

  • If the files extension is .css.
  • If the filename begins with http:// (or any other protocol).
  • If the filename is a url().
  • If the @import has any media queries.

The following patterns are considered warnings:

// path/to/_file.scss:

@import "foo.scss";
// path/to/_file.less:
@import "path/fff.less";
// path/to/_file.scss:
@import "path\\fff.supa";

The following patterns are not considered warnings:

// path/to/file.scss:
@import "path/fff";

/* @import in a file that is not a partial */
// path/to/_file.scss:
@import url("path/_file.css"); /* has url(), so doesn't count as a partial @import */
// path/to/_file.scss:
@import "file.css"; /* Has ".css" extension, so doesn't count as a partial @import */
// path/to/_file.scss:
@import "http://_file.scss";
@import "//_file.scss";
/* Both are URIs, so don't count as partial @imports */
// path/to/_file.scss:
@import "file.scss" screen; /* Has a media query, so doesn't count as a partial @import */