パッケージの詳細

stylelint-no-unresolved-module

niksy104.2kMIT2.5.2

Ensures that module (import-like or url) can be resolved to a module on the file system.

stylelint-plugin, resolve, module, import

readme

stylelint-no-unresolved-module

Build Status

Ensures that module (import-like or url) can be resolved to a module on the file system.

Nodes which are considered "modules":

Features:

  • oxc-resolver to resolve each resource
  • Handling partials for Sass files

Install

npm install stylelint-no-unresolved-module --save

Usage

Add this config to your .stylelintrc:

{
    "plugins": ["stylelint-no-unresolved-module"],
    "rules": {
        "plugin/no-unresolved-module": {
            "alias": {
                "assets": "pebbles"
            },
            "modules": ["node_modules", "local_modules"]
        }
    }
}

Assuming file system like this:

.
├── package.json
├── index.css
├── milo/
│   └── macy.css
├── node_modules/
│   └── josie/
│       ├── package.json
│       ├── rusty.css
│       └── index.css
└── local_modules/
    ├── pebbles/
    │   └── tucker.png
    └── shelby/
        └── shelby.css

Assuming code is run from ./index.css:

/**
 * These resources can be resolved */

@import url('josie');
@import url('shelby/shelby.css');
@import url('./milo/macy.css');

body {
    background: url('assets/tucker.jpg');
}

/**
 * These resources can’t be resolved */

@import url('shelby');
@import url('josie/misty.css');
@import url('./milo/index.css');

body {
    background: url('assets/sandy.jpg');
}

Options

Plugin accepts either boolean (true) or object configuration.

If boolean, it will use default configuration:

  • No aliases
  • Look only inside node_modules for non-relative resource paths

If object configuration, following properties are valid:

cwd

Type: string
Default: process.cwd()

Root directory from where to start resolving resources. If it’s not defined, directory of file will be used. Useful for situations where you don’t have original file.

alias

Type: Object

A list of module alias configurations or an object which maps key to value. See original documentation.

modules

Type: string[]

A list of directories to resolve modules from. See original documentation.

roots

Type: string[]

A list of root paths. See original documentation.

tsconfig

Type: object

TypeScript related config for resolver. See original documentation.

License

MIT © Ivan Nikolić

更新履歴

Changelog

[Unreleased][]

2.5.2 - 2025-10-28

Changed

  • Handle edge cases for interpolation

2.5.1 - 2025-10-23

Fixed

  • Recursively check for interpolation or variable in string for Sass files

2.5.0 - 2025-10-23

Added

  • Support for TypeScript configuration option (#7)

2.4.0 - 2025-08-06

Changed

  • Replace enhanced-resolve with oxc-resolver

Fixed

  • Handle string when using with in Sass @use and @forward

2.3.0 - 2024-08-23

  • Add support for Sass pkg: URLs
  • Expand condition names to include default export

2.2.2 - 2024-02-26

Changed

  • Allow Stylelint 16 as peer dependancy

2.2.1 - 2023-09-08

Fixed

  • Ignore data URLs (#4)

2.2.0 - 2023-08-22

Changed

  • Allow Stylelint 15 as peer dependancy
  • Update import statements to be ESM compatible
  • Use pure ESM as default
  • Upgrade package

2.1.0 - 2023-03-02

Added

  • Support for enhanced-resolve roots option

2.0.0 - 2021-10-25

Added

  • TypeScript types

Changed

  • Breaking: Supports Node >= 12
  • Breaking: Supports Stylelint >= 14
  • Upgrade package

1.1.1 - 2020-11-13

Fixed

  • Parsing unqouted url values

1.1.0 - 2020-11-13

Changed

  • Allow array of aliases

Fixed

  • Skip checking interpolated strings

1.0.1 - 2020-11-05

Fixed

  • Make fixtures node_modules available in project (#1)

1.0.0 - 2020-11-05

Added

  • Initial implementation

[Unreleased]: https://github.com/niksy/stylelint-no-unresolved-module/compare/v2.5.2...HEAD

https://github.com/niksy/stylelint-no-unresolved-module/compare/v2.5.1...HEAD
https://github.com/niksy/stylelint-no-unresolved-module/compare/v2.5.0...HEAD
https://github.com/niksy/stylelint-no-unresolved-module/compare/v2.4.0...HEAD
https://github.com/niksy/stylelint-no-unresolved-module/compare/v2.3.0...HEAD