Skip to content

Commit

Permalink
Update ESLint config
Browse files Browse the repository at this point in the history
  • Loading branch information
ai committed Oct 29, 2019
1 parent 89d723c commit 400d48f
Show file tree
Hide file tree
Showing 12 changed files with 205 additions and 170 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,31 @@
"dependencies": {
"@babel/register": "^7.6.2",
"browserslist": "^4.7.2",
"caniuse-lite": "^1.0.30001004",
"caniuse-lite": "^1.0.30001005",
"chalk": "^2.4.2",
"normalize-range": "^0.1.2",
"num2fraction": "^1.2.2",
"postcss": "^7.0.19",
"postcss": "^7.0.21",
"postcss-value-parser": "^4.0.2"
},
"devDependencies": {
"@babel/core": "^7.6.4",
"@babel/plugin-proposal-class-properties": "^7.5.5",
"@babel/plugin-transform-proto-to-assign": "^7.5.5",
"@babel/preset-env": "^7.6.3",
"@logux/eslint-config": "^33.0.0",
"@logux/eslint-config": "^34.0.0",
"@size-limit/preset-small-lib": "^2.1.6",
"babel-core": "^7.0.0-0",
"babel-eslint": "^10.0.3",
"babel-jest": "^24.9.0",
"babelify": "^10.0.0",
"browserify": "^16.5.0",
"eslint": "^6.5.1",
"eslint": "^6.6.0",
"eslint-ci": "^1.0.0",
"eslint-config-standard": "^14.1.0",
"eslint-plugin-es5": "^1.4.1",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jest": "^22.20.0",
"eslint-plugin-jest": "^23.0.2",
"eslint-plugin-node": "^10.0.0",
"eslint-plugin-prefer-let": "^1.0.1",
"eslint-plugin-promise": "^4.2.1",
Expand Down
12 changes: 6 additions & 6 deletions test/autoprefixer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,10 @@ afterEach(() => {
it('throws on wrong options', () => {
expect(() => {
autoprefixer({ browser: ['chrome 25', 'opera 12'] })
}).toThrowError(/overrideBrowserslist/)
}).toThrow(/overrideBrowserslist/)
expect(() => {
autoprefixer({ browserslist: ['chrome 25', 'opera 12'] })
}).toThrowError(/overrideBrowserslist/)
}).toThrow(/overrideBrowserslist/)
})

let options = {
Expand Down Expand Up @@ -390,13 +390,13 @@ it('parses difficult files', () => {
it('marks parsing errors', () => {
expect(() => {
postcss([cleaner]).process('a {').css
}).toThrowError('<css input>:1:1: Unclosed block')
}).toThrow('<css input>:1:1: Unclosed block')
})

it('shows file name in parse error', () => {
expect(() => {
postcss([cleaner]).process('a {', { from: 'a.css' }).css
}).toThrowError(/a.css:1:1: /)
}).toThrow(/a.css:1:1: /)
})

it('uses browserslist config', () => {
Expand Down Expand Up @@ -529,12 +529,12 @@ it('uses browserslist config in inspect', () => {
it('ignores unknown versions on request', () => {
expect(() => {
autoprefixer({ overrideBrowserslist: ['ie 100'] }).info()
}).toThrowError()
}).toThrow(/Unknown version 100 of ie/)
expect(() => {
autoprefixer({
overrideBrowserslist: ['ie 100'], ignoreUnknownVersions: true
}).info()
}).not.toThrowError()
}).not.toThrow()
})

