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", "markdownDescription": "Enable linting",
"scope": "language-overridable" "scope": "language-overridable"
}, },
"tailwindCSS.lint.utilityConflicts": { "tailwindCSS.lint.cssConflict": {
"type": "string", "type": "string",
"enum": [ "enum": [
"ignore", "ignore",

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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