rename utilityConflicts lint rule

master
Brad Cornes 2020-06-23 12:22:31 +01:00
parent cba601d776
commit da5ed63109
8 changed files with 27 additions and 27 deletions

View File

@ -76,7 +76,7 @@
"markdownDescription": "Enable linting",
"scope": "language-overridable"
},
"tailwindCSS.lint.utilityConflicts": {
"tailwindCSS.lint.cssConflict": {
"type": "string",
"enum": [
"ignore",

View File

@ -6,14 +6,14 @@ import {
DiagnosticKind,
isInvalidApplyDiagnostic,
AugmentedDiagnostic,
isUtilityConflictsDiagnostic,
isCssConflictDiagnostic,
isInvalidConfigPathDiagnostic,
isInvalidTailwindDirectiveDiagnostic,
isInvalidScreenDiagnostic,
isInvalidVariantDiagnostic,
} from '../diagnostics/types'
import { flatten, dedupeBy } from '../../../util/array'
import { provideUtilityConflictsCodeActions } from './provideUtilityConflictsCodeActions'
import { provideCssConflictCodeActions } from './provideCssConflictCodeActions'
import { provideInvalidApplyCodeActions } from './provideInvalidApplyCodeActions'
import { provideSuggestionCodeActions } from './provideSuggestionCodeActions'
@ -56,8 +56,8 @@ export async function provideCodeActions(
return provideInvalidApplyCodeActions(state, params, diagnostic)
}
if (isUtilityConflictsDiagnostic(diagnostic)) {
return provideUtilityConflictsCodeActions(state, params, diagnostic)
if (isCssConflictDiagnostic(diagnostic)) {
return provideCssConflictCodeActions(state, params, diagnostic)
}
if (

View File

@ -4,14 +4,14 @@ import {
CodeAction,
CodeActionKind,
} from 'vscode-languageserver'
import { UtilityConflictsDiagnostic } from '../diagnostics/types'
import { CssConflictDiagnostic } from '../diagnostics/types'
import { joinWithAnd } from '../../util/joinWithAnd'
import { removeRangesFromString } from '../../util/removeRangesFromString'
export async function provideUtilityConflictsCodeActions(
export async function provideCssConflictCodeActions(
_state: State,
params: CodeActionParams,
diagnostic: UtilityConflictsDiagnostic
diagnostic: CssConflictDiagnostic
): Promise<CodeAction[]> {
return [
{

View File

@ -2,7 +2,7 @@ import { TextDocument } from 'vscode-languageserver'
import { State } from '../../util/state'
import { getDocumentSettings } from '../../util/getDocumentSettings'
import { DiagnosticKind, AugmentedDiagnostic } from './types'
import { getUtilityConflictDiagnostics } from './getUtilityConflictDiagnostics'
import { getCssConflictDiagnostics } from './getCssConflictDiagnostics'
import { getInvalidApplyDiagnostics } from './getInvalidApplyDiagnostics'
import { getInvalidScreenDiagnostics } from './getInvalidScreenDiagnostics'
import { getInvalidVariantDiagnostics } from './getInvalidVariantDiagnostics'
@ -13,7 +13,7 @@ export async function getDiagnostics(
state: State,
document: TextDocument,
only: DiagnosticKind[] = [
DiagnosticKind.UtilityConflicts,
DiagnosticKind.CssConflict,
DiagnosticKind.InvalidApply,
DiagnosticKind.InvalidScreen,
DiagnosticKind.InvalidVariant,
@ -25,8 +25,8 @@ export async function getDiagnostics(
return settings.validate
? [
...(only.includes(DiagnosticKind.UtilityConflicts)
? getUtilityConflictDiagnostics(state, document, settings)
...(only.includes(DiagnosticKind.CssConflict)
? getCssConflictDiagnostics(state, document, settings)
: []),
...(only.includes(DiagnosticKind.InvalidApply)
? getInvalidApplyDiagnostics(state, document, settings)

View File

@ -1,7 +1,7 @@
import { joinWithAnd } from '../../util/joinWithAnd'
import { State, Settings } from '../../util/state'
import { TextDocument, DiagnosticSeverity } from 'vscode-languageserver'
import { UtilityConflictsDiagnostic, DiagnosticKind } from './types'
import { CssConflictDiagnostic, DiagnosticKind } from './types'
import {
findClassListsInDocument,
getClassNamesInClassList,
@ -10,15 +10,15 @@ import { getClassNameDecls } from '../../util/getClassNameDecls'
import { getClassNameMeta } from '../../util/getClassNameMeta'
import { equal } from '../../../util/array'
export function getUtilityConflictDiagnostics(
export function getCssConflictDiagnostics(
state: State,
document: TextDocument,
settings: Settings
): UtilityConflictsDiagnostic[] {
let severity = settings.lint.utilityConflicts
): CssConflictDiagnostic[] {
let severity = settings.lint.cssConflict
if (severity === 'ignore') return []
let diagnostics: UtilityConflictsDiagnostic[] = []
let diagnostics: CssConflictDiagnostic[] = []
const classLists = findClassListsInDocument(state, document)
classLists.forEach((classList) => {
@ -51,7 +51,7 @@ export function getUtilityConflictDiagnostics(
if (conflictingClassNames.length === 0) return
diagnostics.push({
code: DiagnosticKind.UtilityConflicts,
code: DiagnosticKind.CssConflict,
className,
otherClassNames: conflictingClassNames,
range: className.range,

View File

@ -2,7 +2,7 @@ import { Diagnostic } from 'vscode-languageserver'
import { DocumentClassName, DocumentClassList } from '../../util/state'
export enum DiagnosticKind {
UtilityConflicts = 'utilityConflicts',
CssConflict = 'cssConflict',
InvalidApply = 'invalidApply',
InvalidScreen = 'invalidScreen',
InvalidVariant = 'invalidVariant',
@ -10,16 +10,16 @@ export enum DiagnosticKind {
InvalidTailwindDirective = 'invalidTailwindDirective',
}
export type UtilityConflictsDiagnostic = Diagnostic & {
code: DiagnosticKind.UtilityConflicts
export type CssConflictDiagnostic = Diagnostic & {
code: DiagnosticKind.CssConflict
className: DocumentClassName
otherClassNames: DocumentClassName[]
}
export function isUtilityConflictsDiagnostic(
export function isCssConflictDiagnostic(
diagnostic: AugmentedDiagnostic
): diagnostic is UtilityConflictsDiagnostic {
return diagnostic.code === DiagnosticKind.UtilityConflicts
): diagnostic is CssConflictDiagnostic {
return diagnostic.code === DiagnosticKind.CssConflict
}
export type InvalidApplyDiagnostic = Diagnostic & {
@ -78,7 +78,7 @@ export function isInvalidTailwindDirectiveDiagnostic(
}
export type AugmentedDiagnostic =
| UtilityConflictsDiagnostic
| CssConflictDiagnostic
| InvalidApplyDiagnostic
| InvalidScreenDiagnostic
| InvalidVariantDiagnostic

View File

@ -46,7 +46,7 @@ const defaultSettings: Settings = {
includeLanguages: {},
validate: true,
lint: {
utilityConflicts: 'warning',
cssConflict: 'warning',
invalidApply: 'error',
invalidScreen: 'error',
invalidVariant: 'error',

View File

@ -33,7 +33,7 @@ export type Settings = {
includeLanguages: Record<string, string>
validate: boolean
lint: {
utilityConflicts: DiagnosticSeveritySetting
cssConflict: DiagnosticSeveritySetting
invalidApply: DiagnosticSeveritySetting
invalidScreen: DiagnosticSeveritySetting
invalidVariant: DiagnosticSeveritySetting