Skip to content

Commit 45b934f

Browse files
committed
docs(public-api/lite): minor refinements
1 parent 7d2561e commit 45b934f

File tree

2 files changed

+80
-33
lines changed

2 files changed

+80
-33
lines changed

README.md

Lines changed: 40 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -63,48 +63,56 @@ Uncomment if will be needed
6363

6464
## Customization
6565

66-
1. You can partially use the rules
66+
1. You can *partially use* the rules
6767

6868
> **WARN:** Don't use main config (`"@feature-sliced"`) in customization to avoid rules conflicts.
6969
70-
```json
71-
{
72-
"extends": [
73-
"@feature-sliced/eslint-config/rules/import-order",
74-
"@feature-sliced/eslint-config/rules/public-api",
75-
"@feature-sliced/eslint-config/rules/layers-slices"
76-
]
77-
}
78-
```
79-
80-
2. You can use [advanced FeatureSliced-specific messages processing](https://www.npmjs.com/package/@feature-sliced/eslint-plugin-messages)
81-
82-
```diff
83-
# (feature-sliced/public-api)
84-
- 'Reaching to "features/search/ui" is not allowed.'
85-
+ 'Violated usage of modules Public API | https://git.io/Jymjf'
86-
```
87-
88-
3. You can use *warnings* instead of *errors* for specific rules
89-
9070
```js
91-
// feature-sliced/import-order
92-
"import/order": "warn" // ~ 1,
93-
// feature-sliced/public-api
94-
"import/no-internal-modules": "warn" // ~ 1,
95-
// feature-sliced/layers-slices
96-
"boundaries/element-types": "warn" // ~ 1,
71+
"extends": [
72+
"@feature-sliced/eslint-config/rules/import-order",
73+
"@feature-sliced/eslint-config/rules/public-api",
74+
"@feature-sliced/eslint-config/rules/layers-slices"
75+
]
9776
```
9877
99-
4. [`EXPERIMENTAL:`](https://github.com/feature-sliced/eslint-config/issues/85) You can use [`import-order/experimental`](./rules/import-order#Experimental) for formatting with spaces between groups and reversed order of layers
78+
1. You can use *alternative experimental rules*
79+
- Use [`import-order/experimental`](./rules/import-order#Experimental) for formatting with spaces between groups and reversed order of layers [(why?)](https://github.com/feature-sliced/eslint-config/issues/85)
10080
101-
```js
102-
{
81+
```js
10382
"extends": [
10483
// ... Other rules or config
10584
"@feature-sliced/eslint-config/rules/import-order/experimental",
10685
]
107-
}
86+
```
87+
88+
- Use [`public-api/lite`](./rules/public-api#Lite) for less strict PublicAPI boundaries [(why?)](https://github.com/feature-sliced/eslint-config/issues/90)
89+
90+
```js
91+
"extends": [
92+
// ... Other rules or config
93+
"@feature-sliced/eslint-config/rules/public-api/lite",
94+
]
95+
```
96+
97+
1. You can use *warnings* instead of *errors* for specific rules
98+
99+
```js
100+
"rules": {
101+
// feature-sliced/import-order
102+
"import/order": "warn" // ~ 1,
103+
// feature-sliced/public-api
104+
"import/no-internal-modules": "warn" // ~ 1,
105+
// feature-sliced/layers-slices
106+
"boundaries/element-types": "warn" // ~ 1,
107+
}
108+
```
109+
110+
1. You can use *[advanced FSD-specific messages processing](https://www.npmjs.com/package/@feature-sliced/eslint-plugin-messages)*
111+
112+
```diff
113+
# (feature-sliced/public-api)
114+
- 'Reaching to "features/search/ui" is not allowed.'
115+
+ 'Violated usage of modules Public API | https://git.io/Jymjf'
108116
```
109117
110118
## TypeScript
@@ -140,4 +148,4 @@ This plugin can be used also in TypeScript projects using `@typescript-eslint/es
140148
- [Releases & Changelog](https://github.com/feature-sliced/eslint-config/releases)
141149
- [**How can I help?**](./CONTRIBUTING.md)
142150
- ⭐ Rate us on GitHub
143-
- 💫 Any assistance is important - from feedback to participation in the development of the methodology!
151+
- 💫 **Any assistance is important** - from *feedback to participation in the development of the methodology*!

rules/public-api/README.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
Add `"@feature-sliced/eslint-config/rules/public-api"` to your `extends` section in ESLint config.
88

9+
#### Slices PublicAPI
10+
911
```js
1012
// 👎 Fail
1113
import { Issues } from "pages/issues/ui";
@@ -27,20 +29,57 @@ import { AuthForm } from "features/auth/form"
2729
import { Button } from "shared/ui";
2830
```
2931

30-
## Segments PublicAPI
32+
#### Segments PublicAPI
3133

3234
```js
35+
// 👍 Pass
36+
/** @path features/smth/index.ts */
37+
export { SubmitButton, SmthForm } from "./ui";
38+
export * from "./model";
39+
export * as smthModel from "./model";
40+
export { selectSmthById, ... } from "./model";
41+
3342
// 👎 Fail
3443
/** @path features/smth/index.ts */
3544
export { SubmitButton } from "./ui/button";
3645
export { SmthForm } from "./ui/form";
3746
export * from "./model/actions";
3847
export { selectSmthById } from "./model/selectors";
48+
```
49+
50+
## Lite
51+
52+
**Without SegmentsAPI / InnerAPI restrictions** [(why experimental?)](https://github.com/feature-sliced/eslint-config/issues/90)
53+
54+
Add `"@feature-sliced/eslint-config/rules/public-api/lite"` to your `extends` section in ESLint config. (for `^0.1.0-beta.5` versions)
55+
56+
#### Slices PublicAPI
57+
58+
Without changes
59+
60+
```js
61+
// 👍 Pass
62+
import { orderModel } from "entities/order";
63+
// 👎 Fail
64+
import { orderModel } from "entities/order/model";
65+
```
66+
67+
#### Segments PublicAPI
68+
69+
Less restricted with segments
3970

71+
```js
4072
// 👍 Pass
4173
/** @path features/smth/index.ts */
4274
export { SubmitButton, SmthForm } from "./ui";
4375
export * from "./model";
4476
export * as smthModel from "./model";
4577
export { selectSmthById, ... } from "./model";
78+
79+
// 👍 Also Pass
80+
/** @path features/smth/index.ts */
81+
export { SubmitButton } from "./ui/button";
82+
export { SmthForm } from "./ui/form";
83+
export * from "./model/actions";
84+
export { selectSmthById } from "./model/selectors";
4685
```

0 commit comments

Comments
 (0)