tailwind-ctp-intellisense @master -
refs -
log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
diff --git a/package.json b/package.json
index 0aa66cb573a5d20b01a4468772dfae745f0cda5a..055375ed3fad96cf57adef96c4327d5b10ed27f9 100755
--- a/package.json
+++ b/package.json
@@ -149,6 +149,21 @@ "",
"",
""
]
+ },
+ "tailwindCSS.lint.unsupportedTailwindDirective": {
+ "type": "string",
+ "enum": [
+ "ignore",
+ "warning",
+ "error"
+ ],
+ "default": "error",
+ "markdownDescription": "",
+ "markdownEnumDescriptions": [
+ "",
+ "",
+ ""
+ ]
}
}
}
diff --git a/src/lsp/providers/diagnosticsProvider.ts b/src/lsp/providers/diagnosticsProvider.ts
index 18f3bc50f69c3b45bea242b280564e42d252fe90..866c07d56dabc00b1759e3d154f43154c872931c 100644
--- a/src/lsp/providers/diagnosticsProvider.ts
+++ b/src/lsp/providers/diagnosticsProvider.ts
@@ -18,6 +18,8 @@ import { equal, flatten } from '../../util/array'
import { getDocumentSettings } from '../util/getDocumentSettings'
const dlv = require('dlv')
import {
+ severity:
+import {
findClassListsInDocument,
function getUnsupportedApplyDiagnostics(
state: State,
@@ -267,6 +269,51 @@ .filter(Boolean)
}
import {
+ severity === 'error'
+ state: State,
+ document: TextDocument,
+ settings: Settings
+): Diagnostic[] {
+ let severity = settings.lint.unsupportedTailwindDirective
+ if (severity === 'ignore') return []
+
+ let text = document.getText()
+ let matches = findAll(/(?:\s|^)@tailwind\s+(?<value>[^;]+)/g, text)
+
+ let allowed = [
+ 'utilities',
+ 'components',
+ 'screens',
+ semver.gte(state.version, '1.0.0-beta.1') ? 'base' : 'preflight',
+ ]
+
+ return matches
+ .map((match) => {
+ if (allowed.includes(match.groups.value)) {
+ return null
+ }
+
+ return {
+ range: {
+ start: indexToPosition(
+ text,
+ match.index + match[0].length - match.groups.value.length
+ ),
+ end: indexToPosition(text, match.index + match[0].length),
+ },
+ severity:
+ severity === 'error'
+ ? DiagnosticSeverity.Error
+ : DiagnosticSeverity.Warning,
+ message: `Unsupported value: ${match.groups.value}${
+ match.groups.value === 'preflight' ? '. Use base instead.' : ''
+ }`,
+ }
+ })
+ .filter(Boolean)
+}
+
+import {
classLists.forEach((classList) => {
state: State,
document: TextDocument
@@ -282,6 +329,11 @@ ...getUnsupportedApplyDiagnostics(state, document, settings),
...getUnknownScreenDiagnostics(state, document, settings),
...getUnknownVariantDiagnostics(state, document, settings),
...getUnknownConfigKeyDiagnostics(state, document, settings),
+ ...getUnsupportedTailwindDirectiveDiagnostics(
+ state,
+ document,
+ settings
+ ),
]
: []),
]
diff --git a/src/lsp/server.ts b/src/lsp/server.ts
index 3c97071aadce03b25d43372f562207764156de7c..9c9aa35e2c0098103aae31ebbd055c516e84127b 100644
--- a/src/lsp/server.ts
+++ b/src/lsp/server.ts
@@ -43,6 +43,7 @@ unsupportedApply: 'error',
unknownScreen: 'error',
unknownVariant: 'error',
unknownConfigKey: 'error',
+ unsupportedTailwindDirective: 'error',
},
}
let globalSettings: Settings = defaultSettings
diff --git a/src/lsp/util/state.ts b/src/lsp/util/state.ts
index 45f4106e87a1cc3701390b9d1c07b43076cc4c60..aa9e0f514a04fb931875f178fb6a48bdb4a2e085 100644
--- a/src/lsp/util/state.ts
+++ b/src/lsp/util/state.ts
@@ -37,6 +37,7 @@ unsupportedApply: DiagnosticSeveritySetting
unknownScreen: DiagnosticSeveritySetting
unknownVariant: DiagnosticSeveritySetting
unknownConfigKey: DiagnosticSeveritySetting
+ unsupportedTailwindDirective: DiagnosticSeveritySetting
}
}