Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-validate-declared-imports

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-validate-declared-imports

ESLint plugin that validates globally declared typings imports

  • 1.0.13
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

eslint-plugin-validate-declared-imports

test npm

Validates imports of typescripts globally declared modules

When to use

When you declare modules with typescript, filepaths are not validated to be correct.

Example:

declare module '*.module.css' {
  const classes: { [key: string]: string };
  export default classes;
}

declare module '*.module.scss' {
  const classes: { [key: string]: string };
  export default classes;
}

declare module '*.module.sass' {
  const classes: { [key: string]: string };
  export default classes;
}

declare module '*.module.less' {
  const classes: { [key: string]: string };
  export default classes;
}

declare module '*.module.styl' {
  const classes: { [key: string]: string };
  export default classes;
}

This will not throw an error, even though path is incorrect:

import styles from 'asdasdasdasdasd.module.css';

Installation

You'll first need to install ESLint:

npm i eslint --save-dev

Next, install eslint-plugin-validate-declared-imports:

npm install eslint-plugin-validate-declared-imports --save-dev

or with yarn:

yarn add -D eslint-plugin-validate-declared-imports

Usage

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

{
    "plugins": [
        "validate-declared-imports"
    ]
}

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

{
    "rules": {
        "validate-declared-imports/no-unresolved-declared-imports": 
            ["error", { 
                "fileExtensions": [
                    // Asset files: png, jpeg, svg...
                    ".jpg", 
                    // Style files
                    ".module.css",  // CSS Modules
                    ".module.scss", // SCSS Modules
                    ".module.less", // Less Modules
                    ".st.css" // Stylable files
                    ] 
                  }
            ]
        
    }
}

Keywords

FAQs

Package last updated on 18 Aug 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc