-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Revert "New config structure docs"" (#120)
- Loading branch information
Showing
5 changed files
with
360 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'steiger': minor | ||
--- | ||
|
||
Add documentation about the new config structure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# Examples | ||
|
||
## Glob matching | ||
|
||
All globs are matched only against files, folder severities are computed based on the files inside them. The formula is simple: the folder severity is the highest severity of files inside it (from highest to lowest: error, warn, off). | ||
|
||
**Glob examples**: | ||
|
||
- `./src/shared/**` - matches all files in the `shared` folder and its subfolders | ||
- `./src/shared/*` - matches all files that are direct children of the `shared` folder | ||
- `./src/shared` - based on the fact that globs are matched against files, this one matches only `shared` file (without an extension) inside the `src` folder | ||
- `**/__mocks__/**` - matches all files in all `__mocks__` folders throughout the project | ||
- `**/*.{test,spec}.{ts,tsx}` - matches all test files in the project | ||
|
||
## Example 1. Default case | ||
|
||
```javascript | ||
// ./steiger.config.ts | ||
import fsd from '@feature-sliced/steiger-plugin' | ||
import { defineConfig } from 'steiger' | ||
|
||
export default defineConfig([...fsd.configs.recommended]) | ||
``` | ||
|
||
## Example 2. FSD with all rules enabled by default, but excluding a couple of folders | ||
|
||
```javascript | ||
import fsd from '@feature-sliced/steiger-plugin' | ||
import { defineConfig } from 'steiger' | ||
|
||
export default defineConfig([ | ||
...fsd.configs.recommended, | ||
{ | ||
ignores: ['**/__mocks__/**'], | ||
}, | ||
]) | ||
``` | ||
|
||
## Example 3. FSD without certain rules | ||
|
||
```javascript | ||
import fsd from '@feature-sliced/steiger-plugin' | ||
import { defineConfig } from 'steiger' | ||
|
||
export default defineConfig([ | ||
...fsd.configs.recommended, | ||
{ | ||
rules: { | ||
'fsd/no-processes': 'off', | ||
'fsd/no-public-api-sidestep': 'warn', | ||
}, | ||
}, | ||
{ | ||
files: ['./src/shared/**'], | ||
rules: { | ||
'fsd/public-api': 'off', | ||
}, | ||
}, | ||
]) | ||
``` | ||
|
||
## Example 4. Disabling a rule for a specific folder | ||
|
||
```javascript | ||
import fsd from '@feature-sliced/steiger-plugin' | ||
import { defineConfig } from 'steiger' | ||
|
||
export default defineConfig([ | ||
...fsd.configs.recommended, | ||
{ | ||
files: ['./src/shared/**'], | ||
rules: { | ||
'fsd/no-public-api': 'off', | ||
}, | ||
}, | ||
]) | ||
``` | ||
|
||
## Example 5. Using ignores along with files | ||
|
||
```javascript | ||
import fsd from '@feature-sliced/steiger-plugin' | ||
import { defineConfig } from 'steiger' | ||
|
||
export default defineConfig([ | ||
...fsd.configs.recommended, | ||
{ | ||
files: ['./src/shared/**'], | ||
ignores: ['./src/shared/lib/**', './src/shared/ui/**'], | ||
rules: { | ||
'fsd/no-public-api': 'off', // Disable the rule for the shared folder, but not for the lib and ui folders | ||
}, | ||
}, | ||
]) | ||
``` | ||
|
||
## Example 6. Setting rule options | ||
|
||
```javascript | ||
import fsd from '@feature-sliced/steiger-plugin' | ||
import { defineConfig } from 'steiger' | ||
|
||
export default defineConfig([ | ||
...fsd.configs.recommended, | ||
{ | ||
rules: { | ||
'fsd/no-public-api': ['warn', { someOptions: true }], | ||
}, | ||
}, | ||
{ | ||
files: ['./src/shared/**'], | ||
rules: { | ||
'fsd/no-public-api': 'error', | ||
// 'fsd/no-public-api': ['error', { someOptions: false }], // Would throw an error as you can't override the options | ||
}, | ||
}, | ||
]) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# Migration guide | ||
|
||
## From 0.4.0 to 0.5.0 | ||
|
||
**Step 1**: First of all you need to make sure you upgraded Steiger package to version 0.5.0 or higher. | ||
|
||
**Step 2**: You need to install `@feature-sliced/steiger-plugin` package (that contains all FSD rules to run checks in your project). Run one of the following commands based on the package manager you use. | ||
|
||
**pnpm**: | ||
|
||
```shell | ||
pnpm add -D @feature-sliced/steiger-plugin | ||
``` | ||
|
||
**yarn**: | ||
|
||
```shell | ||
yarn add -D @feature-sliced/steiger-plugin | ||
``` | ||
|
||
**npm**: | ||
|
||
```shell | ||
npm i -D @feature-sliced/steiger-plugin | ||
``` | ||
|
||
**Step 3**: The final step. You need to bring your `steiger.config.js` file to the new configuration format. You can do that automatically by running one of the following commands. (Alter the command before running if your config file has an extension different from `.js`) | ||
|
||
Here is an example of the transformation that will be applied to your config: | ||
|
||
<table><thead><tr> | ||
<th>Before</th> | ||
<th>After</th> | ||
</tr></thead><tbody><tr><td> | ||
|
||
```ts | ||
// steiger.config.ts | ||
import { defineConfig } from 'steiger' | ||
|
||
export default defineConfig({ | ||
rules: { | ||
'public-api': 'off', | ||
'ambiguous-slice-names': 'off', | ||
'no-processes': 'off', | ||
}, | ||
}) | ||
``` | ||
|
||
</td><td> | ||
|
||
```ts | ||
// steiger.config.ts | ||
import { defineConfig } from 'steiger' | ||
import fsd from '@feature-sliced/steiger-plugin' | ||
|
||
export default defineConfig([ | ||
...fsd.configs.recommended, | ||
{ | ||
rules: { | ||
'fsd/public-api': 'off', | ||
'fsd/ambiguous-slice-names': 'off', | ||
'fsd/no-processes': 'off', | ||
}, | ||
}, | ||
]) | ||
``` | ||
|
||
</td></tr></tbody></table> | ||
|
||
> [!NOTE] | ||
> The codemod will probably get the formatting wrong, so don't forget to check the file yourself after migration. | ||
**pnpm**: | ||
|
||
```shell | ||
pnpx jscodeshift -t https://raw.githubusercontent.com/feature-sliced/steiger/master/packages/steiger/migrations/convert-config-to-flat.js steiger.config.js | ||
``` | ||
|
||
**yarn**: | ||
|
||
```shell | ||
yarn dlx jscodeshift -t https://raw.githubusercontent.com/feature-sliced/steiger/master/packages/steiger/migrations/convert-config-to-flat.js steiger.config.js | ||
``` | ||
|
||
**npm**: | ||
|
||
```shell | ||
npx jscodeshift -t https://raw.githubusercontent.com/feature-sliced/steiger/master/packages/steiger/migrations/convert-config-to-flat.js steiger.config.js | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.