describe('hacks', () => {
Expand Down
8 changes: 4 additions & 4 deletions test/browsers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ describe('.prefixes()', () => {

describe('.withPrefix()', () => {
it('finds possible prefix', () => {
expect(Browsers.withPrefix('1 -o-calc(1)')).toBeTruthy()
expect(Browsers.withPrefix('1 calc(1)')).toBeFalsy()
expect(Browsers.withPrefix('1 -o-calc(1)')).toBe(true)
expect(Browsers.withPrefix('1 calc(1)')).toBe(false)
})
})

Expand Down Expand Up @@ -71,7 +71,7 @@ describe('prefix()', () => {
describe('isSelected()', () => {
it('return true for selected browsers', () => {
let browsers = new Browsers(data, ['chrome 30', 'chrome 31'])
expect(browsers.isSelected('chrome 30')).toBeTruthy()
expect(browsers.isSelected('ie 6')).toBeFalsy()
expect(browsers.isSelected('chrome 30')).toBe(true)
expect(browsers.isSelected('ie 6')).toBe(false)
})
})
16 changes: 8 additions & 8 deletions test/declaration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ beforeEach(() => {

describe('otherPrefixes()', () => {
it('checks values for other prefixes', () => {
expect(tabsize.otherPrefixes('black', '-moz-')).toBeFalsy()
expect(tabsize.otherPrefixes('-moz-black', '-moz-')).toBeFalsy()
expect(tabsize.otherPrefixes('-dev-black', '-moz-')).toBeFalsy()
expect(tabsize.otherPrefixes('-ms-black', '-moz-')).toBeTruthy()
expect(tabsize.otherPrefixes('black', '-moz-')).toBe(false)
expect(tabsize.otherPrefixes('-moz-black', '-moz-')).toBe(false)
expect(tabsize.otherPrefixes('-dev-black', '-moz-')).toBe(false)
expect(tabsize.otherPrefixes('-ms-black', '-moz-')).toBe(true)
})
})

Expand All @@ -25,19 +25,19 @@ describe('needCascade()', () => {

it('returns true by default', () => {
let css = parse('a {\n tab-size: 4 }')
expect(tabsize.needCascade(css.first.first)).toBeTruthy()
expect(tabsize.needCascade(css.first.first)).toBe(true)
})

it('return false is disabled', () => {
prefixes.options.cascade = false
let css = parse('a {\n tab-size: 4 }')
expect(tabsize.needCascade(css.first.first)).toBeFalsy()
expect(tabsize.needCascade(css.first.first)).toBe(false)
})

it('returns false on declarations in one line', () => {
let css = parse('a { tab-size: 4 } a {\n tab-size: 4 }')
expect(tabsize.needCascade(css.first.first)).toBeFalsy()
expect(tabsize.needCascade(css.last.first)).toBeTruthy()
expect(tabsize.needCascade(css.first.first)).toBe(false)
expect(tabsize.needCascade(css.last.first)).toBe(true)
})
})

Expand Down
12 changes: 6 additions & 6 deletions test/old-selector.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,35 @@ let old = selector.old('-moz-')
describe('isHack()', () => {
it('returns true on last rule', () => {
let css = parse('::selection {} ::-moz-selection {}')
expect(old.isHack(css.last)).toBeTruthy()
expect(old.isHack(css.last)).toBe(true)
})

it('stops on another type', () => {
let css = parse('::-moz-selection {} ' +
'@keyframes anim {} ::selection {}')
expect(old.isHack(css.first)).toBeTruthy()
expect(old.isHack(css.first)).toBe(true)
})

it('stops on another selector', () => {
let css = parse('::-moz-selection {} a {} ::selection {}')
expect(old.isHack(css.first)).toBeTruthy()
expect(old.isHack(css.first)).toBe(true)
})

it('finds unprefixed selector', () => {
let css = parse('::-moz-selection {} ' +
'::-o-selection {} ::selection {}')
expect(old.isHack(css.first)).toBeFalsy()
expect(old.isHack(css.first)).toBe(false)
})
})

describe('check()', () => {
it('finds old selector', () => {
let css = parse('body::-moz-selection {} body::selection {}')
expect(old.check(css.first)).toBeTruthy()
expect(old.check(css.first)).toBe(true)
})

it('finds right', () => {
let css = parse('body:::-moz-selection {}')
expect(old.check(css.first)).toBeFalsy()
expect(old.check(css.first)).toBe(false)
})
})
6 changes: 3 additions & 3 deletions test/old-value.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ let OldValue = require('../lib/old-value')
describe('.check()', () => {
it('checks value in string', () => {
let old = new OldValue('calc', '-o-calc')
expect(old.check('1px -o-calc(1px)')).toBeTruthy()
expect(old.check('1px calc(1px)')).toBeFalsy()
expect(old.check('1px -o-calc(1px)')).toBe(true)
expect(old.check('1px calc(1px)')).toBe(false)
})

it('allows custom checks', () => {
let old = new OldValue('calc', '-o-calc', 'calc', /calc/)
expect(old.check('1px calc(1px)')).toBeTruthy()
expect(old.check('1px calc(1px)')).toBe(true)
})
})
10 changes: 5 additions & 5 deletions test/prefixer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('.clone()', () => {

describe('parentPrefix', () => {
it('works with root node', () => {
expect(prefix.parentPrefix(css)).toBeFalsy()
expect(prefix.parentPrefix(css)).toBe(false)
})

it('finds in at-rules', () => {
Expand All @@ -75,23 +75,23 @@ describe('parentPrefix', () => {
it('finds in parents', () => {
let decl = css.first.first
expect(prefix.parentPrefix(decl)).toEqual('-ms-')
expect(prefix.parentPrefix(css.nodes[2])).toBeFalsy()
expect(prefix.parentPrefix(css.nodes[2])).toBe(false)
})

it('caches prefix', () => {
prefix.parentPrefix(css.first)
expect(css.first._autoprefixerPrefix).toEqual('-ms-')

css.first._autoprefixerPrefix = false
expect(prefix.parentPrefix(css.first)).toBeFalsy()
expect(prefix.parentPrefix(css.first)).toBe(false)
})

it('finds only browsers prefixes', () => {
expect(prefix.parentPrefix(css.nodes[2])).toBeFalsy()
expect(prefix.parentPrefix(css.nodes[2])).toBe(false)
})

it('works with selector contained --', () => {
let parsed = parse(':--a { color: black }')
expect(prefix.parentPrefix(parsed.first.first)).toBeFalsy()
expect(prefix.parentPrefix(parsed.first.first)).toBe(false)
})
})
8 changes: 4 additions & 4 deletions test/prefixes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ describe('group()', () => {
let css = parse('a { -moz-a: 1; -ms-a: 1; -o-a: 1; a: 1 }')
let decl = css.first.first

expect(empty.group(decl).down(i => i.prop === '-o-a')).toBeTruthy()
expect(empty.group(decl).down(i => i.prop === '-o-b')).toBeFalsy()
expect(empty.group(decl).down(i => i.prop === '-o-a')).toBe(true)
expect(empty.group(decl).down(i => i.prop === '-o-b')).toBe(false)
})
})

Expand All @@ -194,8 +194,8 @@ describe('group()', () => {
let css = parse('a { -moz-a: 1; -ms-a: 1; -o-a: 1; a: 1 }')
let decl = css.first.nodes[3]

expect(empty.group(decl).up(i => i.prop === '-ms-a')).toBeTruthy()
expect(empty.group(decl).up(i => i.prop === '-ms-b')).toBeFalsy()
expect(empty.group(decl).up(i => i.prop === '-ms-a')).toBe(true)
expect(empty.group(decl).up(i => i.prop === '-ms-b')).toBe(false)
})
})
})
26 changes: 11 additions & 15 deletions test/selector.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,24 @@ describe('prefixed()', () => {
describe('regexp()', () => {
it('creates regexp for prefix', () => {
let regexp = selector.regexp('-moz-')
expect(regexp.test('::-moz-selection')).toBeTruthy()
expect(regexp.test('::selection')).toBeFalsy()
expect(regexp.test('::-moz-selection')).toBe(true)
expect(regexp.test('::selection')).toBe(false)
})

it('creates regexp without prefix', () => {
let regexp = selector.regexp()
expect(regexp.test('::-moz-selection')).toBeFalsy()
expect(regexp.test('::selection')).toBeTruthy()
expect(regexp.test('::-moz-selection')).toBe(false)
expect(regexp.test('::selection')).toBe(true)
})
})

describe('check()', () => {
it('checks rule selectors', () => {
let css = parse('body .selection {}, ' +
':::selection {}, body ::selection {}')
expect(selector.check(css.nodes[0])).toBeFalsy()
expect(selector.check(css.nodes[1])).toBeFalsy()
expect(selector.check(css.nodes[2])).toBeTruthy()
expect(selector.check(css.nodes[0])).toBe(false)
expect(selector.check(css.nodes[1])).toBe(false)
expect(selector.check(css.nodes[2])).toBe(true)
})
})

Expand Down Expand Up @@ -81,28 +81,24 @@ describe('already()', () => {

it('returns false on first element', () => {
let css = parse('::selection {}')
expect(selector.already(css.first, prefixeds, '-moz-'))
.toBeFalsy()
expect(selector.already(css.first, prefixeds, '-moz-')).toBe(false)
})

it('stops on another type', () => {
let css = parse('::-moz-selection {} ' +
'@keyframes anim {} ::selection {}')
expect(selector.already(css.nodes[2], prefixeds, '-moz-'))
.toBeFalsy()
expect(selector.already(css.nodes[2], prefixeds, '-moz-')).toBe(false)
})

it('stops on another selector', () => {
let css = parse('::-moz-selection {} a {} ::selection {}')
expect(selector.already(css.nodes[2], prefixeds, '-moz-'))
.toBeFalsy()
expect(selector.already(css.nodes[2], prefixeds, '-moz-')).toBe(false)
})

it('finds prefixed even if unknown prefix is between', () => {
let css = parse('::-moz-selection {} ' +
'::-o-selection {} ::selection {}')
expect(selector.already(css.nodes[2], prefixeds, '-moz-'))
.toBeTruthy()
expect(selector.already(css.nodes[2], prefixeds, '-moz-')).toBe(true)
})
})

Expand Down
24 changes: 12 additions & 12 deletions test/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('.error()', () => {
error = e
}

expect(error.autoprefixer).toBeTruthy()
expect(error.autoprefixer).toBe(true)
})
})

Expand Down Expand Up @@ -47,17 +47,17 @@ describe('.regexp()', () => {
return string.match(regexp) !== null
}

expect(check('foo')).toBeTruthy()
expect(check('Foo')).toBeTruthy()
expect(check('one, foo, two')).toBeTruthy()
expect(check('one(),foo(),two()')).toBeTruthy()
expect(check('foo')).toBe(true)
expect(check('Foo')).toBe(true)
expect(check('one, foo, two')).toBe(true)
expect(check('one(),foo(),two()')).toBe(true)

expect('foo(), a, foo'.replace(regexp, '$1b$2'))
.toEqual('bfoo(), a, bfoo')

expect(check('foob')).toBeFalsy()
expect(check('(foo)')).toBeFalsy()
expect(check('-a-foo')).toBeFalsy()
expect(check('foob')).toBe(false)
expect(check('(foo)')).toBe(false)
expect(check('-a-foo')).toBe(false)
})

it('escapes string if needed', () => {
Expand All @@ -66,12 +66,12 @@ describe('.regexp()', () => {
return string.match(regexp) !== null
}

expect(check('a')).toBeFalsy()
expect(check('(a|b)')).toBeTruthy()
expect(check('a')).toBe(false)
expect(check('(a|b)')).toBe(true)

regexp = utils.regexp('(a|b)', false)
expect(check('a')).toBeTruthy()
expect(check('b')).toBeTruthy()
expect(check('a')).toBe(true)
expect(check('b')).toBe(true)
})
})

Expand Down
10 changes: 5 additions & 5 deletions test/value.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ describe('check()', () => {
'3: -ms-calc; ' +
'4: calced; }')

expect(calc.check(css.first.nodes[0])).toBeTruthy()
expect(calc.check(css.first.nodes[1])).toBeTruthy()
expect(calc.check(css.first.nodes[2])).toBeTruthy()
expect(calc.check(css.first.nodes[0])).toBe(true)
expect(calc.check(css.first.nodes[1])).toBe(true)
expect(calc.check(css.first.nodes[2])).toBe(true)

expect(calc.check(css.first.nodes[3])).toBeFalsy()
expect(calc.check(css.first.nodes[4])).toBeFalsy()
expect(calc.check(css.first.nodes[3])).toBe(false)
expect(calc.check(css.first.nodes[4])).toBe(false)
})
})

Expand Down
Loading

0 comments on commit 400d48f

Please sign in to comment.