Skip to content

Commit

Permalink
Improve eslint situation
Browse files Browse the repository at this point in the history
ESLint was complaining about a bunch of things in tests, like undefined
variables that are global and some other small things. This commit fixes
most of these issues. I also modified the tool so it runs on more code
by default. This should give much better coverage for this project.

As a result, I spotted a couple of files that look suspiciously
erroneous that I ended up removing here. They seem to have appeared in a
merge commit: 091f339.
  • Loading branch information
lencioni committed Mar 8, 2017
1 parent d10d4bb commit 137885c
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 14 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ utils/**/*
coverage/**/*
modules/dynamic/dynamicData.js
modules/static/staticData.js
node_modules
benchmark
dist
4 changes: 1 addition & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"parser": "babel-eslint",
"env": {
"browser": true,
"node": true,
"mocha": true
"node": true
},
"plugins": [
"flowtype"
Expand All @@ -30,7 +29,6 @@
"no-restricted-syntax": [ 1 ],
"no-continue": [ 1 ],
"no-prototype-builtins": [ 1 ],
"max-len": [ 2, 100 ],
"no-mixed-operators": [ 1 ],
"no-lonely-if": [ 1 ],
"no-bitwise": [ 0 ],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"docs": "gitbook install && gitbook build && gh-pages -d _book",
"flow": "flow",
"generate": "babel-node generateDefaultData",
"lint": "eslint modules",
"lint": "eslint .",
"release": "npm run build && npm publish && npm run docs",
"test": "istanbul cover node_modules/mocha/bin/_mocha -- --opts test/_setup/mocha.opts"
},
Expand Down
1 change: 0 additions & 1 deletion plugins/flexboxOld.js

This file was deleted.

1 change: 0 additions & 1 deletion prefixProps.js

This file was deleted.

10 changes: 10 additions & 0 deletions test/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"env": {
"mocha": true
},
"globals": {
"expect": false,
"prefixAll": false,
"Prefixer": false
}
}
14 changes: 8 additions & 6 deletions test/dynamic/createPrefixer-test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint camelcase: 1 */
const MSIE9 = 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 7.1; Trident/5.0)'
const MSIE10 = 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)'
const MSEdge12 = 'Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10136'
Expand All @@ -13,7 +14,6 @@ const Chrome49 = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML,
const SeaMonkey = 'Mozilla/5.0 (Windows NT 5.2; RW; rv:7.0a1) Gecko/20091211 SeaMonkey/9.23a1pre'
const Chromium = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/50.0.2661.102 Chrome/50.0.2661.102 Safari/537.36'
const PhantomJS = 'Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/538.1 (KHTML, like Gecko) PhantomJS/2.0.0 Safari/538.1'
const Samsung = 'Mozilla/5.0 (Linux; Android 6.0.1; SAMSUNG SM-G900F Build/MMB29M) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/4.0 Chrome/44.0.2403.133 Mobile Safari/537.36'

describe('Dynamic Prefixer', () => {
describe('Prefixing a property', () => {
Expand All @@ -29,7 +29,7 @@ describe('Dynamic Prefixer', () => {
expect(new Prefixer({ userAgent: Chrome45 }).prefix(input)).to.eql(prefixed)
})
it('should not break if the value is undefined or false', () => {
expect(new Prefixer({ userAgent: Chrome14 }).prefix({ width: undefined })).to.not.throw
expect(new Prefixer({ userAgent: Chrome14 }).prefix({ width: undefined })).to.not.throw()
})
it('should also resolve nested objects', () => {
const input = {
Expand Down Expand Up @@ -371,8 +371,10 @@ describe('Dynamic Prefixer', () => {
expect(new Prefixer({ userAgent: MSIE10 }).prefix({ display: 'block' })).to.eql({ display: 'block' })
})
it('should not throw if display is null or undefined', () => {
expect(new Prefixer({ userAgent: Chrome45 }).prefix({ display: null })).to.eql({ display: null })
expect(new Prefixer({ userAgent: Chrome45 }).prefix({ display: undefined })).to.eql({ display: undefined })
expect(new Prefixer({ userAgent: Chrome45 }).prefix({ display: null }))
.to.eql({ display: null })
expect(new Prefixer({ userAgent: Chrome45 }).prefix({ display: undefined }))
.to.eql({ display: undefined })
})
})
describe('Using Prefixer.prefixAll', () => {
Expand All @@ -396,7 +398,7 @@ describe('Dynamic Prefixer', () => {
'userSelect'
]
expect(Object.keys(Prefixer.prefixAll(input))).to.eql(order)
});
})

it('does not mess up the order of other styles', () => {
const input = {
Expand All @@ -413,6 +415,6 @@ describe('Dynamic Prefixer', () => {
'border'
]
expect(Object.keys(Prefixer.prefixAll(input))).to.eql(order)
});
})
})
})
4 changes: 2 additions & 2 deletions test/static/createPrefixer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('Static Prefixer', () => {
'userSelect'
]
expect(Object.keys(prefixAll(input))).to.eql(order)
});
})

it('does not mess up the order of other styles', () => {
const input = {
Expand All @@ -47,7 +47,7 @@ describe('Static Prefixer', () => {
'border'
]
expect(Object.keys(prefixAll(input))).to.eql(order)
});
})

it('should use dash-cased alternative values in array', () => {
const input = { marginLeft: 'calc(30deg)' }
Expand Down

0 comments on commit 137885c

Please sign in to comment.