0.0.25 • Published 9 months ago

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

Weekly downloads
-
License
MIT
Repository
-
Last release
9 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

9 months ago

0.0.20

10 months ago

0.0.21

10 months ago

0.0.22

10 months ago

0.0.23

10 months ago

0.0.19

10 months ago

0.0.18

10 months ago

0.0.13

1 year ago

0.0.14

1 year ago

0.0.15

12 months ago

0.0.16

11 months ago

0.0.17

11 months ago

0.0.11

1 year ago

0.0.12

1 year ago

0.0.3

1 year ago

0.0.10

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.5

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago

0.0.0

1 year ago