@conarti/eslint-plugin-feature-sliced 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/CHANGELOG.md +477 -0
  2. package/README.md +142 -0
  3. package/dist/config.js +27 -0
  4. package/dist/configs/import-order/index.js +20 -0
  5. package/dist/configs/import-order/recommended.js +28 -0
  6. package/dist/configs/import-order/with-newlines-and-type-group.js +28 -0
  7. package/dist/configs/import-order/with-newlines.js +28 -0
  8. package/dist/configs/import-order/with-type-group.js +28 -0
  9. package/dist/configs/recommended.js +11 -0
  10. package/dist/configs/rules.js +11 -0
  11. package/dist/index.js +24 -0
  12. package/dist/lib/fsd-lib/extract-feature-sliced-parts.js +18 -0
  13. package/dist/lib/fsd-lib/extract-layer.js +21 -0
  14. package/dist/lib/fsd-lib/extract-paths-info.js +59 -0
  15. package/dist/lib/fsd-lib/extract-paths.js +19 -0
  16. package/dist/lib/fsd-lib/extract-segment.js +18 -0
  17. package/dist/lib/fsd-lib/extract-slice.js +10 -0
  18. package/dist/lib/fsd-lib/index.js +10 -0
  19. package/dist/lib/fsd-lib/layers.js +16 -0
  20. package/dist/lib/fsd-lib/validate-extracted-feature-sliced-parts.js +29 -0
  21. package/dist/lib/path-lib/convert-to-absolute.js +18 -0
  22. package/dist/lib/path-lib/index.js +9 -0
  23. package/dist/lib/path-lib/is-path-relative.js +7 -0
  24. package/dist/lib/path-lib/join-path.js +12 -0
  25. package/dist/lib/path-lib/normalize-path.js +19 -0
  26. package/dist/lib/rule-lib/can-validate.js +11 -0
  27. package/dist/lib/rule-lib/create-rule.js +7 -0
  28. package/dist/lib/rule-lib/extract-current-file-path.js +11 -0
  29. package/dist/lib/rule-lib/extract-cwd.js +13 -0
  30. package/dist/lib/rule-lib/extract-node-path.js +13 -0
  31. package/dist/lib/rule-lib/extract-rule-options.js +7 -0
  32. package/dist/lib/rule-lib/get-source-range-without-quotes.js +7 -0
  33. package/dist/lib/rule-lib/index.js +23 -0
  34. package/dist/lib/rule-lib/is-ignored-current-file.js +12 -0
  35. package/dist/lib/rule-lib/is-ignored.js +12 -0
  36. package/dist/lib/rule-lib/is-node-type.js +17 -0
  37. package/dist/lib/rule-lib/models.js +2 -0
  38. package/dist/lib/shared/get-by-reg-exp.js +12 -0
  39. package/dist/lib/shared/index.js +11 -0
  40. package/dist/lib/shared/is-null.js +7 -0
  41. package/dist/lib/shared/is-object.js +7 -0
  42. package/dist/lib/shared/is-undefined.js +7 -0
  43. package/dist/rules/absolute-relative/config.js +2 -0
  44. package/dist/rules/absolute-relative/index.js +52 -0
  45. package/dist/rules/absolute-relative/model/errors-lib.js +17 -0
  46. package/dist/rules/absolute-relative/model/index.js +5 -0
  47. package/dist/rules/absolute-relative/model/should-be-absolute.js +16 -0
  48. package/dist/rules/absolute-relative/model/should-be-relative.js +21 -0
  49. package/dist/rules/absolute-relative/model/validate-and-report.js +24 -0
  50. package/dist/rules/layers-slices/config.js +2 -0
  51. package/dist/rules/layers-slices/index.js +56 -0
  52. package/dist/rules/layers-slices/model/can-import-layer.js +22 -0
  53. package/dist/rules/layers-slices/model/errors-lib.js +14 -0
  54. package/dist/rules/layers-slices/model/index.js +5 -0
  55. package/dist/rules/layers-slices/model/validate-and-report.js +22 -0
  56. package/dist/rules/public-api/config.js +2 -0
  57. package/dist/rules/public-api/index.js +65 -0
  58. package/dist/rules/public-api/model/convert-to-public-api.js +24 -0
  59. package/dist/rules/public-api/model/errors-lib.js +34 -0
  60. package/dist/rules/public-api/model/index.js +5 -0
  61. package/dist/rules/public-api/model/is-index-file.js +7 -0
  62. package/dist/rules/public-api/model/is-layer-public-api.js +23 -0
  63. package/dist/rules/public-api/model/is-segments-public-api.js +11 -0
  64. package/dist/rules/public-api/model/is-slice-public-api.js +7 -0
  65. package/dist/rules/public-api/model/should-be-from-public-api.js +21 -0
  66. package/dist/rules/public-api/model/validate-and-report-program.js +15 -0
  67. package/dist/rules/public-api/model/validate-and-report.js +18 -0
  68. package/package.json +86 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,477 @@
