@feature-sliced/eslint-config
Advanced tools
Weekly downloads
Changelog
v.0.1.0-beta: GodMode and other refinements
feat:
(public-api) DangerousMode: Allow custom shared segments with _prefix by @Krakazybik in https://github.com/feature-sliced/eslint-config/pull/88
Use carefully and at your own risk
import { ... } from "shared/lib" // 🟩 valid import { ... } from "shared/library" // 🟥 not valid import { ... } from "shared/_library" // 🟩 again valid (as custom shared-segment)
feat:
(layer-slices) DangerousMode: Allow cross-imports for _prefix slices by @Krakazybik in https://github.com/feature-sliced/eslint-config/pull/95
Use carefully and at your own risk
import { ... } from "../HomePage"; import { ... } from "../ProfilePage"; // Imported into ... @path "pages/router" // 🟥 not valid (sibling slice) @path "pages/_router" // 🟩 again valid (as service directory/slice)
fix:
Incorrect sorting for layer root imports by @Krakazybik in https://github.com/feature-sliced/eslint-config/pull/94Full Changelog: https://github.com/feature-sliced/eslint-config/compare/v0.1.0-beta.5...v0.1.0-beta.6
Readme
WIP:
At the moment at beta-testing - use carefully
Linting of FeatureSliced concepts by existing eslint-plugins
Each rule has its own test cases and customization aspects
You'll first need to install ESLint:
$ npm install -D eslint
# or by yarn
$ yarn add -D eslint
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
Add config to the extends
section of your .eslintrc
configuration file (for recommended rules). You can omit the eslint-config
postfix:
{
"extends": ["@feature-sliced"]
}
TYPESCRIPT-ONLY:
Also setup TS-parser and TS-plugin (why?)
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
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
}
}
}
}
Support general aliases
import { Input } from "~/shared/ui/input";
import { Input } from "@/shared/ui/input";
import { Input } from "@shared/ui/input";
import { Input } from "$shared/ui/input";
// But not - import { Input } from "$UIKit/input";
Support relative and absolute imports (but look at recommendations)
import { ... } from "entities/foo"; // absolute imports
import { ... } from "@/entities/foo"; // aliased imports
import { ... } from "../entities/foo"; // relative imports
Case-agnostic
import { ... } from "entities/user-post"; // Support kebab-case (recommended)
import { ... } from "entities/UserPost"; // Support PascalCase
import { ... } from "entities/userPost"; // Support camelCase
import { ... } from "entities/user_post"; // Support snake_case
For exceptional cases, support ⚠️DANGEROUS-mode⚠️ (see more for specific rule)
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",
]
You can use alternative experimental rules
Use import-order/experimental
for formatting with spaces between groups and reversed order of layers (why?)
"extends": [
// ... Other rules or config
"@feature-sliced/eslint-config/rules/import-order/experimental",
]
Use public-api/lite
for less strict PublicAPI boundaries (why?)
"extends": [
// ... Other rules or config
"@feature-sliced/eslint-config/rules/public-api/lite",
]
You can use warnings instead of errors for specific rules
"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,
}
You can use advanced FSD-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'
FAQs
🍰 Lint feature-sliced concepts by existing eslint plugins
The npm package @feature-sliced/eslint-config receives a total of 634 weekly downloads. As such, @feature-sliced/eslint-config popularity was classified as not popular.
We found that @feature-sliced/eslint-config demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.