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

eslint-plugin-greenwich

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-greenwich

Define import prefix for omit Vue Lint 'One word imports'

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12
increased by33.33%
Maintainers
1
Weekly downloads
 
Created
Source

ESLint Rule: no-single-word-imports

Description

This ESLint rule enforces naming conventions for imports of single-word identifiers within specific directories. It is part of the eslint-plugin-greenwich plugin.

The rule checks that single-word import names do not violate specified naming conventions in certain directory paths. In this rule's context, a "single-word import" refers to an import statement that imports a default export with a single-word identifier.

Installation

To use this rule in your ESLint configuration, you can install the eslint-plugin-greenwich plugin using your preferred package manager.

  1. Using pnpm:

    pnpm install eslint-plugin-greenwich --save-dev
    
  2. Using npm:

    npm install eslint-plugin-greenwich --save-dev
    
  3. Using yarn:

    yarn add eslint-plugin-greenwich --dev
    

Rule Details

This rule checks import statements within specified directories (e.g., "/components/") and ensures that single-word import names adhere to specific naming conventions.

Options

This rule supports the following configuration options:

  • allowedPrefixes (array of strings, default: ['V']): Specifies a list of allowed prefixes for single-word import names. If provided, the rule allows import names that start with any of the specified prefixes.

  • paths (array of strings, default: ['/components/']): Specifies an array of directory paths where the rule should be applied. Only import statements within these paths will be checked for compliance with the rule.

ESLint Configuration

To configure ESLint for your project, you can create or edit an ESLint configuration file (e.g., .eslintrc.js) in your project's root directory. Below is an example ESLint configuration:

module.exports = {
  extends: ["eslint:recommended"], // Use recommended rules as a starting point
  plugins: ["greenwich"], // Add the 'greenwich' plugin
  rules: {
    "greenwich/prefix-one-word-import": [
      "error",
      {
        allowedPrefixes: ["V"], // Customize allowed prefixes
        paths: ["/components/"] // Specify the directory paths to check
      }
    ]
    // Add more rules and configurations as needed
  }
};

Examples

Here are some examples of how this rule works:

// ESLint: Single-word file names in components directory must start with one of the following prefixes: ['V']
import Button from "@/components/base/Button.vue";

// ESLint: Single-word file names in components directory must start with one of the following prefixes: ['V']
import MyButton from "@/components/base/Button.vue";

// Correct: Import name "VButton" starts with an allowed prefix ['V']
import VButton from "@/components/base/Button.vue";

// Correct: Import name "DragDrop" is multi word, don't check it
import DragDrop from "@/components/base/DragDrop.vue";

Keywords

FAQs

Package last updated on 09 Sep 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