@conarti/eslint-plugin-feature-sliced 1.0.5 → 2.0.0-rc.2

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 (78) hide show
  1. package/README.md +43 -38
  2. package/dist/index.cjs +1004 -0
  3. package/dist/index.d.cts +61 -0
  4. package/dist/index.d.ts +61 -0
  5. package/dist/index.js +978 -21
  6. package/package.json +39 -40
  7. package/dist/config.js +0 -27
  8. package/dist/configs/import-order/index.js +0 -20
  9. package/dist/configs/import-order/recommended.js +0 -28
  10. package/dist/configs/import-order/with-newlines-and-type-group.js +0 -28
  11. package/dist/configs/import-order/with-newlines.js +0 -28
  12. package/dist/configs/import-order/with-type-group.js +0 -28
  13. package/dist/configs/recommended.js +0 -11
  14. package/dist/configs/rules.js +0 -11
  15. package/dist/lib/feature-sliced/extract-feature-sliced-parts.js +0 -18
  16. package/dist/lib/feature-sliced/extract-layer.js +0 -21
  17. package/dist/lib/feature-sliced/extract-paths-info.js +0 -59
  18. package/dist/lib/feature-sliced/extract-segment.js +0 -18
  19. package/dist/lib/feature-sliced/extract-slice.js +0 -10
  20. package/dist/lib/feature-sliced/index.js +0 -10
  21. package/dist/lib/feature-sliced/layers.js +0 -16
  22. package/dist/lib/feature-sliced/validate-extracted-feature-sliced-parts.js +0 -29
  23. package/dist/lib/path/convert-to-absolute.js +0 -18
  24. package/dist/lib/path/index.js +0 -9
  25. package/dist/lib/path/is-path-relative.js +0 -7
  26. package/dist/lib/path/join-path.js +0 -12
  27. package/dist/lib/path/normalize-path.js +0 -19
  28. package/dist/lib/rule/create-rule.js +0 -7
  29. package/dist/lib/rule/extract-current-file-path.js +0 -11
  30. package/dist/lib/rule/extract-cwd.js +0 -13
  31. package/dist/lib/rule/extract-node-path.js +0 -13
  32. package/dist/lib/rule/extract-paths.js +0 -21
  33. package/dist/lib/rule/extract-rule-options.js +0 -7
  34. package/dist/lib/rule/get-source-range-without-quotes.js +0 -7
  35. package/dist/lib/rule/has-path.js +0 -11
  36. package/dist/lib/rule/index.js +0 -27
  37. package/dist/lib/rule/is-ignored-current-file.js +0 -12
  38. package/dist/lib/rule/is-ignored-target.js +0 -12
  39. package/dist/lib/rule/is-ignored.js +0 -12
  40. package/dist/lib/rule/is-node-type.js +0 -16
  41. package/dist/lib/rule/models.js +0 -2
  42. package/dist/lib/shared/get-by-reg-exp.js +0 -12
  43. package/dist/lib/shared/index.js +0 -11
  44. package/dist/lib/shared/is-null.js +0 -7
  45. package/dist/lib/shared/is-object.js +0 -7
  46. package/dist/lib/shared/is-undefined.js +0 -7
  47. package/dist/rules/absolute-relative/config.js +0 -2
  48. package/dist/rules/absolute-relative/index.js +0 -51
  49. package/dist/rules/absolute-relative/model/errors.js +0 -17
  50. package/dist/rules/absolute-relative/model/index.js +0 -5
  51. package/dist/rules/absolute-relative/model/should-be-absolute.js +0 -16
  52. package/dist/rules/absolute-relative/model/should-be-relative.js +0 -21
  53. package/dist/rules/absolute-relative/model/validate-and-report.js +0 -24
  54. package/dist/rules/layers-slices/config.js +0 -2
  55. package/dist/rules/layers-slices/index.js +0 -55
  56. package/dist/rules/layers-slices/model/errors.js +0 -22
  57. package/dist/rules/layers-slices/model/index.js +0 -5
  58. package/dist/rules/layers-slices/model/is-not-suitable-for-validation.js +0 -17
  59. package/dist/rules/layers-slices/model/specifiers/extract-import-specifiers.js +0 -8
  60. package/dist/rules/layers-slices/model/specifiers/has-errors-at-all-specifiers.js +0 -9
  61. package/dist/rules/layers-slices/model/specifiers/index.js +0 -7
  62. package/dist/rules/layers-slices/model/specifiers/validate-specifiers.js +0 -8
  63. package/dist/rules/layers-slices/model/validate-and-report.js +0 -46
  64. package/dist/rules/layers-slices/model/validate-node/index.js +0 -16
  65. package/dist/rules/layers-slices/model/validate-node/valid-by-layer-order.js +0 -10
  66. package/dist/rules/layers-slices/model/validate-node/valid-by-type-import.js +0 -9
  67. package/dist/rules/public-api/config.js +0 -2
  68. package/dist/rules/public-api/index.js +0 -65
  69. package/dist/rules/public-api/model/convert-to-public-api.js +0 -24
  70. package/dist/rules/public-api/model/errors.js +0 -34
  71. package/dist/rules/public-api/model/index.js +0 -5
  72. package/dist/rules/public-api/model/is-index-file.js +0 -7
  73. package/dist/rules/public-api/model/is-layer-public-api.js +0 -23
  74. package/dist/rules/public-api/model/is-segments-public-api.js +0 -11
  75. package/dist/rules/public-api/model/is-slice-public-api.js +0 -7
  76. package/dist/rules/public-api/model/should-be-from-public-api.js +0 -21
  77. package/dist/rules/public-api/model/validate-and-report-program.js +0 -15
  78. package/dist/rules/public-api/model/validate-and-report.js +0 -18
package/README.md CHANGED
@@ -68,55 +68,60 @@ You'll first need to install [ESLint](https://eslint.org/):
68
68
  npm i eslint --save-dev
69
69
  ```
70
70
 
71
- Next, install `@conarti/eslint-plugin-feature-sliced` and dependencies:
71
+ Next, install `@conarti/eslint-plugin-feature-sliced`:
72
72
 
73
73
  ```sh
74
- npm install -D @conarti/eslint-plugin-feature-sliced eslint-plugin-import
75
- # or by yarn
76
- yarn add -D @conarti/eslint-plugin-feature-sliced eslint-plugin-import
74
+ npm i -D @conarti/eslint-plugin-feature-sliced
77
75
  ```
78
76
 
79
- Note: 'eslint-plugin-import' is optional. You can skip installing this plugin if you don't need to sort imports in your code.
77
+ Note: the plugin may conflict with other import sorting plugins installed in your project.
78
+ If you do not want to use this plugin's sorting, disable it. More about this below
80
79
 
81
- ## Quick Usage
80
+ ## Usage
82
81
 
83
- Add `@conarti/feature-sliced/recommended` to extends section of your `.eslintrc` configuration file.
84
- It enables all rules and additional recommended configs of other eslint plugins, like `eslint-plugin-import`.
82
+ For simple use with loose settings, just call the function:
85
83
 
86
- ```json
87
- {
88
- "extends": [
89
- "plugin:@conarti/feature-sliced/recommended"
90
- ]
91
- }
84
+ ```js
85
+ // eslint.config.js
86
+ import featureSliced from '@conarti/eslint-plugin-feature-sliced';
87
+
88
+ export default [
89
+ featureSliced(),
90
+ ]
92
91
  ```
93
92
 
94
93
  ## Customisation
95
94
 
96
- If you want to use only plugin rules, add `@conarti/feature-sliced/rules` instead.
97
-
98
- ```json
99
- {
100
- "extends": [
101
- "plugin:@conarti/feature-sliced/rules"
102
- ]
103
- }
104
- ```
105
-
106
- If you only want to use certain rules, you can add them individually. To do this, you need to add `@conarti/feature-sliced` to the 'plugins'
107
- section of the configuration file and add the desired rules to the 'rules' section. Also now you don't need to use the 'extends' section like before
108
-
109
- ```json
110
- {
111
- "plugins": [
112
- "@conarti/feature-sliced"
113
- ],
114
- "rules": {
115
- "@conarti/feature-sliced/layers-slices": "error",
116
- "@conarti/feature-sliced/absolute-relative": "error",
117
- "@conarti/feature-sliced/public-api": "error"
118
- }
119
- }
95
+ You can also manage any rule and disable them:
96
+
97
+ ```js
98
+ import featureSliced from '@conarti/eslint-plugin-feature-sliced';
99
+
100
+ export default [
101
+ featureSliced({
102
+ /* Enables public api check in segments */
103
+ publicApi: { level: 'segments' },
104
+ /* Uses a different import sorter. You can disable it and use your own plugins and configurations */
105
+ sortImports: 'with-newlines',
106
+ /* This is how you can completely disable the rule */
107
+ absoluteRelative: false,
108
+ layersSlices: {
109
+ /* This is how you can disable the rule for imports in any files (ignore paths in code) */
110
+ ignorePatterns: [
111
+ /**
112
+ * Please note that the plugin reads the entire file path from the root of your system, not the project.
113
+ * That's why we added "**" to the beginning.
114
+ */
115
+ "**/src/components/**/*"
116
+ ],
117
+ /* This is how you can disable the rule for files or folders (ignore all paths in files or folders) */
118
+ ignoreInFilesPatterns: [
119
+ /* Do not check imports like "import foo from '@/app/some-module/foo'" */
120
+ "@/app/some-module/*",
121
+ ],
122
+ },
123
+ }),
124
+ ]
120
125
  ```
121
126
 
122
127
  ## Rules