-
Notifications
You must be signed in to change notification settings - Fork 23
feat: add --quiet CLI option #254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Kedlingar
wants to merge
4
commits into
feature-sliced:master
Choose a base branch
from
Kedlingar:feat/quiet-option
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
bbc489b
feat(steiger): add quiet CLI option
Kedlingar 4b6dda7
refactor(steiger): revise warning filter option
Kedlingar 0a5e972
test(integration): fix POSIX warning snapshot
Kedlingar ee12228
test(integration): increase warning test timeout
Kedlingar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 a --ignore-warnings CLI option to report errors only. |
This file contains hidden or 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
26 changes: 26 additions & 0 deletions
26
integration-tests/tests/__snapshots__/ignore-warnings-stderr-posix.txt
This file contains hidden or 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,26 @@ | ||
| Without --ignore-warnings: | ||
|
|
||
| ┌ src/app/ui | ||
| × Layer "app" should not have "ui" segment. | ||
| │ | ||
| └ fsd/no-ui-in-app: https://github.com/feature-sliced/steiger/tree/master/packages/steiger-plugin-fsd/src/no-ui-in-app | ||
|
|
||
| ┌ src/processes | ||
| ‼ Layer "processes" is deprecated, avoid using it | ||
| │ | ||
| └ fsd/no-processes: https://github.com/feature-sliced/steiger/tree/master/packages/steiger-plugin-fsd/src/no-processes | ||
|
|
||
| ───────────────────────────────────────────────────────────── | ||
| Found 1 error and 1 warning (none can be fixed automatically) | ||
|
|
||
|
|
||
| With --ignore-warnings: | ||
|
|
||
| ┌ src/app/ui | ||
| × Layer "app" should not have "ui" segment. | ||
| │ | ||
| └ fsd/no-ui-in-app: https://github.com/feature-sliced/steiger/tree/master/packages/steiger-plugin-fsd/src/no-ui-in-app | ||
|
|
||
| ─────────────────────────────────────────────── | ||
| Found 1 error (none can be fixed automatically) | ||
|
|
26 changes: 26 additions & 0 deletions
26
integration-tests/tests/__snapshots__/ignore-warnings-stderr-windows.txt
This file contains hidden or 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,26 @@ | ||
| Without --ignore-warnings: | ||
|
|
||
| ┌ src\app\ui | ||
| × Layer "app" should not have "ui" segment. | ||
| │ | ||
| └ fsd/no-ui-in-app: https://github.com/feature-sliced/steiger/tree/master/packages/steiger-plugin-fsd/src/no-ui-in-app | ||
|
|
||
| ┌ src\processes | ||
| ‼ Layer "processes" is deprecated, avoid using it | ||
| │ | ||
| └ fsd/no-processes: https://github.com/feature-sliced/steiger/tree/master/packages/steiger-plugin-fsd/src/no-processes | ||
|
|
||
| ───────────────────────────────────────────────────────────── | ||
| Found 1 error and 1 warning (none can be fixed automatically) | ||
|
|
||
|
|
||
| With --ignore-warnings: | ||
|
|
||
| ┌ src\app\ui | ||
| × Layer "app" should not have "ui" segment. | ||
| │ | ||
| └ fsd/no-ui-in-app: https://github.com/feature-sliced/steiger/tree/master/packages/steiger-plugin-fsd/src/no-ui-in-app | ||
|
|
||
| ─────────────────────────────────────────────── | ||
| Found 1 error (none can be fixed automatically) | ||
|
|
This file contains hidden or 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,90 @@ | ||
| import * as fs from 'node:fs/promises' | ||
| import os from 'node:os' | ||
| import { dirname, join } from 'node:path' | ||
| import { fileURLToPath, pathToFileURL } from 'node:url' | ||
| import { exec } from 'tinyexec' | ||
| import { replaceSymbols } from 'figures' | ||
|
|
||
| import { expect, test } from 'vitest' | ||
|
|
||
| import { getSteigerBinPath } from '../utils/get-bin-path.js' | ||
|
|
||
| const temporaryDirectory = await fs.realpath(os.tmpdir()) | ||
| const steiger = await getSteigerBinPath() | ||
| const kitchenSinkExample = join(dirname(fileURLToPath(import.meta.url)), '../../examples/kitchen-sink-of-fsd-issues') | ||
| const fsdPluginUrl = pathToFileURL( | ||
| join(dirname(fileURLToPath(import.meta.url)), '../../packages/steiger-plugin-fsd/dist/index.js'), | ||
| ).href | ||
| const pathPlatform = os.platform() === 'win32' ? 'windows' : 'posix' | ||
|
|
||
| test('ignores warnings in the kitchen sink example project', async () => { | ||
| const project = join(temporaryDirectory, 'ignore-warnings') | ||
|
|
||
| await fs.rm(project, { recursive: true, force: true }) | ||
| await fs.cp(kitchenSinkExample, project, { recursive: true }) | ||
|
|
||
| await fs.writeFile( | ||
| join(project, 'steiger.config.mjs'), | ||
| ` | ||
| import fsd from ${JSON.stringify(fsdPluginUrl)} | ||
|
|
||
| export default [ | ||
| fsd.plugin, | ||
| { | ||
| rules: { | ||
| 'fsd/no-ui-in-app': 'error', | ||
| 'fsd/no-processes': 'warn', | ||
| }, | ||
| }, | ||
| ] | ||
| `, | ||
| ) | ||
|
|
||
| let { stderr: regularStderr } = await exec('node', [steiger, 'src'], { | ||
| nodeOptions: { | ||
| cwd: project, | ||
| env: { NO_COLOR: '1' }, | ||
| }, | ||
| }) | ||
|
|
||
| const ignoreWarningsRun = await exec('node', [steiger, 'src', '--ignore-warnings'], { | ||
| nodeOptions: { | ||
| cwd: project, | ||
| env: { NO_COLOR: '1' }, | ||
| }, | ||
| }) | ||
|
|
||
| let ignoreWarningsStderr = ignoreWarningsRun.stderr | ||
|
|
||
| regularStderr = replaceSymbols(regularStderr, { | ||
| useFallback: true, | ||
| }) | ||
| ignoreWarningsStderr = replaceSymbols(ignoreWarningsStderr, { | ||
| useFallback: true, | ||
| }) | ||
|
|
||
| expect(ignoreWarningsRun.exitCode).toBe(1) | ||
|
|
||
| await expect( | ||
| ['Without --ignore-warnings:', regularStderr, 'With --ignore-warnings:', ignoreWarningsStderr].join('\n'), | ||
| ).toMatchFileSnapshot(join('__snapshots__', `ignore-warnings-stderr-${pathPlatform}.txt`)) | ||
| }, 15_000) | ||
|
|
||
| test('does not allow ignore-warnings with fail-on-warnings', async () => { | ||
| const project = join(temporaryDirectory, 'conflicting-warning-options') | ||
|
|
||
| await fs.rm(project, { recursive: true, force: true }) | ||
| await fs.cp(kitchenSinkExample, project, { | ||
| recursive: true, | ||
| }) | ||
|
|
||
| const result = await exec('node', [steiger, 'src', '--ignore-warnings', '--fail-on-warnings'], { | ||
| nodeOptions: { | ||
| cwd: project, | ||
| env: { NO_COLOR: '1' }, | ||
| }, | ||
| }) | ||
|
|
||
| expect(result.exitCode).not.toBe(0) | ||
| expect(result.stderr).toContain('mutually exclusive') | ||
| }) |
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.