1
+ ## [1.0.3](https://github.com/conarti/eslint-plugin-fsd/compare/v1.0.2...v1.0.3) (2023-06-27)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **configs:** add 'rules' config definition at main entry point ([a9eba73](https://github.com/conarti/eslint-plugin-fsd/commit/a9eba7319090177d284c9d846afb31f8f024d2d0))
7
+
8
+
9
+
10
+ ## [1.0.2](https://github.com/conarti/eslint-plugin-fsd/compare/v1.0.1...v1.0.2) (2023-06-27)
11
+
12
+
13
+ ### Features
14
+
15
+ * **configs:** add config contain only rules ([e811a84](https://github.com/conarti/eslint-plugin-fsd/commit/e811a84900f63c95c72efa960e58c591b2d456d5))
16
+
17
+
18
+
19
+ ## [1.0.1](https://github.com/conarti/eslint-plugin-fsd/compare/v1.0.0...v1.0.1) (2023-06-27)
20
+
21
+ ### Bug Fixes
22
+
23
+ * **configs:** update definitions using new plugin name ([6d9b4f1](https://github.com/conarti/eslint-plugin-fsd/commit/b76283a7ae98d2a5f16494ede9a5a0f6b6d9b4f1))
24
+
25
+
26
+ # [1.0.0](https://github.com/conarti/eslint-plugin-fsd/compare/v0.0.39...v1.0.0) (2023-06-27)
27
+
28
+ This version refactored to typescript and vitest, as well as fixed important bugs and redesigned the rules.
29
+ Also, with the release of this version, the repository will be renamed to '@conarti/eslint-plugin-feature-sliced' and package with old name will be deprecated.
30
+
31
+ ### Bug Fixes
32
+
33
+ * **absolute-relative:** correct use default options ([85283af](https://github.com/conarti/eslint-plugin-fsd/commit/85283af4ac13fe41217f624a426013b01e7ee966))
34
+ * **absolute-relative:** should correct understand node module imports ([061e815](https://github.com/conarti/eslint-plugin-fsd/commit/061e815c8f43b5b7c3c4960d53919f4073e2ba6f))
35
+ * **import-order:** change to correct global config import path ([a079822](https://github.com/conarti/eslint-plugin-fsd/commit/a079822fc697f52dbf07afddbef49460a3a3b0dd))
36
+ * **layers-slices:** add schema for new 'ignoreInFilesPatterns' option ([e9aaffc](https://github.com/conarti/eslint-plugin-fsd/commit/e9aaffc2924139229be2faec2a024891209fa6ed))
37
+ * **layers-slices:** correct use default options ([c66179e](https://github.com/conarti/eslint-plugin-fsd/commit/c66179e98287f8db0f30fbf7d9c0a3d62c09a445))
38
+ * **layers-slices:** remove the incorrect check after correcting the logic for obtaining layer slices ([627c240](https://github.com/conarti/eslint-plugin-fsd/commit/627c2402f8957788f0071a28c2848a0d2bae44ac))
39
+ * **public-api:** correct use default options ([c2f36b6](https://github.com/conarti/eslint-plugin-fsd/commit/c2f36b6cb81bae2a1f7f950768f9022e6a76c130))
40
+ * **public-api:** report only 1 "import to layers public api is not allowed" error per file ([8672f55](https://github.com/conarti/eslint-plugin-fsd/commit/8672f554a079a0caa04fcef553c25fcf1819c917))
41
+ * **public-api:** should work with multiple layer names in path (correct understand layer) ([c09bc09](https://github.com/conarti/eslint-plugin-fsd/commit/c09bc09b8d438d29e7dbb54e4c28cd135e3ea22f))
42
+
43
+
44
+ ### Features
45
+
46
+ * use 'cwd' to understand paths ([3493d74](https://github.com/conarti/eslint-plugin-fsd/commit/3493d74def5df0bf066c0728df04a84405f36b7e))
47
+ * **import-order:** add different variations of configurations ([05e87f0](https://github.com/conarti/eslint-plugin-fsd/commit/05e87f07dc56c800b6d512c13dfa894a190360b7))
48
+ * **layers-slices:** 'allowTypeImports' option is set to 'true' by default ([7a3fc34](https://github.com/conarti/eslint-plugin-fsd/commit/7a3fc349de407642e2740926878a95461ad31de7))
49
+ * **layers-slices:** add 'ignoreInFilesPatterns' option ([b6b6fe3](https://github.com/conarti/eslint-plugin-fsd/commit/b6b6fe3824281364c604913f7f814969d3e6cfd0))
50
+ * **public-api:** add 'ignoreInFilesPatterns' option ([b2b3641](https://github.com/conarti/eslint-plugin-fsd/commit/b2b36417e5d626ccb38383dc569590d0685f417c))
51
+ * **public-api:** don't allow layers public api ([755a07c](https://github.com/conarti/eslint-plugin-fsd/commit/755a07c12658c7cecdb75cb863b07621908b6704))
52
+
53
+
54
+
55
+ ## [0.0.39](https://github.com/conarti/eslint-plugin-fsd/compare/v0.0.38...v0.0.39) (2023-05-28)
56
+
57
+
58
+ ### Bug Fixes
59
+
60
+ * **layers-slices:** remove import path normalization to check if it is ignored ([6569e75](https://github.com/conarti/eslint-plugin-fsd/commit/6569e7537f18efa9eba5010ac37e68dcd6eef57e))
61
+ * **import-order:** error when using 'recommended' config without 'eslint-plugin-import' package installed (now the rule simply won't work, and you can always use 'recommended' config) ([8f3dfa7](https://github.com/conarti/eslint-plugin-fsd/commit/8f3dfa73c3d44b6287e6267a2d62f74f1791ea30))
62
+
63
+
64
+ ### Features
65
+
66
+ * **absolute-relative:** improve logic for getting layer and slice from paths (now understands relative paths) ([c6d264a](https://github.com/conarti/eslint-plugin-fsd/commit/c6d264aa9f0226162842e758af04082ca418edc1))
67
+ * **public-api:** add the option which adjust the level of validation ([ab6b7e5](https://github.com/conarti/eslint-plugin-fsd/commit/ab6b7e568c7e9dc2e8791b8fc2bd55ba4815d83f)), closes [#5](https://github.com/conarti/eslint-plugin-fsd/issues/5)
68
+
69
+
70
+
71
+ ## [0.0.38](https://github.com/conarti/eslint-plugin-fsd/compare/v0.0.37...v0.0.38) (2023-05-11)
72
+
73
+
74
+ ### Features
75
+
76
+ * **public-api:** validate 'export ... from ...' syntax ([db343f4](https://github.com/conarti/eslint-plugin-fsd/commit/db343f4586f91b97c2a86a2a861ebdf810d9b185))
77
+
78
+
79
+
80
+ ## [0.0.37](https://github.com/conarti/eslint-plugin-fsd/compare/v0.0.36...v0.0.37) (2023-05-08)
81
+
82
+
83
+ ### Bug Fixes
84
+
85
+ * **import-order:** cycle fsd imports errors bug ([f0107ed](https://github.com/conarti/eslint-plugin-fsd/commit/f0107ed90a10764b0bc2d9a70bd35ca6f69bda62))
86
+
87
+
88
+
89
+ ## [0.0.36](https://github.com/conarti/eslint-plugin-fsd/compare/v0.0.35...v0.0.36) (2023-05-03)
90
+
91
+
92
+ ### Features
93
+
94
+ * **absolute-relative:** add 'ignoreInFilesPatterns' options for ignoring validations in files by patterns ([ec87cd1](https://github.com/conarti/eslint-plugin-fsd/commit/ec87cd192626503aa005b28cf36071e34224bcd4))
95
+
96
+
97
+
98
+ ## [0.0.35](https://github.com/conarti/eslint-plugin-fsd/compare/v0.0.34...v0.0.35) (2023-04-30)
99
+
100
+
101
+ ### Bug Fixes
102
+
103
+ * **public-api:** incorrect working if segment files has segment-like naming ([4e7cade](https://github.com/conarti/eslint-plugin-fsd/commit/4e7cadecc3211f5e795258c04e68bc6623a04d1e))
104
+
105
+
106
+
107
+ ## [0.0.34](https://github.com/conarti/eslint-plugin-fsd/compare/v0.0.33...v0.0.34) (2023-04-30)
108
+
109
+
110
+ ### Bug Fixes
111
+
112
+ * **layers-slices:** incorrect work with 'layers-like' names at not layer path part ([d13544b](https://github.com/conarti/eslint-plugin-fsd/commit/d13544b8311993be895133b8860b71e13fe868aa))
113
+
114
+
115
+ ### Features
116
+
117
+ * **layers-slices:** allow imports inside 'app' layer ([a2cc503](https://github.com/conarti/eslint-plugin-fsd/commit/a2cc503cb2991b5cb7ad9f5acf3699a13ba75823))
118
+
119
+
120
+
121
+ ## [0.0.33](https://github.com/conarti/eslint-plugin-fsd/compare/v0.0.32...v0.0.33) (2023-04-30)
122
+
123
+
124
+ ### Bug Fixes
125
+
126
+ * **layers-slices:** correctly understand layers from paths if usual folder names is same as layer names ([0.0.33](https://github.com/conarti/eslint-plugin-fsd/compare/v0.0.32...v0.0.33))
127
+
128
+
129
+
130
+ ## [0.0.32](https://github.com/conarti/eslint-plugin-fsd/compare/v0.0.31...v0.0.32) (2023-04-17)
131
+
132
+
133
+ ### Bug Fixes
134
+
135
+ * **public-api:** incorrect getting slices from the path ([5876679](https://github.com/conarti/eslint-plugin-fsd/commit/5876679c69eb2248970b8680a9bf07775b1eed3f))
136
+ * **public-api:** incorrect validation imports from 'index' files ([a335984](https://github.com/conarti/eslint-plugin-fsd/commit/a335984c33546b015e670ad95575c5ee3120cce5))
137
+ * **public-api:** incorrect validation within same segment ([61425a4](https://github.com/conarti/eslint-plugin-fsd/commit/61425a455bcc3c86a74f5278cdf606f327378be5))
138
+
139
+
140
+
141
+ ## [0.0.31](https://github.com/conarti/eslint-plugin-fsd/compare/v0.0.30...v0.0.31) (2023-04-16)
142
+
143
+
144
+ ### Bug Fixes
145
+
146
+ * **public-api:** working with file extension if import was from segment ([64ac21c](https://github.com/conarti/eslint-plugin-fsd/commit/64ac21c53c73b343600ec6708fa7a2b78852d90a))
147
+
148
+
149
+ ### Features
150
+
151
+ * **absolute-relative:** validate in import expressions ([d0e82f0](https://github.com/conarti/eslint-plugin-fsd/commit/d0e82f00ddf8b296761abbfec3446e3adb9c9983))
152
+ * **layers-slices:** validate in import expressions ([de3971b](https://github.com/conarti/eslint-plugin-fsd/commit/de3971b01bd9bfa983cea26fcd3ecfc9ded73e36))
153
+ * **public-api:** validate in import expressions ([c439acc](https://github.com/conarti/eslint-plugin-fsd/commit/c439acc3c259d2d05ec52d1d8ff35b3254fc38ab))
154
+
155
+
156
+
157
+ ## [0.0.30](https://github.com/conarti/eslint-plugin-fsd/compare/v0.0.29...v0.0.30) (2023-04-16)
158
+
159
+
160
+ ### Bug Fixes
161
+
162
+ * **public-api:** don't replace quotes style to single after fix invalid paths ([5881993](https://github.com/conarti/eslint-plugin-fsd/commit/588199320d3ae6139f3016bf874b3119a6416407))
163
+
164
+
165
+ ## [0.0.29](https://github.com/conarti/eslint-plugin-fsd/compare/v0.0.28...v0.0.29) (2023-04-16)
166
+
167
+
168
+ ### Features
169
+
170
+ * **convert-to-absolute:** add work with absolute target path ([b36fb06](https://github.com/conarti/eslint-plugin-fsd/commit/b36fb06a912f327d4fba0fd07a823a748ba997c7))
171
+ * **public-api:** add relative path validation ([af2a104](https://github.com/conarti/eslint-plugin-fsd/commit/af2a10459db3afeba1e12b52c5eba27ea436cee0))
172
+ * **public-api:** validate relative paths ([93e287c](https://github.com/conarti/eslint-plugin-fsd/commit/93e287c2651dd81c8e56b38cc845c4a76f7c341a))
173
+
174
+
175
+
176
+ ## [0.0.28](https://github.com/conarti/eslint-plugin-fsd/compare/v0.0.27...v0.0.28) (2023-04-09)
177
+
178
+
179
+ ### Bug Fixes
180
+
181
+ * incorrect working with windows paths ([7efc4c5](https://github.com/conarti/eslint-plugin-fsd/commit/7efc4c59e6c1357ff69cafdef4b4d820463a4a16))
182
+ * set rules meta type to 'problem' ([89c7fdd](https://github.com/conarti/eslint-plugin-fsd/commit/89c7fdd78dfa0dfa5278ace29da1b8038515deba))
183
+
184
+
185
+
186
+ ## [0.0.27](https://github.com/conarti/eslint-plugin-fsd/compare/v0.0.26...v0.0.27) (2023-04-04)
187
+
188
+
189
+ ### Reverts
190
+
191
+ * Revert "refactor(configs): extract 'base' config from 'recommended'" ([c7f7bd9](https://github.com/conarti/eslint-plugin-fsd/commit/c7f7bd958b541c499515ae24893dce8b108a94e4))
192
+ * Revert "refactor(import-order): move to 'configs'" ([8ef7228](https://github.com/conarti/eslint-plugin-fsd/commit/8ef7228eac949145cce04834f2600ab303d09643))
193
+
194
+
195
+
196
+ ## [0.0.26](https://github.com/conarti/eslint-plugin-fsd/compare/v0.0.25...v0.0.26) (2023-04-04)
197
+
198
+
199
+ ### Bug Fixes
200
+
201
+ * incorrect handling of windows paths ([f4d8877](https://github.com/conarti/eslint-plugin-fsd/commit/f4d887792555263aac7883121d70bd6835064098))
202
+ * **public-api:** validation with sub-grouping folders ([675546e](https://github.com/conarti/eslint-plugin-fsd/commit/675546eec3159366896040cd812eb2fe470a0e95))
203
+
204
+
205
+
206
+ ## [0.0.25](https://github.com/conarti/eslint-plugin-fsd/compare/v0.0.24...v0.0.25) (2023-03-29)
207
+
208
+
209
+ ### Bug Fixes
210
+
211
+ * **public-api:** validation with grouping folders ([88d282a](https://github.com/conarti/eslint-plugin-fsd/commit/88d282a86c5246edbd4a479ad2a79384c57d255a))
212
+ * **public-api:** working with paths in 'kebab-case' ([1a73850](https://github.com/conarti/eslint-plugin-fsd/commit/1a73850f4b2f9d99af863ea63b86da1f798a71f9))
213
+
214
+
215
+
216
+ ## [0.0.24](https://github.com/conarti/eslint-plugin-fsd/compare/v0.0.23...v0.0.24) (2023-03-06)
217
+
218
+
219
+ ### Bug Fixes
220
+
221
+ * **absolute-relative:** error when validating exported values (not re-exports) ([36a9b77](https://github.com/conarti/eslint-plugin-fsd/commit/36a9b77e4c5f2c5b126cd110c906452476fe8347))
222
+
223
+
224
+
225
+ ## [0.0.23](https://github.com/conarti/eslint-plugin-fsd/compare/v0.0.22...v0.0.23) (2023-03-06)
226
+
227
+
228
+ ### Features
229
+
230
+ * **absolute-relative:** export validation ([d4243e2](https://github.com/conarti/eslint-plugin-fsd/commit/d4243e2bc26919078a219b7364b28d9798bbf177))
231
+
232
+
233
+
234
+ ## [0.0.22](https://github.com/conarti/eslint-plugin-fsd/compare/v0.0.21...v0.0.22) (2023-03-06)
235
+
236
+
237
+ ### Bug Fixes
238
+
239
+ * **get-layer-slice-from-path:** correction of work with segment names ([741bfa3](https://github.com/conarti/eslint-plugin-fsd/commit/741bfa3e17dca2e56f2b2e203a39be2c01fa93e4))
240
+
241
+
242
+ ### Features
243
+
244
+ * **get-layer-slice-from-path:** case insensitive ([7b81eed](https://github.com/conarti/eslint-plugin-fsd/commit/7b81eed1c97c5025c354c7679f8e85125cd48448))
245
+
246
+
247
+
248
+ ## [0.0.21](https://github.com/conarti/eslint-plugin-fsd/compare/v0.0.20...v0.0.21) (2023-03-06)
249
+
250
+
251
+ ### Bug Fixes
252
+
253
+ * **normalize-path:** do not delete '.' ([ae463bb](https://github.com/conarti/eslint-plugin-fsd/commit/ae463bbf26ca65c74d6adc6fcce86bb23e91ac49))
254
+
255
+
256
+
257
+ ## [0.0.20](https://github.com/conarti/eslint-plugin-fsd/compare/v0.0.19...v0.0.20) (2023-03-06)
258
+
259
+
260
+ ### Bug Fixes
261
+
262
+ * **get-layer-slice-from-path:** working with kebab-case paths ([9d61320](https://github.com/conarti/eslint-plugin-fsd/commit/9d61320ab726a1781d7b3574b383a6cbc42c5951))
263
+
264
+
265
+ ### Features
266
+
267
+ * **helpers:** add convert-to-absolute helper ([2d93396](https://github.com/conarti/eslint-plugin-fsd/commit/2d93396af5b17fbebdc6b9843ee987d3f2055758))
268
+ * **layers-slices:** validate relative paths ([1b153ab](https://github.com/conarti/eslint-plugin-fsd/commit/1b153ab450d8d26d2fe2bb4ecaa9ed2ba72833c1))
269
+
270
+
271
+
272
+ ## [0.0.19](https://github.com/conarti/eslint-plugin-fsd/compare/v0.0.18...v0.0.19) (2023-03-04)
273
+
274
+
275
+ * feat(public-api-imports)!: rename rule to 'public-api' ([fb6b6d3](https://github.com/conarti/eslint-plugin-fsd/commit/fb6b6d3f28c09ed66d5bdcc39d2dc3bc726e0c5b))
276
+
277
+
278
+ ### Features
279
+
280
+ * **public-api-imports:** change rule fix to suggestion ([f0489f3](https://github.com/conarti/eslint-plugin-fsd/commit/f0489f3ca80e8e2038b8111ff30d1a68e76be6e4))
281
+ * **public-api:** add fixed path to error message ([4fddcde](https://github.com/conarti/eslint-plugin-fsd/commit/4fddcde76bc5abafcf5cbbb4635eac15e875b30f))
282
+
283
+
284
+ ### BREAKING CHANGES
285
+
286
+ * the name of the rule has been changed, you need to rename it in your eslint configs
287
+
288
+
289
+
290
+ ## [0.0.18](https://github.com/conarti/eslint-plugin-fsd/compare/v0.0.17...v0.0.18) (2023-03-03)
291
+
292
+
293
+ ### Bug Fixes
294
+
295
+ * **layers-slices:** remove extra '>' ([70a219b](https://github.com/conarti/eslint-plugin-fsd/commit/70a219bb0911c330fa426fb28ae6b48bdd56d969))
296
+
297
+
298
+ * feat(path-checker)!: rename rule to 'absolute-relative' ([68ce50a](https://github.com/conarti/eslint-plugin-fsd/commit/68ce50a1ac475c0d4c11199c3a749e4e9ea33890))
299
+
300
+
301
+ ### Features
302
+
303
+ * **import-order:** add padding and separate type imports ([fb36189](https://github.com/conarti/eslint-plugin-fsd/commit/fb361896f064cc059b0869d4bc1f6059208c5330))
304
+ * **layers-slices:** update error message ([3787909](https://github.com/conarti/eslint-plugin-fsd/commit/3787909dc35930120729b4a9bf62273aeaa8d6dd))
305
+ * **rules:** show rule errors over paths instead 'import' ([74e2b79](https://github.com/conarti/eslint-plugin-fsd/commit/74e2b793aa5ed81174afb74a82afc720981c5399))
306
+
307
+
308
+ ### BREAKING CHANGES
309
+
310
+ * the name of the rule has been changed, you need to rename it in your eslint configs
311
+
312
+
313
+
314
+ ## [0.0.17](https://github.com/conarti/eslint-plugin-fsd/compare/v0.0.16...v0.0.17) (2023-03-03)
315
+
316
+
317
+ ### Bug Fixes
318
+
319
+ * **layer-imports:** add 'processes' layer to error message ([11cbf93](https://github.com/conarti/eslint-plugin-fsd/commit/11cbf93cb3ab7e2a62705196122da82ac13765ba))
320
+
321
+
322
+ * feat(layer-imports)!: rename rule 'layer-imports' to 'layers-slices' ([b732ec1](https://github.com/conarti/eslint-plugin-fsd/commit/b732ec16b26920a6e457ee13993370dc2e703cd7))
323
+
324
+
325
+ ### Features
326
+
327
+ * **layer-imports:** don't throw an error when importing from the same slice ([28a002f](https://github.com/conarti/eslint-plugin-fsd/commit/28a002fbfb790bf1e872abac78950f5b068b5655))
328
+
329
+
330
+ ### BREAKING CHANGES
331
+
332
+ * the name of the rule has been changed, you need to rename it in your eslint configs
333
+
334
+
335
+
336
+ ## [0.0.16](https://github.com/conarti/eslint-plugin-fsd/compare/v0.0.15...v0.0.16) (2023-02-22)
337
+
338
+
339
+ ### Features
340
+
341
+ * **layer-imports:** add functionality for ignoring by patterns ([751e86c](https://github.com/conarti/eslint-plugin-fsd/commit/751e86c34cde89a5d65bad6d02b3e4b802bcd446))
342
+
343
+
344
+
345
+ ## [0.0.15](https://github.com/conarti/eslint-plugin-fsd/compare/v0.0.14...v0.0.15) (2023-02-21)
346
+
347
+
348
+ ### Bug Fixes
349
+
350
+ * **path-checker:** imports inside 'app' and 'shared' should be relative ([5ebb65d](https://github.com/conarti/eslint-plugin-fsd/commit/5ebb65dd18cae92d2c8229b7455856c371d6a3a5))
351
+ * **path-checker:** update message for relative path errors ([4aeea52](https://github.com/conarti/eslint-plugin-fsd/commit/4aeea52d4320430bf68f481743d26c997fb6071a))
352
+
353
+
354
+ ### Features
355
+
356
+ * **configs:** set 'all' config as 'recommended', enable 'allowTypeImports' by default ([e2f800d](https://github.com/conarti/eslint-plugin-fsd/commit/e2f800d011e42563126f1b5d925ef75da3c106a5))
357
+ * **layer-imports:** add a setting to disable checking for type imports ([8605f58](https://github.com/conarti/eslint-plugin-fsd/commit/8605f58f5a508858b10f29d1f17bc663cfd7fbb1))
358
+
359
+
360
+
361
+ ## [0.0.14](https://github.com/conarti/eslint-plugin-fsd/compare/v0.0.13...v0.0.14) (2023-02-12)
362
+
363
+
364
+ ### Bug Fixes
365
+
366
+ * **path-checker:** shouldBeRelative - don't error for imports from another layer ([aad40c0](https://github.com/conarti/eslint-plugin-fsd/commit/aad40c028c208f07db92a6fdf8e04ef88f4ebfd8))
367
+
368
+
369
+
370
+ ## [0.0.13](https://github.com/conarti/eslint-plugin-fsd/compare/v0.0.12...v0.0.13) (2023-02-12)
371
+
372
+
373
+ ### Bug Fixes
374
+
375
+ * **get-layer-slice-from-path:** don't find a file as a slice ([1de7f4b](https://github.com/conarti/eslint-plugin-fsd/commit/1de7f4b9e9a9c0f69ee733aa2b4f4d1c76b550ab))
376
+ * **layer-imports:** allow imports from same layer for '{layer}/{file}' pattern ([f00cdaf](https://github.com/conarti/eslint-plugin-fsd/commit/f00cdaf43dcb25f4e84d8a5162b77ea72c3d7e52))
377
+
378
+
379
+ ### Features
380
+
381
+ * **path-checker:** error if should relative import at files like {layer}/{filename} pattern ([e34ff41](https://github.com/conarti/eslint-plugin-fsd/commit/e34ff4139be131d80b093327920a8166b5d12b08))
382
+
383
+
384
+
385
+ ## [0.0.12](https://github.com/conarti/eslint-plugin-fsd/compare/v0.0.11...v0.0.12) (2023-02-12)
386
+
387
+
388
+ ### Bug Fixes
389
+
390
+ * **public-api-imports:** don't check imports from 'shared' ([2e0801b](https://github.com/conarti/eslint-plugin-fsd/commit/2e0801bc299143d6b55636ba5759e2892137d4d4))
391
+
392
+
393
+
394
+ ## [0.0.11](https://github.com/conarti/eslint-plugin-fsd/compare/v0.0.10...v0.0.11) (2023-02-12)
395
+
396
+
397
+ ### Bug Fixes
398
+
399
+ * **layer-imports:** disable imports from one layer except 'shared', correct validation mistakes, 'canNotImportLayer' -> 'canImportLayer' ([5623b69](https://github.com/conarti/eslint-plugin-fsd/commit/5623b696c47d5da2cd8be2b6c7dbd53b03642636))
400
+
401
+
402
+ ### Features
403
+
404
+ * **get-layer-slice-from-path:** rename from 'getPathParts', fix implementation ([72c543f](https://github.com/conarti/eslint-plugin-fsd/commit/72c543f08bd71a2336caac1b0645c70188626671))
405
+ * **layer-imports:** implementation without 'alias' option ([db41630](https://github.com/conarti/eslint-plugin-fsd/commit/db4163089ad3ba48e76d3a8fccd68572ed5c7edb))
406
+ * **normalize-path:** don't remove aliases ([5e00cae](https://github.com/conarti/eslint-plugin-fsd/commit/5e00caef5713cd509f345c8f5647c844ac2064b2))
407
+ * **normalizePath:** automatic detection of aliases and their removal from the path ([c8ff1b2](https://github.com/conarti/eslint-plugin-fsd/commit/c8ff1b25f91842a1be2b92475f6a6603c28e9ba2))
408
+ * **path-checker:** checks 'should be absolute' ([6510e71](https://github.com/conarti/eslint-plugin-fsd/commit/6510e719982aa7010e7e068d86377bba0685e05e))
409
+ * **path-checker:** implementation without 'alias' option ([5ba3dac](https://github.com/conarti/eslint-plugin-fsd/commit/5ba3dac6500d0fd1769f6c2d6f263f168fe39df3))
410
+ * **public-api-imports:** automatically detect aliases in the path ([be743b8](https://github.com/conarti/eslint-plugin-fsd/commit/be743b87e9f9de9f45313b505214063fa4487474))
411
+ * **public-api-imports:** new implementation with auto-detect aliases and working with any paths ([1b3e2ad](https://github.com/conarti/eslint-plugin-fsd/commit/1b3e2ad5efc2d4b6b3b948a29942f178155fc435))
412
+
413
+
414
+ ### Reverts
415
+
416
+ * add 'getByRegExp' and 'getAlias' to helpers public api ([e71f8aa](https://github.com/conarti/eslint-plugin-fsd/commit/e71f8aa4585107ed960b5dddfad413f133cee7d9))
417
+
418
+
419
+
420
+ ## [0.0.10](https://github.com/conarti/eslint-plugin-fsd/compare/v0.0.9...v0.0.10) (2023-01-17)
421
+
422
+
423
+ ### Features
424
+
425
+ * **import-order:** disable rule for imports from the same slice ([90668ac](https://github.com/conarti/eslint-plugin-fsd/commit/90668ac816656e319d15ed471eeda084adfb7675))
426
+
427
+
428
+ ### Reverts
429
+
430
+ * Revert "refactor(layer-imports): change function canNotImportLayer to canImportLayer, move to global helpers" ([284ca0c](https://github.com/conarti/eslint-plugin-fsd/commit/284ca0c8993d05d14d54e91ffd52a70b5f0facb1))
431
+
432
+
433
+
434
+ ## [0.0.9](https://github.com/conarti/eslint-plugin-fsd/compare/v0.0.8-beta1...v0.0.9) (2023-01-16)
435
+
436
+
437
+ ### Features
438
+
439
+ * **import-order:** throw errors when has lines between groups ([38a5420](https://github.com/conarti/eslint-plugin-fsd/commit/38a542033b13cafaad9e38c6e58ed3e9793bd9c7))
440
+
441
+
442
+
443
+ ## [0.0.8-beta1](https://github.com/conarti/eslint-plugin-fsd/compare/v0.0.8...v0.0.8-beta1) (2023-01-16)
444
+
445
+
446
+ ### Features
447
+
448
+ * setup configs ([65af4f0](https://github.com/conarti/eslint-plugin-fsd/commit/65af4f0a64e376da161d740551a20b0877605824))
449
+
450
+
451
+
452
+ ## [0.0.8](https://github.com/conarti/eslint-plugin-fsd/compare/v0.0.7...v0.0.8) (2023-01-16)
453
+
454
+
455
+ ### Features
456
+
457
+ * setup import-order rule, update docs ([b333104](https://github.com/conarti/eslint-plugin-fsd/commit/b333104538098e8ab460c32aa9e50073dc9ae35f))
458
+
459
+
460
+
461
+ ## [0.0.7](https://github.com/conarti/eslint-plugin-fsd/compare/d7d1f135401328c6071c924b162b2fffdfda592c...v0.0.7) (2023-01-06)
462
+
463
+
464
+ ### Bug Fixes
465
+
466
+ * **public-api-imports:** disable for 'app' imports ([b5032e9](https://github.com/conarti/eslint-plugin-fsd/commit/b5032e9d78ac0e07991f69567149d489a060f5a9))
467
+
468
+
469
+ ### Features
470
+
471
+ * add public-api-imports rule ([5c1cfe3](https://github.com/conarti/eslint-plugin-fsd/commit/5c1cfe3e0ad981a623bcf36a24853f50ba5f7dbd))
472
+ * **path-checker:** add alias implementation ([d7d1f13](https://github.com/conarti/eslint-plugin-fsd/commit/d7d1f135401328c6071c924b162b2fffdfda592c))
473
+ * **public-api-imports:** add auto fix for rule ([7889f73](https://github.com/conarti/eslint-plugin-fsd/commit/7889f73a183e8a0e6e04cf7d100a7b034d587028))
474
+ * **rules:** setup 'layer-imports' rule ([ec86bd3](https://github.com/conarti/eslint-plugin-fsd/commit/ec86bd30c39268bb7ea925c5a9c2cce39e6ba2a5))
475
+
476
+
477
+
package/README.md ADDED
@@ -0,0 +1,142 @@
1
+ # eslint-plugin-conarti-fsd
2
+
3
+ Feature-sliced design methodology plugin.
4
+
5
+ _Attention: the plugin is being actively developed and is in **beta**.
6
+ The names of rules and configurations may change in new versions.
7
+ If you find a bug, please open an issue or pull request.
8
+ Feel free to contribute_
9
+
10
+ ## Features
11
+
12
+ - Works with any framework
13
+
14
+ - Support for **any aliases** out of the box
15
+
16
+ ```javascript
17
+ import { AppButton } from "~/shared/ui/app-button";
18
+ import { AppButton } from "@/shared/ui/app-button";
19
+ import { AppButton } from "@shared/ui/app-button";
20
+ import { AppButton } from "$shared/ui/app-button";
21
+ import { AppButton } from "$@#$%%shared/ui/app-button";
22
+ ```
23
+
24
+ - Checks for absolute and relative paths
25
+
26
+ ```javascript
27
+ // file: src/widgets/TheHeader/ui/TheHeader.stories.tsx
28
+
29
+ import { TheHeader } from './TheHeader'; // valid
30
+ import { TheHeader } from 'src/widgets/TheHeader'; // error: should relative
31
+ import { TheHeader } from 'widgets/TheHeader'; // error: should relative
32
+ import { useBar } from '../../../shared/hooks'; // error: should absolute
33
+ ```
34
+
35
+ - Checks for imports from public api and fix them
36
+
37
+ ```javascript
38
+ // file: src/features/search-articles/...
39
+
40
+ import { addCommentFormActions, addCommentFormReducer } from 'entities/Article/model/file.ts'; // error
41
+ // fix: import { addCommentFormActions, addCommentFormReducer } from 'entities/Article';
42
+ ```
43
+
44
+ - Sort imports
45
+
46
+ ```javascript
47
+ import axios from "axios"; // 1) external libs
48
+ import { Header } from "widgets/header"; // 2.1) Layers: widgets
49
+ import { Zero } from "widgets/zero"; // 2.1) Layers: widget
50
+ import { LoginForm } from "features/login-form"; // 2.2) Layers: features
51
+ import { globalEntities } from "entities"; // 2.4) Layers: entities
52
+ import { authModel } from "entities/auth"; // 2.4) Layers: entities
53
+ import { Cart } from "entities/cart"; // 2.4) Layers: entities
54
+ import { One } from "entities/one"; // 2.4) Layers: entities
55
+ import { Two } from "entities/two"; // 2.4) Layers: entities
56
+ import { debounce } from "shared/lib/fp"; // 2.5) Layers: shared
57
+ import { Button } from "shared/ui"; // 2.5) Layers: shared
58
+ import { Input } from "shared/ui"; // 2.5) Layers: shared
59
+ import { data } from "../fixtures"; // 3) parent
60
+ import { getSmth } from "./lib"; // 4) sibling
61
+ ```
62
+
63
+ ## Installation
64
+
65
+ You'll first need to install [ESLint](https://eslint.org/):
66
+
67
+ ```sh
68
+ npm i eslint --save-dev
69
+ ```
70
+
71
+ Next, install `eslint-plugin-conarti-fsd` and dependencies:
72
+
73
+ ```sh
74
+ npm install -D eslint-plugin-conarti-fsd eslint-plugin-import
75
+ # or by yarn
76
+ yarn add -D eslint-plugin-conarti-fsd eslint-plugin-import
77
+ ```
78
+
79
+ ## Usage
80
+
81
+ Add `conarti-fsd` to the plugins section of your `.eslintrc` configuration file. You can omit the `eslint-plugin-`
82
+ prefix:
83
+
84
+ ```json
85
+ {
86
+ "plugins": [
87
+ "conarti-fsd"
88
+ ]
89
+ }
90
+ ```
91
+
92
+ Then enable rules:
93
+
94
+ ```json
95
+ {
96
+ "extends": [
97
+ "plugin:conarti-fsd/recommended"
98
+ ]
99
+ }
100
+ ```
101
+
102
+ ## Customization
103
+
104
+ You can use _warnings_ instead of _errors_ for specific rules. Or turn off certain rules:
105
+
106
+ ```json
107
+ {
108
+ "rules": {
109
+ "conarti-fsd/layers-slices": "warn",
110
+ "conarti-fsd/absolute-relative": "off",
111
+ "conarti-fsd/public-api": "warn",
112
+ "import/order": "warn"
113
+ }
114
+ }
115
+ ```
116
+
117
+ If you don't want to use the 'import/order' rule, you can choose not to install the 'eslint-plugin-import' package.
118
+ And also you will have to configure all the rules separately, without using the config.
119
+ Recommended settings:
120
+ ```json
121
+ {
122
+ "rules": {
123
+ "conarti-fsd/layers-slices": ["error", {
124
+ "allowTypeImports": true
125
+ }],
126
+ "conarti-fsd/absolute-relative": "error",
127
+ "conarti-fsd/public-api": "error"
128
+ }
129
+ }
130
+ ```
131
+
132
+ ## Rules
133
+
134
+ 🔧 Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).
135
+ 💡 Suggestion fix (no automatic fix)
136
+
137
+ | Name | Description | 🔧 |
138
+ |:-------------------------------------------------------------------|:------------------------------------------|:---|
139
+ | [conarti-fsd/layers-slices](rules/layers-slices/README.md) | Checks layer imports | |
140
+ | [conarti-fsd/absolute-relative](rules/absolute-relative/README.md) | Checks for absolute and relative paths | |
141
+ | [conarti-fsd/public-api](rules/public-api/README.md) | Check for module imports from public api | 💡 |
142
+ | import/order | Sort imports using 'eslint-plugin-import' | 🔧 |
package/dist/config.js ADDED
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RULE_DOCS_URL = exports.pathSeparator = exports.segments = exports.layersWithSlices = exports.layersWithoutSlices = exports.layers = void 0;
4
+ exports.layers = [
5
+ 'shared',
6
+ 'entities',
7
+ 'features',
8
+ 'widgets',
9
+ 'pages',
10
+ 'processes',
11
+ 'app',
12
+ ];
13
+ exports.layersWithoutSlices = [
14
+ 'shared',
15
+ 'app',
16
+ ];
17
+ exports.layersWithSlices = exports.layers.filter((layer) => !exports.layersWithoutSlices.includes(layer));
18
+ exports.segments = [
19
+ 'ui',
20
+ 'model',
21
+ 'lib',
22
+ 'api',
23
+ 'config',
24
+ 'assets',
25
+ ];
26
+ exports.pathSeparator = '/';
27
+ exports.RULE_DOCS_URL = 'https://example.com/rule/';
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ const recommended_1 = __importDefault(require("./recommended"));
6
+ const with_newlines_1 = __importDefault(require("./with-newlines"));
7
+ const with_newlines_and_type_group_1 = __importDefault(require("./with-newlines-and-type-group"));
8
+ const with_type_group_1 = __importDefault(require("./with-type-group"));
9
+ module.exports = {
10
+ parserOptions: {
11
+ ecmaVersion: '2015',
12
+ sourceType: 'module',
13
+ },
14
+ configs: {
15
+ recommended: recommended_1.default,
16
+ 'with-newlines': with_newlines_1.default,
17
+ 'with-type-group': with_type_group_1.default,
18
+ 'with-newlines-and-type-group': with_newlines_and_type_group_1.default,
19
+ },
20
+ };