Socket
Socket
Sign inDemoInstall

@feature-sliced/eslint-config

Package Overview
Dependencies
197
Maintainers
2
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @feature-sliced/eslint-config

🍰 Lint feature-sliced concepts by existing eslint plugins


Version published
Weekly downloads
3.4K
decreased by-33.71%
Maintainers
2
Created
Weekly downloads
 

Readme

Source

@feature-sliced/eslint-config

WIP: At the moment at beta-testing - use carefully

npm npm npm bundle size GitHub Workflow Status

Linting of FeatureSliced concepts by existing eslint-plugins

Rules

Get Started

  1. You'll first need to install ESLint:

    $ npm install -D eslint
    # or by yarn
    $ yarn add -D eslint
    
  2. Next, install @feature-sliced/eslint-config and dependencies:

    $ npm install -D @feature-sliced/eslint-config eslint-plugin-import eslint-plugin-boundaries
    # or by yarn
    $ yarn add -D @feature-sliced/eslint-config eslint-plugin-import eslint-plugin-boundaries
    
  3. Add config to the extends section of your .eslintrc configuration file (for recommended rules). You can omit the eslint-config postfix:

    {
        "extends": ["@feature-sliced"]
    }
    

Customization

  1. You can partially use the rules

    WARN: Don't use main config ("@feature-sliced") in customization to avoid rules conflicts.

    {
      "extends": [
        "@feature-sliced/eslint-config/rules/import-order",
        "@feature-sliced/eslint-config/rules/public-api",
        "@feature-sliced/eslint-config/rules/layers-slices"
      ]
    }
    
  2. You can use advanced FeatureSliced-specific messages processing

    # (feature-sliced/public-api)
    - 'Reaching to "features/search/ui" is not allowed.'
    + 'Violated usage of modules Public API | https://git.io/Jymjf'
    
  3. You can use warnings instead of errors for specific rules

    // feature-sliced/import-order
    "import/order": "warn" // ~ 1,
    // feature-sliced/public-api
    "import/no-internal-modules": "warn" // ~ 1,
    // feature-sliced/layers-slices
    "boundaries/element-types": "warn" // ~ 1,
    
  4. EXPERIMENTAL: You can use import-order/experimental for formatting with spaces between groups and reversed order of layers

    {
      "extends": [
        // ... Other rules or config
        "@feature-sliced/eslint-config/rules/import-order/experimental",
      ]
    }
    

TypeScript

This plugin can be used also in TypeScript projects using @typescript-eslint/eslint-plugin. Follow next steps to configure it:

  1. Install dependencies:

    $ npm i -D @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint-import-resolver-typescript
    # or by yarn
    $ yarn add -D @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint-import-resolver-typescript
    
  2. Configure @typescript-eslint/parser as parser and setup the eslint-import-resolver-typescript resolver in the .eslintrc config file:

    {
      "parser": "@typescript-eslint/parser",
      "settings": {
        "import/resolver": {
          "typescript": {
            "alwaysTryTypes": true
          }
        }
      }
    }
    

See also

Keywords

FAQs

Last updated on 02 Feb 2022

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc