diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fa7cca..06323a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## Unreleased + +- removed: `swiftlint.forceExcludePaths` as it didn't work. Use `excluded` in your `.swiftlint` config instead. #39 + ## 1.7.3 - fix: Unrecognized arguments: --format #47 #55 diff --git a/README.md b/README.md index c2210b1..6973567 100755 --- a/README.md +++ b/README.md @@ -41,16 +41,15 @@ let package = Package( ## Configuration -| Config | Type | Default | Description | -| --------------------------------------- | ---------- | -------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | -| `swiftlint.enable` | `Bool` | `true` | Whether SwiftLint should actually do something. | -| `swiftlint.onlyEnableOnSwiftPMProjects` | `Bool` | `false` | Requires and uses a SwiftLint as SwiftPM dependency. | -| `swiftlint.onlyEnableWithConfig` | `Bool` | `false` | Only lint if config present. | -| `swiftlint.path` | `String` | `/usr/local/bin/swiftlint` | The location of the globally installed SwiftLint. | -| `swiftlint.additionalParameters` | `[String]` | `["--format"]` | Additional parameters to pass to SwiftLint. | -| `swiftlint.configSearchPaths` | `[String]` | `[]` | Possible paths for SwiftLint config. _This disables [nested configurations](https://github.com/realm/SwiftLint#nested-configurations)!_ | -| `swiftlint.forceExcludePaths` | `[String]` | `["tmp","build",".build","Pods","Carthage"]` | Paths to be excluded from being passed to SwiftLint. | -| `swiftlint.autoLintWorkspace` | `Bool` | `true` | Automatically lint the whole project right after start. | +| Config | Type | Default | Description | +| --------------------------------------- | ---------- | -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | +| `swiftlint.enable` | `Bool` | `true` | Whether SwiftLint should actually do something. | +| `swiftlint.onlyEnableOnSwiftPMProjects` | `Bool` | `false` | Requires and uses a SwiftLint as SwiftPM dependency. | +| `swiftlint.onlyEnableWithConfig` | `Bool` | `false` | Only lint if config present. | +| `swiftlint.path` | `String` | `/usr/local/bin/swiftlint` | The location of the globally installed SwiftLint. | +| `swiftlint.additionalParameters` | `[String]` | `["--format"]` | Additional parameters to pass to SwiftLint. | +| `swiftlint.configSearchPaths` | `[String]` | `[]` | Possible paths for SwiftLint config. _This disables [nested configurations](https://github.com/realm/SwiftLint#nested-configurations)!_ | +| `swiftlint.autoLintWorkspace` | `Bool` | `true` | Automatically lint the whole project right after start. | ## Commands diff --git a/package.json b/package.json index 0815205..dd33065 100644 --- a/package.json +++ b/package.json @@ -87,20 +87,6 @@ "type": "string" } }, - "swiftlint.forceExcludePaths": { - "type": "array", - "description": "Paths to be excluded from being passed to SwiftLint.", - "default": [ - "tmp", - "build", - ".build", - "Pods", - "Carthage" - ], - "items": { - "type": "string" - } - }, "swiftlint.autoLintWorkspace": { "type": "boolean", "description": "Automatically lint the whole project right after start.", diff --git a/src/Current.ts b/src/Current.ts index 227d6b2..c8b99a1 100644 --- a/src/Current.ts +++ b/src/Current.ts @@ -33,7 +33,6 @@ export interface Current { resetSwiftLintPath(): void; openSettings(): void; lintConfigSearchPaths(): string[]; - forceExcludePaths(): string[]; autoLintWorkspace(): boolean; }; } @@ -157,16 +156,6 @@ export function prodEnvironment(): Current { .getConfiguration() .get("swiftlint.configSearchPaths", []) .map(absolutePath), - forceExcludePaths: () => - vscode.workspace - .getConfiguration() - .get("swiftlint.forceExcludePaths", [ - "tmp", - "build", - ".build", - "Pods", - "Carthage", - ]), }, }; } diff --git a/src/SwiftLintProvider.ts b/src/SwiftLintProvider.ts index f9955e0..031e2a7 100644 --- a/src/SwiftLintProvider.ts +++ b/src/SwiftLintProvider.ts @@ -156,14 +156,7 @@ export class SwiftLint { parameters: [], workspaceFolder, }); - this.diagnosticCollection.set( - document.uri, - this.isForceExcluded( - path.relative(workspaceFolder?.uri.fsPath ?? "/", document.uri.fsPath) - ) - ? [] - : diagnostics - ); + this.diagnosticCollection.set(document.uri, diagnostics); this.latestDocumentVersion.set(document.uri, document.version); } catch (error) { handleFormatError(error, document.uri); @@ -211,7 +204,7 @@ export class SwiftLint { for (const file of diagnosticsByFile.keys()) { this.diagnosticCollection.set( folder.uri.with({ path: file }), - this.isForceExcluded(file) ? [] : diagnosticsByFile.get(file) + diagnosticsByFile.get(file) ); } } catch (error) { @@ -223,14 +216,4 @@ export class SwiftLint { await Promise.all(lintWorkspaces); } - - private isForceExcluded(relativePath: string): boolean { - for (const exclude of Current.config.forceExcludePaths()) { - const excluded = match([relativePath], exclude, { matchBase: true }); - if (excluded.length > 0) { - return true; - } - } - return false; - } } diff --git a/src/lint.ts b/src/lint.ts index 60a88ed..fea1049 100644 --- a/src/lint.ts +++ b/src/lint.ts @@ -208,16 +208,11 @@ async function detectDefaultPathArguments( workspaceFolder: WorkspaceFolder ): Promise { const fileUris = await workspace.findFiles( - new RelativePattern(workspaceFolder, "**/*.swift"), - new RelativePattern(workspaceFolder, forceExcludePathsPattern()) + new RelativePattern(workspaceFolder, "**/*.swift") ); return fileUris.map((uri) => uri.path); } -function forceExcludePathsPattern(): string { - return "**/{" + Current.config.forceExcludePaths().join(",") + "}/***"; -} - function reportToPreciseDiagnosticForDocument( document: TextDocument ): (report: Report) => Diagnostic {