Skip to content

Latest commit

 

History

History
58 lines (42 loc) · 1.25 KB

README.md

File metadata and controls

58 lines (42 loc) · 1.25 KB

eslint-plugin-assets

Helps check whether statically imported resources exist, Even if you use aliases or files starting width .

For example, in the Vite project, there may be a client. d.ts file for static resources, and all ts cannot handle whether this file exists well. Especially during development, it may cause build code errors and cause some build problems. This plugin can effectively avoid this situation

Installation

You'll first need to install ESLint:

npm i eslint --save-dev

Next, install eslint-plugin-assets:

npm install eslint-plugin-assets --save-dev

Usage

Add assets to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
    "plugins": [
        "assets"
    ]
}

Then configure the rules you want to use under the rules section.

{
    "rules": {
        "assets/check": "error"
    }
}

You can also use advanced(alias & extensions) configuration to config files you need check!

{
    "rules": {
        "assets/check": [
            "error", {
                alias: {'@': 'src'} // default,
                extensions: ['.png', '.jpg', '.jpeg', '.gif', '.svg'] // default
            }
        ]
    }
}