39 Commits

Author SHA1 Message Date
Danny Mösch 2e87be0398 Infer name of parent rule in configurations (#6363) 2025-12-01 14:15:00 -05:00
Danny Mösch 9e5a526483 Enable unneeded_throws_rethrows rule (#6335) 2025-11-03 20:24:57 +01:00
Copilot 038135e14d Enable prefer_key_path rule (#6331)
Co-authored-by: SimplyDanny <16365760+SimplyDanny@users.noreply.github.com>
2025-10-31 16:58:41 +00:00
Danny Mösch 67e98911fc Get rid of @testable import 2025-10-18 00:19:05 +02:00
Danny Mösch 4065fc8437 Enable upcoming feature MemberImportVisibility (#6286) 2025-10-08 08:12:05 +02:00
Danny Mösch 9b3b538a18 Add @WorkingDirectory and @TemporaryDirectory macros to be used in tests 2025-10-03 22:41:38 +02:00
Danny Mösch bad724fb73 Extract macro helper functions 2025-10-03 22:41:38 +02:00
Danny Mösch 61558ce766 Separate @main macro provider allowing to exclude it from Bazel build
Avoids linker error in tests due to duplicated `_main` routine.
2025-10-03 22:41:38 +02:00
Danny Mösch aa67f5ac13 Adopt typed throws where possible (#5922) 2025-09-27 19:11:46 +02:00
Danny Mösch 77050e8c40 Enable a fully statically linked Linux executable (#6211)
If SwiftLint is built from this state using the Swift SDK, we'll get a
large self-contained Linux executable that runs without loading SourceKit.
It can do that by disabling any rule that requires SourceKit.

With `SWIFTLINT_DISABLE_SOURCEKIT` set on a normally (dynamically linked)
binary, the behavior is the same. That's different from the previously
reported more serious warnings.
2025-08-30 10:02:38 -04:00
Danny Mösch 2578cb3862 Use SwiftSyntax version 601.0.0 (#6003) 2025-04-03 21:27:57 +02:00
Danny Mösch ff21ff796c Specify rule properties in attribute 2024-12-26 20:40:29 +01:00
Danny Mösch 9f38075eb8 Evaluate arguments to boolean values 2024-12-26 20:40:29 +01:00
Danny Mösch 7385beaaf6 Add validation hook to configuration parsing (#5824) 2024-10-17 23:13:17 +02:00
Vladimir Burdukov 0d04196f92 Do not throw deprecation warning if property is not present in configuration (#5792) 2024-09-15 21:13:31 +02:00
Danny Mösch 98cf87ab8d Rename macros to something more descriptive (#5686) 2024-07-23 20:14:29 +02:00
Danny Mösch cc4b569c54 Enable unused_parameter rule and fix all violations (#5673) 2024-07-14 11:20:50 -04:00
Danny Mösch c810459e6a Enforce mandatory trailing comma and fix all violations (#5640) 2024-06-28 05:36:50 +00:00
Danny Mösch c29391a5ae Ignore but report invalid keys (#5567)
Don't fall back to the default configuration due to invalid keys.
2024-05-11 10:28:10 +00:00
Danny Mösch 1b7fbc4bcd Make postprocessors non-throwing (#5539)
Failing immediately when a property is invalid is too strict. It feels
sufficient to allow to report an issue but otherwise continue with a default
value instead of stopping execution completely.
2024-04-23 16:45:59 -04:00
Danny Mösch 299042a233 Allow to configure only severity in a short form for every rule with a severity (#5509)
The README states that a configuration like `attributes: error` is
valid to only set a different severity level for a rule (the
`attributes` rule here). This was previously only possible for rules
that were accompanied by a plain severity configuration.

I don't think this broke with the automatic parsing code generation.
For some rules it might have worked before, for others not. This change
makes it consistently working for all rules.
2024-03-25 21:40:56 +01:00
Danny Mösch dfa7f2fd4d Use result builder to fix indentation (#5507) 2024-03-24 09:04:36 +00:00
Danny Mösch e6bb673444 Handle issues in nested contexts gracefully while still throwing standalone
Use different issues to make inlineable configurations work in both
scenarios, namely being used standalone and nested as part of another
configuration. In the latter case, finding no values to parse in a raw
configuration is okay, while as a standalone configuration it's not.
2024-03-24 09:36:18 +01:00
Danny Mösch ccd50e8c68 Merge duplicated issues 2024-03-24 09:36:18 +01:00
Danny Mösch 82cad0bfff Allow to infer option names (#5505)
This allows to infer names of options from their names in a configuration. CamelCase is translated into snake_case automatically when `apply` is triggered.

* Don't have all `RuleConfiguration`s conform to `InlinableOptionType`. Mark types that must have this capability explicitly. Same for `AcceptableByConfigurationElement`.
* A type being an `InlinableOptionType` doesn't mean it's automatically inlined. This also doesn't depend on the fact of having a name for its key configured any longer. Instead, an `inline` attribute must explicitly be set to `true` in `@ConfigurationElement`.
* Key name inference is optional and can be overwritten by specifying a key name in the attribute.
* Inlined configurations only fail in `apply` when they are really sure that something is odd. Otherwise, they accept to not being updated.
2024-03-23 18:54:39 +01:00
Danny Mösch 4078e41f1b Let all rewriters have a configuration by default (#5467) 2024-02-11 15:13:24 +01:00
Danny Mösch fb4ef951ee Print invalid keys when configuration parsing fails (#5350) 2023-11-14 23:43:38 +01:00
Danny Mösch b87467fb2c Fail with diagnostic on non-boolean macro arguments 2023-10-19 21:35:57 +02:00
Danny Mösch 3ce2d60938 Move and rename macro errors 2023-10-19 21:35:57 +02:00
Danny Mösch 5ee0ff9535 Inline constants 2023-10-19 21:35:57 +02:00
Danny Mösch ca045a236b Use enums for macro implementations 2023-10-19 21:35:57 +02:00
Danny Mösch 5ec1de0312 Generate makeRewriter optionally (#5281) 2023-10-17 15:19:19 -04:00
Danny Mösch 40bd97038a Support arbitrary configurations in @SwiftSyntaxRule (#5275)
Almost all rules based on SwiftSyntax can be set up now by just adding
`@SwiftSyntaxRule` to the rule struct.
2023-10-16 19:34:43 +02:00
Danny Mösch 58928b7e40 Enforce any on existential types (#5273)
This makes syntactically clear which types are rather expensive.
2023-10-12 08:37:23 +02:00
JP Simard e30065e632 Prevent SwiftSyntax string interpolation errors in tests (#5258)
Previously this was logged to the console when running tests:

```
[ParseError] Parsing a `DeclSyntax` node from string interpolation produced the following parsing errors.
Set a breakpoint in `SyntaxParseable.logStringInterpolationParsingError()` to debug the failure.
```

And slightly improve the style of the expanded `@SwiftSyntaxRule` macro.
2023-10-03 14:53:41 +00:00
Danny Mösch f6e5f778fc Configure expression folding by argument of @SwiftSyntaxRule macro (#5255) 2023-10-03 07:16:33 -04:00
Danny Mösch 4716f59c54 Add tests for RuleConfigurationMacros (#5256) 2023-10-03 12:42:32 +02:00
JP Simard 591154091e Introduce @SwiftSyntaxRule & @Fold macros (#5253)
These macros remove some of the boilerplate involved when writing rules.

This change also adds test infrastructure for the macros used within
SwiftLint.
2023-10-02 18:43:16 -04:00
Danny Mösch 2433e7b5bf Make use of macros to generate configuration parsing code (#5250) 2023-10-02 22:35:24 +02:00