Skip to content

Commit 506d008

Browse files
authored
Ignore css keys (#1)
* Feat: working ignore option * Chore: cleanup && improve: better similarity finding * Chore: more styling and wording changes * Chore: more wording changes..
1 parent e279928 commit 506d008

File tree

8 files changed

+437
-284
lines changed

8 files changed

+437
-284
lines changed
Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,46 @@
11
import { State } from '../util/state'
2-
import type {
3-
CodeActionParams,
4-
CodeAction,
2+
import {
3+
type CodeActionParams, CodeAction,
4+
CodeActionKind,
5+
Command,
56
} from 'vscode-languageserver'
67
import { CssConflictDiagnostic, InvalidIdentifierDiagnostic } from '../diagnostics/types'
78
import { joinWithAnd } from '../util/joinWithAnd'
89
import { removeRangesFromString } from '../util/removeRangesFromString'
910

11+
1012
export async function provideInvalidIdentifierCodeActions(
1113
_state: State,
1214
params: CodeActionParams,
1315
diagnostic: InvalidIdentifierDiagnostic
1416
): Promise<CodeAction[]> {
15-
if (!diagnostic.suggestion) return [];
16-
17-
debugger;
18-
return [
19-
{
20-
title: `Replace with '${diagnostic.suggestion}'`,
21-
kind: 'quickfix', // CodeActionKind.QuickFix,
22-
diagnostics: [diagnostic],
23-
edit: {
24-
changes: {
25-
[params.textDocument.uri]: [
26-
{
27-
range: diagnostic.range,
28-
newText: diagnostic.suggestion,
29-
},
30-
],
31-
},
32-
},
33-
},
34-
]
17+
const actions: CodeAction[] = [{
18+
title: `Ignore '${diagnostic.chunk}' in this workspace`,
19+
kind: CodeActionKind.QuickFix,
20+
diagnostics: [diagnostic],
21+
command: Command.create(`Ignore '${diagnostic.chunk}' in this workspace`, 'tailwindCSS.addWordToWorkspaceFileFromServer', diagnostic.chunk)
22+
}];
23+
24+
if (typeof diagnostic.suggestion == 'string') {
25+
actions.push({
26+
title: `Replace with '${diagnostic.suggestion}'`,
27+
kind: CodeActionKind.QuickFix,
28+
diagnostics: [diagnostic],
29+
isPreferred: true,
30+
edit: {
31+
changes: {
32+
[params.textDocument.uri]: [
33+
{
34+
range: diagnostic.range,
35+
newText: diagnostic.suggestion,
36+
},
37+
],
38+
},
39+
},
40+
})
41+
} else {
42+
// unimplemented.
43+
}
44+
45+
return actions;
3546
}

packages/tailwindcss-language-service/src/diagnostics/diagnosticsProvider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { getInvalidVariantDiagnostics } from './getInvalidVariantDiagnostics'
88
import { getInvalidConfigPathDiagnostics } from './getInvalidConfigPathDiagnostics'
99
import { getInvalidTailwindDirectiveDiagnostics } from './getInvalidTailwindDirectiveDiagnostics'
1010
import { getRecommendedVariantOrderDiagnostics } from './getRecommendedVariantOrderDiagnostics'
11-
import { getUnknownClassesDiagnostics } from './getUnknownClassesDiagnostics'
11+
import { getInvalidValueDiagnostics } from './getInvalidValueDiagnostics'
1212

1313
export async function doValidate(
1414
state: State,
@@ -29,7 +29,7 @@ export async function doValidate(
2929
return settings.tailwindCSS.validate
3030
? [
3131
...(only.includes(DiagnosticKind.InvalidIdentifier)
32-
? await getUnknownClassesDiagnostics(state, document, settings)
32+
? await getInvalidValueDiagnostics(state, document, settings)
3333
: []),
3434
...(only.includes(DiagnosticKind.CssConflict)
3535
? await getCssConflictDiagnostics(state, document, settings)

0 commit comments

Comments
 (0)