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

@hirasaki/eslint-plugin-coding-rules

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hirasaki/eslint-plugin-coding-rules

eslint plugin for making coding rules.

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

eslint-plugin-coding-rules

eslint plugin for making coding rules.

installation

$ npm install --save-dev @hirasaki/eslint-plugin-coding-rules

Then, in your .eslintrc.json

{
  "plugins": ["@hirasaki/coding-rules"],
}

Finally, enable rules that you would like to use.

  "rules": {
    "@hirasaki/coding-rules/no-use-specific-imports": [
      "error", [
        {
          filePath: [
            "**/components/**",
          ],
          importName: ["react-redux", "**/stores"],
        },
        {
          filePath: [
            "**/pages/**",
          ],
          importName: ["**/*Service", "**/ServiceFactory"],
          message: "'{{importSource}}'からは'{{importFrom}}'をインポートすることはできません。",
        },
      ]
    ]
  }

Rule Details

no-use-specific-imports

Disallow specific imports from specific dirs or source files.

Options

format is

{
  filePath: string | string[],
  importName: string | string[],
  message?: string
}[]
keytypesdescription
filePathstring or string[]Enter paths where the target file is located.
importNamestring or string[]Enter the name of the libraries for which import is prohibited.
messagestringcustom error message.
message format
keydescription
{{importSource}}replaces the source file path.
{{importFrom}}replaces the import name.

example

  "rules": {
    "@hirasaki/coding-rules/no-use-specific-imports": [
      'error',
      [
        {
          filePath: [
            "**/components/**",
          ],
          importName: ["react-redux", "**/stores"],
        },
        {
          filePath: [
            "**/pages/**",
          ],
          importName: ["**/*Service", "**/ServiceFactory"],
          message: "'{{importSource}}'からは'{{importFrom}}'をインポートすることはできません。",
        },
      ]
    ]
  }

Files with paths that match filePath will not be able to import the library specified by importName.

  • components/atoms/ButtonAtom.tsx can not import react-redux or **/stores.
  • pages/MainPage.tsx can not import **/Service or **/ServiceFactory.
architecture example

architecture_example

  • **/components/atoms/**, components/moleculres/**, **/components/organisms/** can not import redux directly.
  • **/components/atoms/**, components/moleculres/**, **/components/organisms/**, **/pages/**, can not import service files directly.

Control the data processing flow by preventing direct import.

react sample code is here sample code

Implementation

Keywords

FAQs

Package last updated on 13 Dec 2021

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