From bb816118221bf016cdf0094b8a20492eeaa519bb Mon Sep 17 00:00:00 2001 From: Remi Rousselet Date: Mon, 20 Nov 2023 12:05:29 +0100 Subject: [PATCH 1/2] The following packages have been updated: custom_lint : 0.5.6 -> 0.5.7 custom_lint_analyzer_plugin_loader : 0.5.6 -> 0.5.7 custom_lint_core : 0.5.6 -> 0.5.7 custom_lint_builder : 0.5.6 -> 0.5.7 --- packages/custom_lint/CHANGELOG.md | 2 +- packages/custom_lint/example/example_lint/pubspec.yaml | 1 - packages/custom_lint/example/pubspec.yaml | 1 - packages/custom_lint/pubspec.yaml | 2 +- packages/custom_lint/tools/analyzer_plugin/pubspec.yaml | 4 ++-- packages/custom_lint_builder/CHANGELOG.md | 5 +++++ .../custom_lint_builder/example/example_lint/pubspec.yaml | 1 - packages/custom_lint_builder/example/pubspec.yaml | 1 - packages/custom_lint_builder/pubspec.yaml | 6 +++--- packages/custom_lint_core/CHANGELOG.md | 4 ++++ packages/custom_lint_core/pubspec.yaml | 4 ++-- 11 files changed, 18 insertions(+), 13 deletions(-) diff --git a/packages/custom_lint/CHANGELOG.md b/packages/custom_lint/CHANGELOG.md index 11a0df7b..2c487cb4 100644 --- a/packages/custom_lint/CHANGELOG.md +++ b/packages/custom_lint/CHANGELOG.md @@ -1,4 +1,4 @@ -## Unreleased patch +## 0.5.7 - 2023-11-20 - Support JSON output format via CLI parameter `--format json|default` (thanks to @kuhnroyal) diff --git a/packages/custom_lint/example/example_lint/pubspec.yaml b/packages/custom_lint/example/example_lint/pubspec.yaml index 071493b2..ae33391a 100644 --- a/packages/custom_lint/example/example_lint/pubspec.yaml +++ b/packages/custom_lint/example/example_lint/pubspec.yaml @@ -1,5 +1,4 @@ name: custom_lint_example_lint -version: 0.0.9 publish_to: none environment: diff --git a/packages/custom_lint/example/pubspec.yaml b/packages/custom_lint/example/pubspec.yaml index d29c2c48..90b786c8 100644 --- a/packages/custom_lint/example/pubspec.yaml +++ b/packages/custom_lint/example/pubspec.yaml @@ -1,5 +1,4 @@ name: custom_lint_example_app -version: 0.0.1 publish_to: none environment: diff --git a/packages/custom_lint/pubspec.yaml b/packages/custom_lint/pubspec.yaml index e9489ea6..1eff22b3 100644 --- a/packages/custom_lint/pubspec.yaml +++ b/packages/custom_lint/pubspec.yaml @@ -1,5 +1,5 @@ name: custom_lint -version: 0.5.6 +version: 0.5.7 description: Lint rules are a powerful way to improve the maintainability of a project. Custom Lint allows package authors and developers to easily write custom lint rules. repository: https://github.com/invertase/dart_custom_lint issue_tracker: https://github.com/invertase/dart_custom_lint/issues diff --git a/packages/custom_lint/tools/analyzer_plugin/pubspec.yaml b/packages/custom_lint/tools/analyzer_plugin/pubspec.yaml index 9e630427..8ac26cb8 100644 --- a/packages/custom_lint/tools/analyzer_plugin/pubspec.yaml +++ b/packages/custom_lint/tools/analyzer_plugin/pubspec.yaml @@ -1,13 +1,13 @@ name: custom_lint_analyzer_plugin_loader description: This pubspec determines the version of the analyzer plugin to load. -version: 0.5.6 +version: 0.5.7 publish_to: none environment: sdk: ">=2.14.0 <4.0.0" dependencies: - custom_lint: 0.5.6 + custom_lint: 0.5.7 # TODO: If you want to contribute to custom_lint, add a pubspec_overrides.yaml file # in this folder, containing the following: diff --git a/packages/custom_lint_builder/CHANGELOG.md b/packages/custom_lint_builder/CHANGELOG.md index 1a227cba..8b639b98 100644 --- a/packages/custom_lint_builder/CHANGELOG.md +++ b/packages/custom_lint_builder/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.5.7 - 2023-11-20 + +- `custom_lint` upgraded to `0.5.7` +- `custom_lint_core` upgraded to `0.5.7` + ## 0.5.6 - 2023-10-30 - `custom_lint` upgraded to `0.5.6` diff --git a/packages/custom_lint_builder/example/example_lint/pubspec.yaml b/packages/custom_lint_builder/example/example_lint/pubspec.yaml index 8ec27ede..7e22afae 100644 --- a/packages/custom_lint_builder/example/example_lint/pubspec.yaml +++ b/packages/custom_lint_builder/example/example_lint/pubspec.yaml @@ -1,5 +1,4 @@ name: custom_lint_builder_example_lint -version: 0.0.9 publish_to: none environment: diff --git a/packages/custom_lint_builder/example/pubspec.yaml b/packages/custom_lint_builder/example/pubspec.yaml index 61dd2276..dfaefdfa 100644 --- a/packages/custom_lint_builder/example/pubspec.yaml +++ b/packages/custom_lint_builder/example/pubspec.yaml @@ -1,5 +1,4 @@ name: custom_lint_builder_example_app -version: 0.0.1 publish_to: none environment: diff --git a/packages/custom_lint_builder/pubspec.yaml b/packages/custom_lint_builder/pubspec.yaml index cce77932..93d8a289 100644 --- a/packages/custom_lint_builder/pubspec.yaml +++ b/packages/custom_lint_builder/pubspec.yaml @@ -1,5 +1,5 @@ name: custom_lint_builder -version: 0.5.6 +version: 0.5.7 description: A package to help writing custom linters repository: https://github.com/invertase/dart_custom_lint @@ -12,10 +12,10 @@ dependencies: collection: ^1.16.0 # Using tight constraints as custom_lint_builder communicate with each-other # using a specific contract - custom_lint: 0.5.6 + custom_lint: 0.5.7 # Using tight constraints as custom_lint_builder communicate with each-other # using a specific contract - custom_lint_core: 0.5.6 + custom_lint_core: 0.5.7 glob: ^2.1.1 hotreloader: ">=3.0.5 <5.0.0" meta: ^1.7.0 diff --git a/packages/custom_lint_core/CHANGELOG.md b/packages/custom_lint_core/CHANGELOG.md index 606de5d5..11ca5bd4 100644 --- a/packages/custom_lint_core/CHANGELOG.md +++ b/packages/custom_lint_core/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.5.7 - 2023-11-20 + +- `custom_lint` upgraded to `0.5.7` + ## 0.5.6 - 2023-10-30 - `custom_lint` upgraded to `0.5.6` diff --git a/packages/custom_lint_core/pubspec.yaml b/packages/custom_lint_core/pubspec.yaml index 6cbc8d2d..56b22992 100644 --- a/packages/custom_lint_core/pubspec.yaml +++ b/packages/custom_lint_core/pubspec.yaml @@ -1,5 +1,5 @@ name: custom_lint_core -version: 0.5.6 +version: 0.5.7 description: A package to help writing custom linters repository: https://github.com/invertase/dart_custom_lint @@ -12,7 +12,7 @@ dependencies: collection: ^1.16.0 # Using tight constraints as custom_lint_builder communicate with each-other # using a specific contract - custom_lint: 0.5.6 + custom_lint: 0.5.7 matcher: ^0.12.0 meta: ^1.7.0 path: ^1.8.0 From 5b5b0dd2923963713403a2c868d7f8e128bb440d Mon Sep 17 00:00:00 2001 From: Piotr Rogulski Date: Mon, 4 Dec 2023 11:53:46 +0100 Subject: [PATCH 2/2] Add indent to the ignore comment (#207) --- packages/custom_lint/CHANGELOG.md | 4 +++ packages/custom_lint/test/ignore_test.dart | 28 +++++++++++++++++++ packages/custom_lint_builder/CHANGELOG.md | 4 +++ .../custom_lint_builder/lib/src/ignore.dart | 6 +++- 4 files changed, 41 insertions(+), 1 deletion(-) diff --git a/packages/custom_lint/CHANGELOG.md b/packages/custom_lint/CHANGELOG.md index 2c487cb4..a8616733 100644 --- a/packages/custom_lint/CHANGELOG.md +++ b/packages/custom_lint/CHANGELOG.md @@ -1,3 +1,7 @@ +## Unreleased fix + +- `// ignore` comments now correctly respect indentation when they are inserted (thanks to @PiotrRogulski) + ## 0.5.7 - 2023-11-20 - Support JSON output format via CLI parameter `--format json|default` (thanks to @kuhnroyal) diff --git a/packages/custom_lint/test/ignore_test.dart b/packages/custom_lint/test/ignore_test.dart index 17a5a928..1d03f6a3 100644 --- a/packages/custom_lint/test/ignore_test.dart +++ b/packages/custom_lint/test/ignore_test.dart @@ -66,6 +66,34 @@ void fn2() {} expectMatchesGoldenFixes(fixes); }); + test('Emits indented ignore quick-fix', () async { + final plugin = createPlugin( + name: 'test_lint', + main: source, + ); + + final app = createLintUsage( + name: 'test_app', + plugins: {'test_lint': plugin.uri}, + source: { + 'lib/main.dart': ''' + void fn() {} +''', + }, + ); + + final runner = await startRunnerForApp(app); + await runner.getLints(reload: false); + final fixes = await runner + .getFixes(app.file('lib', 'main.dart').path, 10) + .then((e) => e.fixes); + + expect( + fixes[0].fixes[0].change.edits[0].edits[0].replacement, + startsWith('${' ' * 4}// ignore: hello_world'), + ); + }); + test('supports `// ignore: code`', () async { final plugin = createPlugin( name: 'test_lint', diff --git a/packages/custom_lint_builder/CHANGELOG.md b/packages/custom_lint_builder/CHANGELOG.md index 8b639b98..9c817183 100644 --- a/packages/custom_lint_builder/CHANGELOG.md +++ b/packages/custom_lint_builder/CHANGELOG.md @@ -1,3 +1,7 @@ +## Unreleased fix + +- `// ignore` comments now correctly respect indentation when they are inserted (thanks to @PiotrRogulski) + ## 0.5.7 - 2023-11-20 - `custom_lint` upgraded to `0.5.7` diff --git a/packages/custom_lint_builder/lib/src/ignore.dart b/packages/custom_lint_builder/lib/src/ignore.dart index 6409bcf6..b382c308 100644 --- a/packages/custom_lint_builder/lib/src/ignore.dart +++ b/packages/custom_lint_builder/lib/src/ignore.dart @@ -128,9 +128,13 @@ class IgnoreCode extends DartFix { final startLineOffset = resolver.lineInfo.getOffsetOfLine(offsetLine); + final indentLength = resolver.source.contents.data + .substring(startLineOffset) + .indexOf(RegExp(r'\S')); + builder.addSimpleInsertion( startLineOffset, - '// ignore: ${analysisError.errorCode.name}\n', + '${' ' * indentLength}// ignore: ${analysisError.errorCode.name}\n', ); } });