diff --git a/.eslintrc b/.eslintrc index 9ae4c93237..2540658dc5 100644 --- a/.eslintrc +++ b/.eslintrc @@ -25,16 +25,10 @@ "no-param-reassign": 0, "no-this-before-super": 2, "no-undef": 2, - "no-unused-vars": [2, { "vars": "all", "args": "none" }], "babel/object-shorthand": 2, "react/jsx-boolean-value": [2, "never"], "react/jsx-no-duplicate-props": 2, "react/prop-types": [2, { "ignore": [ "children", "className", "style" ] }], - "react/sort-comp": 0, - "space-after-keywords": 0, - "space-before-blocks": 0, - "space-before-function-paren": 0, - "spaced-comment": 0, - "vars-on-top": 0 + "react/sort-comp": 0 } } diff --git a/docs/build.js b/docs/build.js index 0b1b973cbe..975f0a6acc 100644 --- a/docs/build.js +++ b/docs/build.js @@ -25,7 +25,7 @@ const readmeDest = path.join(docsBuilt, 'README.md'); * @internal */ function generateHTML(fileName, propData) { - return new Promise((resolve, reject) => { + return new Promise( resolve => { const urlSlug = fileName === 'index.html' ? '/' : `/${fileName}`; Router.run(routes, urlSlug, Handler => { diff --git a/docs/examples/Collapse.js b/docs/examples/Collapse.js index 92b95685d4..f38c4945b8 100644 --- a/docs/examples/Collapse.js +++ b/docs/examples/Collapse.js @@ -1,11 +1,11 @@ class Example extends React.Component { - constructor(...args){ + constructor(...args) { super(...args); this.state = {}; } - render(){ + render() { return (
diff --git a/docs/examples/ModalDefaultSizing.js b/docs/examples/ModalDefaultSizing.js index 7f1435757d..fdd51beb6a 100644 --- a/docs/examples/ModalDefaultSizing.js +++ b/docs/examples/ModalDefaultSizing.js @@ -53,12 +53,12 @@ const MyLargeModal = React.createClass({ }); const App = React.createClass({ - getInitialState(){ + getInitialState() { return { smShow: false, lgShow: false }; }, - render(){ - let smClose = e => this.setState({ smShow: false }); - let lgClose = e => this.setState({ lgShow: false }); + render() { + let smClose = () => this.setState({ smShow: false }); + let lgClose = () => this.setState({ lgShow: false }); return ( diff --git a/docs/examples/NavBasic.js b/docs/examples/NavBasic.js index 075fe4f934..068618d2f8 100644 --- a/docs/examples/NavBasic.js +++ b/docs/examples/NavBasic.js @@ -1,4 +1,4 @@ -function handleSelect (selectedKey) { +function handleSelect(selectedKey) { alert('selected ' + selectedKey); } diff --git a/docs/examples/NavStacked.js b/docs/examples/NavStacked.js index 8680f9384b..65e3a75d16 100644 --- a/docs/examples/NavStacked.js +++ b/docs/examples/NavStacked.js @@ -1,4 +1,4 @@ -function handleSelect (selectedKey) { +function handleSelect(selectedKey) { alert('selected ' + selectedKey); } diff --git a/docs/examples/Overlay.js b/docs/examples/Overlay.js index 7a98967772..2ddb066285 100644 --- a/docs/examples/Overlay.js +++ b/docs/examples/Overlay.js @@ -1,20 +1,20 @@ const Example = React.createClass({ - getInitialState(){ + getInitialState() { return { show: true }; }, - toggle(){ + toggle() { this.setState({ show: !this.state.show }); }, - render(){ + render() { const tooltip = Tooltip overload!; const sharedProps = { show: this.state.show, container: this, - target: props => React.findDOMNode(this.refs.target) + target: () => React.findDOMNode(this.refs.target) }; return ( diff --git a/docs/examples/OverlayCustom.js b/docs/examples/OverlayCustom.js index c5c002e089..e2336e5183 100644 --- a/docs/examples/OverlayCustom.js +++ b/docs/examples/OverlayCustom.js @@ -1,14 +1,14 @@ const Example = React.createClass({ - getInitialState(){ + getInitialState() { return { show: true }; }, - toggle(){ + toggle() { this.setState({ show: !this.state.show }); }, - render(){ + render() { const style = { position: 'absolute', backgroundColor: '#EEE', @@ -31,7 +31,7 @@ const Example = React.createClass({ onHide={() => this.setState({ show: false })} placement="right" container={this} - target={ props => React.findDOMNode(this.refs.target)} + target={() => React.findDOMNode(this.refs.target)} >
Holy guacamole! Check this info. diff --git a/docs/examples/PaginationBasic.js b/docs/examples/PaginationBasic.js index fb161ff104..a90124998c 100644 --- a/docs/examples/PaginationBasic.js +++ b/docs/examples/PaginationBasic.js @@ -5,7 +5,7 @@ const PaginationBasic = React.createClass({ }; }, - handleSelect(event, selectedEvent){ + handleSelect(event, selectedEvent) { this.setState({ activePage: selectedEvent.eventKey }); diff --git a/docs/examples/PanelCollapsible.js b/docs/examples/PanelCollapsible.js index 51d41a1fee..07f1f43dc0 100644 --- a/docs/examples/PanelCollapsible.js +++ b/docs/examples/PanelCollapsible.js @@ -1,12 +1,12 @@ class Example extends React.Component { - constructor(...args){ + constructor(...args) { super(...args); this.state = { open: true }; } - render(){ + render() { return (
{}} + onToggle={() => {}} title='Prop open control' id='test-id' > diff --git a/test/FadeMixinSpec.js b/test/FadeMixinSpec.js index 7e6086dd0f..471efc671d 100644 --- a/test/FadeMixinSpec.js +++ b/test/FadeMixinSpec.js @@ -20,7 +20,7 @@ describe('FadeMixin', function () { }); afterEach(()=> { - if (console.warn.calledWithMatch('FadeMixin is deprecated')){ + if (console.warn.calledWithMatch('FadeMixin is deprecated')) { console.warn.reset(); } }); @@ -31,7 +31,7 @@ describe('FadeMixin', function () { let child = ReactTestUtils.findRenderedDOMComponentWithTag(instance, 'span'); - setTimeout(function(){ + setTimeout(function() { assert.ok(React.findDOMNode(instance).className.match(/\bin\b/)); assert.ok(React.findDOMNode(instance).className.match(/\bfade\b/)); assert.ok(React.findDOMNode(child).className.match(/\bin\b/)); @@ -43,7 +43,7 @@ describe('FadeMixin', function () { it('Should remove the in class for all elements', function (done) { let instance = ReactTestUtils.renderIntoDocument(); - setTimeout(function(){ + setTimeout(function() { instance.componentWillUnmount(); let element = instance._fadeOutEl.children[0]; @@ -52,7 +52,7 @@ describe('FadeMixin', function () { assert.ok(element.className.match(/\bin\b/)); assert.ok(child.className.match(/\bin\b/)); - setTimeout(function(){ + setTimeout(function() { assert.ok(!element.className.match(/\bin\b/)); assert.ok(element.className.match(/\bfade\b/)); assert.ok(!child.className.match(/\bin\b/)); diff --git a/test/FadeSpec.js b/test/FadeSpec.js index 0f85fdfd40..c6217c3f6c 100644 --- a/test/FadeSpec.js +++ b/test/FadeSpec.js @@ -6,10 +6,10 @@ describe('Fade', function () { let Component, instance; - beforeEach(function(){ + beforeEach(function() { Component = React.createClass({ - render(){ + render() { let { children, ...props } = this.props; return ( @@ -52,7 +52,7 @@ describe('Fade', function () { Panel content ); - function onEntering(){ + function onEntering() { assert.equal(React.findDOMNode(instance).className, 'fade in'); done(); } @@ -68,7 +68,7 @@ describe('Fade', function () { Panel content ); - function onExiting(){ + function onExiting() { assert.equal(React.findDOMNode(instance).className, 'fade'); done(); } diff --git a/test/MenuItemSpec.js b/test/MenuItemSpec.js index f1c5c0f223..4dca3af484 100644 --- a/test/MenuItemSpec.js +++ b/test/MenuItemSpec.js @@ -80,7 +80,7 @@ describe('MenuItem', function() { }); it('does not fire onSelect when divider is clicked', function() { - const handleSelect = (event, selectedEvent) => { + const handleSelect = () => { throw new Error('Should not invoke onSelect with divider flag applied'); }; const instance = ReactTestUtils.renderIntoDocument( @@ -93,7 +93,7 @@ describe('MenuItem', function() { }); it('does not fire onSelect when header is clicked', function() { - const handleSelect = (event, selectedEvent) => { + const handleSelect = () => { throw new Error('Should not invoke onSelect with divider flag applied'); }; const instance = ReactTestUtils.renderIntoDocument( @@ -106,7 +106,7 @@ describe('MenuItem', function() { }); it('disabled link', function() { - const handleSelect = (event, selectEvent) => { + const handleSelect = () => { throw new Error('Should not invoke onSelect event'); }; const instance = ReactTestUtils.renderIntoDocument( diff --git a/test/ModalSpec.js b/test/ModalSpec.js index 9d5ceb0178..aab9fd9db1 100644 --- a/test/ModalSpec.js +++ b/test/ModalSpec.js @@ -6,7 +6,7 @@ import { render, shouldWarn } from './helpers'; describe('Modal', function () { let mountPoint; - beforeEach(()=>{ + beforeEach(() => { mountPoint = document.createElement('div'); document.body.appendChild(mountPoint); }); @@ -65,7 +65,7 @@ describe('Modal', function () { ReactTestUtils.Simulate.click(backdrop); - setTimeout(function(){ + setTimeout(function() { assert.equal(React.findDOMNode(instance).className.length, 0); done(); }, 0); @@ -203,7 +203,7 @@ describe('Modal', function () { let noOp = function () {}; class CustomDialog { - render(){ return
; } + render() { return
; } } let instance = render( @@ -221,7 +221,7 @@ describe('Modal', function () { let instance = render( {}} + onHide={() => {}} onExit={increment} onExiting={increment} onExited={()=> { @@ -260,7 +260,7 @@ describe('Modal', function () { describe('Focused state', function () { let focusableContainer = null; - beforeEach(()=>{ + beforeEach(() => { focusableContainer = document.createElement('div'); focusableContainer.tabIndex = 0; document.body.appendChild(focusableContainer); @@ -277,7 +277,7 @@ describe('Modal', function () { document.activeElement.should.equal(focusableContainer); let instance = render( - {}} animation={false}> + {}} animation={false}> Message , focusableContainer); @@ -292,7 +292,7 @@ describe('Modal', function () { it('Should not focus on the Modal when autoFocus is false', function () { render( - {}} animation={false}> + {}} animation={false}> Message , focusableContainer); @@ -305,7 +305,7 @@ describe('Modal', function () { document.activeElement.should.equal(focusableContainer); render( - {}} animation={false}> + {}} animation={false}> , focusableContainer); diff --git a/test/NavDropdownSpec.js b/test/NavDropdownSpec.js index e70ec453cc..b30bdbdd87 100644 --- a/test/NavDropdownSpec.js +++ b/test/NavDropdownSpec.js @@ -42,7 +42,7 @@ describe('NavDropdown', function() { {}} + onToggle={() => {}} title='Prop open control' id='test-id'> Item 1 diff --git a/test/NavItemSpec.js b/test/NavItemSpec.js index a7f6ffb6a1..6e665be08c 100644 --- a/test/NavItemSpec.js +++ b/test/NavItemSpec.js @@ -107,7 +107,7 @@ describe('NavItem', function () { assert.equal(linkElement.outerHTML.match('role="button"'), null); }); - describe('Web Accessibility', function(){ + describe('Web Accessibility', function() { it('Should pass aria-controls to the link', function () { let instance = ReactTestUtils.renderIntoDocument( diff --git a/test/NavSpec.js b/test/NavSpec.js index a86f47e0dc..d1d94cb03f 100644 --- a/test/NavSpec.js +++ b/test/NavSpec.js @@ -178,7 +178,7 @@ describe('Nav', function () { }); - describe('Web Accessibility', function(){ + describe('Web Accessibility', function() { it('Should have tablist and tab roles', function () { let instance = ReactTestUtils.renderIntoDocument( diff --git a/test/OverlayDeprecationSpec.js b/test/OverlayDeprecationSpec.js index c8eb2f03f7..abcbdc998b 100644 --- a/test/OverlayDeprecationSpec.js +++ b/test/OverlayDeprecationSpec.js @@ -6,21 +6,21 @@ import Portal from '../src/Portal'; import { shouldWarn } from './helpers'; -describe('Components moved to react-overlays', ()=>{ +describe('Components moved to react-overlays', () => { - it('should warn about Position', ()=>{ + it('should warn about Position', () => { ReactTestUtils.renderIntoDocument(
); shouldWarn(/Position component is deprecated/); }); - it('should warn about Transition', ()=>{ + it('should warn about Transition', () => { ReactTestUtils.renderIntoDocument(
); shouldWarn(/Transition component is deprecated/); }); - it('should warn about Portal', ()=>{ + it('should warn about Portal', () => { ReactTestUtils.renderIntoDocument(
); shouldWarn(/Portal component is deprecated/); diff --git a/test/OverlayTriggerSpec.js b/test/OverlayTriggerSpec.js index c50e73dc38..960d6322a0 100644 --- a/test/OverlayTriggerSpec.js +++ b/test/OverlayTriggerSpec.js @@ -80,7 +80,7 @@ describe('OverlayTrigger', function() { test
} - onHide={()=>{}} + onHide={() => {}} onExit={increment} onExiting={increment} onExited={()=> { diff --git a/test/PanelSpec.js b/test/PanelSpec.js index 0c9cfc09f1..ff1b9daf30 100644 --- a/test/PanelSpec.js +++ b/test/PanelSpec.js @@ -185,7 +185,7 @@ describe('Panel', function () { assert.notOk(children[0].className.match(/\bpanel-body\b/)); }); - describe('Web Accessibility', function(){ + describe('Web Accessibility', function() { it('Should be aria-expanded=true', function () { let instance = ReactTestUtils.renderIntoDocument( diff --git a/test/SafeAnchorSpec.js b/test/SafeAnchorSpec.js index 2271c2fbbe..2b5bf8487f 100644 --- a/test/SafeAnchorSpec.js +++ b/test/SafeAnchorSpec.js @@ -32,7 +32,7 @@ describe('SafeAnchor', function() { }); it('forwards onClick handler', function(done) { - const handleClick = (event) => { + const handleClick = () => { done(); }; const instance = ReactTestUtils.renderIntoDocument(); diff --git a/test/TabSpec.js b/test/TabSpec.js index 6babd9db32..a38279015a 100644 --- a/test/TabSpec.js +++ b/test/TabSpec.js @@ -17,7 +17,7 @@ describe('Tab', function () { assert.ok(ReactTestUtils.findRenderedDOMComponentWithClass(instance, 'active')); }); - describe('Web Accessibility', function(){ + describe('Web Accessibility', function() { it('Should have aria-hidden', function () { let instance = ReactTestUtils.renderIntoDocument( diff --git a/test/TabsSpec.js b/test/TabsSpec.js index ed7f875c84..5745fb9bdc 100644 --- a/test/TabsSpec.js +++ b/test/TabsSpec.js @@ -390,7 +390,7 @@ describe('Tabs', function () { describe('animation', function () { let mountPoint; - beforeEach(()=>{ + beforeEach(() => { mountPoint = document.createElement('div'); document.body.appendChild(mountPoint); }); @@ -429,9 +429,9 @@ describe('Tabs', function () { checkTabRemovingWithAnimation(false); }); - describe('Web Accessibility', function(){ + describe('Web Accessibility', function() { let instance; - beforeEach(function(){ + beforeEach(function() { instance = ReactTestUtils.renderIntoDocument( Tab 1 content diff --git a/test/helpers.js b/test/helpers.js index 9df659ecae..81611a55d8 100644 --- a/test/helpers.js +++ b/test/helpers.js @@ -14,7 +14,7 @@ export function shouldWarn(about) { * @param {HTMLElement?} mountPoint Optional mount node, when empty it uses an unattached div like `renderIntoDocument()` * @return {ComponentInstance} The instance, with a new method `renderWithProps` which will return a new instance with updated props */ -export function render(element, mountPoint){ +export function render(element, mountPoint) { let mount = mountPoint || document.createElement('div'); let instance = React.render(element, mount); diff --git a/test/utils/CustomPropTypesSpec.js b/test/utils/CustomPropTypesSpec.js index 92e542b366..643f02ffb9 100644 --- a/test/utils/CustomPropTypesSpec.js +++ b/test/utils/CustomPropTypesSpec.js @@ -48,7 +48,7 @@ describe('CustomPropTypes', function() { it('Should validate OK with elementType values', function() { assert.isUndefined(validate('span')); - assert.isUndefined(validate(function(){})); + assert.isUndefined(validate(function() {})); }); it('Should return error with not a string or function values', function() { diff --git a/tools/buildBabel.js b/tools/buildBabel.js index 54ea1bba7a..d19a0e4497 100644 --- a/tools/buildBabel.js +++ b/tools/buildBabel.js @@ -13,7 +13,7 @@ export function buildContent(content, filename, destination, babelOptions = {}) export function buildFile(filename, destination, babelOptions = {}) { const content = fs.readFileSync(filename, {encoding: 'utf8'}); // We only have .js files that we need to build - if(path.extname(filename) === '.js') { + if (path.extname(filename) === '.js') { const outputPath = path.join(destination, path.basename(filename)); // console.log('%s => %s', filename, outputPath); buildContent(content, filename, outputPath, babelOptions); @@ -23,9 +23,9 @@ export function buildFile(filename, destination, babelOptions = {}) { export function buildFolder(folderPath, destination, babelOptions = {}, firstFolder = true) { let stats = fs.statSync(folderPath); - if(stats.isFile()) { + if (stats.isFile()) { buildFile(folderPath, destination, babelOptions); - } else if(stats.isDirectory()) { + } else if (stats.isDirectory()) { let outputPath = firstFolder ? destination : path.join(destination, path.basename(folderPath)); let files = fs.readdirSync(folderPath).map(file => path.join(folderPath, file)); files.forEach(filename => buildFolder(filename, outputPath, babelOptions, false)); diff --git a/tools/promisify.js b/tools/promisify.js index e3098ab499..5e2d123036 100644 --- a/tools/promisify.js +++ b/tools/promisify.js @@ -1,7 +1,7 @@ -export default function promisify(fn){ - return function (...args){ - return new Promise(function(resolve, reject){ - function finish(err, result){ +export default function promisify(fn) { + return function(...args) { + return new Promise(function(resolve, reject) { + function finish(err, result) { if (err) { return reject(err); } diff --git a/tools/public-components.js b/tools/public-components.js index 67fc67f0c7..c54836e550 100644 --- a/tools/public-components.js +++ b/tools/public-components.js @@ -2,7 +2,7 @@ import React from 'react'; import * as index from '../src/index'; let components = []; -Object.keys(index).forEach(function (item) { +Object.keys(index).forEach(function(item) { if (index[item] instanceof React.Component.constructor) { components.push(item); } diff --git a/webpack.config.js b/webpack.config.js index 9d7bf6d0f3..faf8e55ad8 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,4 +1,4 @@ -/* eslint no-var: 0 */ +/* eslint no-var: 0, vars-on-top: 0 */ require('babel/register'); var config = require('./webpack/webpack.config'); module.exports = config; diff --git a/webpack.docs.js b/webpack.docs.js index 80f0eec6fe..dc6139decf 100644 --- a/webpack.docs.js +++ b/webpack.docs.js @@ -1,4 +1,4 @@ -/* eslint no-var: 0 */ +/* eslint no-var: 0, vars-on-top: 0 */ require('babel/register'); var config = require('./webpack/docs.config'); module.exports = config;