'use strict' ; import { TextDocument } from '../../cssLanguageTypes' ; import { SCSSParser } from '../../parser/scssParser' ; import { Rule , Rules } from '../../services/lintRules' ; import { assertEntries } from '../css/lint.test' ; function assertFontFace ( input , ... rules ) { let p = new SCSSParser ( ) ; let document = TextDocument . create ( 'test://test/test.scss' , 'scss' , 0 , input ) ; let node = p . internalParse ( input , p . _parseFontFace ) ! ; assertEntries ( node , document , rules ) ; } function assertRuleSet ( input , ... rules ) { let p = new SCSSParser ( ) ; let document = TextDocument . create ( 'test://test/test.scss' , 'scss' , 0 , input ) ; let node = p . internalParse ( input , p . _parseRuleset ) ! ; assertEntries ( node , document , rules ) ; } suite ( 'SCSS - Lint' , ( ) => { test ( 'empty ruleset' , function ( ) { assertRuleSet ( 'selector { color: red; nested {} }' , Rules . EmptyRuleSet ) ; } ) ; test ( 'ID selectors' , function ( ) { assertRuleSet ( '#id { color: red; }' , Rules . AvoidIdSelector ) ; assertRuleSet ( 'element#id { color: red; }' , Rules . AvoidIdSelector ) ; assertRuleSet ( '#id__#{foo} { color: red; }' , Rules . AvoidIdSelector ) ; } ) ; test ( 'Interpolation selectors' , function ( ) { assertRuleSet ( '#{foo} { color: red; }' ) ; assertRuleSet ( '#{foo}__cont { color: red; }' ) ; assertRuleSet ( '#{foo}.class { color: red; }' ) ; } ) ; test ( 'font-face required properties' , function ( ) { assertFontFace ( '@font-face {  }' , Rules . RequiredPropertiesForFontFace ) ; assertFontFace ( '@font-face { src: url(test.tff) }' , Rules . RequiredPropertiesForFontFace ) ; assertFontFace ( '@font-face { font-family: \'name\' }' , Rules . RequiredPropertiesForFontFace ) ; assertFontFace ( '@font-face { font-#{family}: foo }' ) ; assertFontFace ( '@font-face { font: {family: foo } }' ) ; assertFontFace ( '@font-face { @if true { } }' ) ; } ) ; test ( 'unknown properties' , function ( ) { assertRuleSet ( 'selector { -ms-property: "rest is missing" }' , Rules . UnknownVendorSpecificProperty ) ; assertRuleSet ( 'selector { -moz-box-shadow: "rest is missing" }' , Rules . UnknownVendorSpecificProperty , Rules . IncludeStandardPropertyWhenUsingVendorPrefix ) ; assertRuleSet ( 'selector { box-shadow: none }' ) ; assertRuleSet ( 'selector { -moz-#{box}-shadow: none }' ) ; assertRuleSet ( 'selector { outer: { nested : blue }' ) ; assertRuleSet ( ':export { prop: "some" }' ) ; } ) ; test ( 'vendor specific prefixes' , function ( ) { assertRuleSet ( 'selector { -moz-animation: none }' , Rules . AllVendorPrefixes , Rules . IncludeStandardPropertyWhenUsingVendorPrefix ) ; assertRuleSet ( 'selector { -moz-transform: none; transform: none }' , Rules . AllVendorPrefixes ) ; assertRuleSet ( 'selector { -moz-transform: none; transform: none; -o-transform: none; -webkit-transform: none; -ms-transform: none; }' ) ; } ) ; } ) ;