0.0.25 • Published 7 months ago

eslint-plugin-kisszaya-fsd-plugin v0.0.25

Weekly downloads
-
License
MIT
Repository
-
Last release
7 months ago

eslint-plugin-kisszaya-fsd-plugin

Customizable plugin to format code, inspired by fsd principles

Installation

You'll first need to install ESLint:

npm i eslint --save-dev

Next, install eslint-plugin-kisszaya-fsd-plugin:

npm install eslint-plugin-kisszaya-fsd-plugin --save-dev

Usage

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

{
    "plugins": [
        "kisszaya-fsd-plugin"
    ]
}

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

{
    "rules": {
      "kisszaya-fsd-plugin/fsd-relative-path": [
        "error",
        { alias: "@/", projectStructure: PROJECT_STRUCTURE, "srcPath": "src/" },
      ],
      "kisszaya-fsd-plugin/absolute-public-api-imports": [
        "error",
        { alias: "@/", projectStructure: PROJECT_STRUCTURE, "srcPath": "src/" },
      ],
      "kisszaya-fsd-plugin/layer-imports": [
        "error",
        { alias: "@/", projectStructure: PROJECT_STRUCTURE, srcPath "src/" },
      ]
    }
}

Options

projectStructure

projectStructure configuration is required to understand where the index.ts files are located. Absolute imports will only be used within these index.ts files.

Example:

const PROJECT_STRUCTURE = {
  app: 1,
  pages: {
    "**": 1,
  },
  layouts: {
    "**": 1,
  },
  widgets: {
    "**": 1,
  },
  features: {
    "**": 1,
  },
  entities: {
    "**": 1,
  },
  shared: {
    api: 1,
    assets: {
      images: 1,
      icons: 1,
    },
    config: 1,
    consts: 1,
    init: 1,
    routing: 1,
    types: 1,
    ui: {
      "**": 1,
    },
    lib: {
      "**": 1,
    },
    viewer: 1,
  },
};

srcPath

srcPath defines the path to the src folder. Other folders will be ignored, Example 1:

srcPath: "src/"

Example 2 (for sveltekit):

srcPath: "src/lib/"

Rules

kisszaya-fsd-plugin/fsd-relative-path: Imports within one slice should be relative.

kisszaya-fsd-plugin/absolute-public-api-imports: Absolute imports should be only from public API.

kisszaya-fsd-plugin/layer-imports: Modules on one layer can only interact with modules from the layers strictly below.

0.0.25

7 months ago

0.0.20

8 months ago

0.0.21

8 months ago

0.0.22

8 months ago

0.0.23

8 months ago

0.0.19

8 months ago

0.0.18

9 months ago

0.0.13

11 months ago

0.0.14

11 months ago

0.0.15

10 months ago

0.0.16

9 months ago

0.0.17

9 months ago

0.0.11

11 months ago

0.0.12

11 months ago

0.0.3

11 months ago

0.0.10

11 months ago

0.0.9

11 months ago

0.0.8

11 months ago

0.0.5

11 months ago

0.0.7

11 months ago

0.0.6

11 months ago

0.0.2

11 months ago

0.0.1

11 months ago

0.0.0

11 months ago