Skip to content

Commit cd1f1e3

Browse files
committed
Enforce no semicolon and fix lint errors
- Added babelrc - Split npm test into npm run mocha and npm run lint
1 parent 8f1aff8 commit cd1f1e3

18 files changed

Lines changed: 70 additions & 65 deletions

.babelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"stage": 0
3+
}

.eslintrc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
{
22
"parser": "babel-eslint",
33
"env": {
4-
"es6": true
4+
"es6": true,
5+
"mocha": true,
6+
"node": true
57
},
68
"ecmaFeatures": {
79
"blockBindings": true,
@@ -14,6 +16,9 @@
1416
"max-len": 0,
1517
"semi": 0,
1618
"quotes": 0,
19+
"semi": [2, "never"],
20+
"no-unused-vars": 2,
21+
"no-undef": 2,
1722
"no-console": 0,
1823
"no-trailing-spaces": 0,
1924
"curly": 0,

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ lib
66
/middleware
77
/no-dom.js
88
/tests.js
9+
npm-debug.log

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
"description": "a chainable testing library for React",
55
"main": "legit-tests.js",
66
"scripts": {
7-
"compile": "babel src --stage 0 --out-dir .;",
8-
"prepublish": "babel src --stage 0 --out-dir .;",
9-
"test": "mocha --opts ./mocha.opts; eslint ./src/ ./tests/ --ext .jsx,.js --global require,exports:true"
7+
"compile": "babel src --out-dir .",
8+
"prepublish": "babel src --out-dir .",
9+
"lint": "eslint ./src/ ./tests/ --ext .jsx,.js --global require,exports:true",
10+
"mocha": "mocha --opts ./mocha.opts",
11+
"test": "npm run mocha; npm run lint"
1012
},
1113
"repository": {
1214
"type": "git",

src/dom.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ function propagateToGlobal (window) {
88
}
99
}
1010

11-
var jsdom = require('jsdom');
11+
var jsdom = require('jsdom')
1212

13-
var doc = jsdom.jsdom('<!doctype html><html><body></body></html>');
14-
var win = doc.defaultView;
13+
var doc = jsdom.jsdom('<!doctype html><html><body></body></html>')
14+
var win = doc.defaultView
1515

16-
global.document = doc;
17-
global.window = win;
16+
global.document = doc
17+
global.window = win
1818

19-
propagateToGlobal(win);
19+
propagateToGlobal(win)

src/legit-tests.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
1-
/* globals global */
21
import './dom'
3-
import Test from './tests'
4-
5-
export default Test
2+
export default from './tests'

src/middleware/simulate.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import React from 'react'
22
let { TestUtils } = React.addons
33

44
export default function simulate(data){
5-
let element = data.element ? this.helpers.elements[data.element] : this;
6-
element = Array.isArray(element) ? element[0] : element;
5+
let element = data.element ? this.helpers.elements[data.element] : this
6+
element = Array.isArray(element) ? element[0] : element
77
TestUtils.Simulate[data.method].call(this,
88
element,
99
data.options || null
10-
);
10+
)
1111
}

src/no-dom.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
import Test from './tests'
2-
3-
export default Test
1+
export default from './tests'

src/tests.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ function Test(component, config) {
2525
helpers: {},
2626
params() {
2727
const length = Object.keys(this.helpers).length
28-
if(this.helpers.elements && length === 1) {
28+
if (this.helpers.elements && length === 1) {
2929
return Object.assign({}, this, this.helpers.elements)
3030
}
3131
return this
3232
},
3333
element(select, callback) {
34-
if(!this.helpers) return
34+
if (!this.helpers) return
3535

3636
let element
37-
if(typeof select === 'string') {
37+
if (typeof select === 'string') {
3838
element = this.helpers.elements[select]
3939
callback.call(this, element)
4040
return this
@@ -55,7 +55,7 @@ function Test(component, config) {
5555
return this
5656
}
5757
})
58-
return this;
58+
return this
5959
},
6060
test(callback) {
6161
const param = this.params()
@@ -67,7 +67,7 @@ function Test(component, config) {
6767
callback.call(null, componentString)
6868
return this
6969
}
70-
};
70+
}
7171

7272
return testComponent.mixin({
7373
find: Find,

tests/components/component.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import React, { Component, PropTypes } from 'react'
2-
import TinyComponent from './tiny-component';
1+
import React, { Component } from 'react'
2+
import TinyComponent from './tiny-component'
33

44
export default class TestComponent extends Component {
55
constructor(props, context){

0 commit comments

Comments
 (0)