Skip to content

Commit

Permalink
Fix up lint errors after applying new AirBnB rules
Browse files Browse the repository at this point in the history
  • Loading branch information
kumar303 committed Sep 9, 2016
1 parent b8eef5d commit 2c3054d
Show file tree
Hide file tree
Showing 26 changed files with 75 additions and 63 deletions.
9 changes: 8 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
"parser": "babel-eslint",
"rules": {
"arrow-parens": ["error", "always"],
// Beware about turning this rule back on. The rule encourages you to create
// static class methods on React components when they don't use `this`.
// However, it will not warn you if you access `this` in a static method
// accidentally (which would most likely be a mistake).
"class-methods-use-this": "off",
// This makes sure imported modules exist.
"import/no-unresolved": ["error"],
// This makes sure imported names exist.
Expand Down Expand Up @@ -56,13 +61,15 @@
}],
// This ensures a new line after all import statements.
"import/newline-after-import": ["error"],
"jsx-a11y/no-static-element-interactions": "off",
"no-plusplus": "off",
"no-underscore-dangle": "off",
"space-before-function-paren": ["error", "never"],
"react/prefer-stateless-function": "off",
"react/jsx-indent-props": "off",
"react/jsx-closing-bracket-location": "off",
"react/jsx-first-prop-new-line": "off",
// FIXME: Use funcs for refs https://github.com/mozilla/addons-frontend/issues/970
// FIXME: Use funcs for refs https://github.com/mozilla/addons-frontend/issues/970
"react/no-string-refs": "off",
// FIXME: Deprecate use of findDOMNode https://github.com/mozilla/addons-frontend/issues/968
"react/no-find-dom-node": "off",
Expand Down
2 changes: 1 addition & 1 deletion src/admin/components/JsonData/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import './style.scss';

export default class JsonData extends React.Component {
static propTypes = {
data: PropTypes.object.isRequired,
data: PropTypes.shape({}).isRequired,
}

constructor() {
Expand Down
6 changes: 3 additions & 3 deletions src/admin/components/SearchForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import 'admin/css/lib/buttons.scss';

export class SearchFormBase extends React.Component {
static propTypes = {
api: PropTypes.object.isRequired,
api: PropTypes.shape({}).isRequired,
loadAddon: PropTypes.func.isRequired,
pathname: PropTypes.string.isRequired,
query: PropTypes.string,
query: PropTypes.string.isRequired,
}
static contextTypes = {
router: PropTypes.object,
router: PropTypes.shape({}),
}

goToSearch(query) {
Expand Down
5 changes: 1 addition & 4 deletions src/admin/components/SearchPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ export default class SearchPage extends React.Component {
count: PropTypes.number,
loading: PropTypes.bool.isRequired,
page: PropTypes.number,
results: PropTypes.arrayOf(PropTypes.shape({
slug: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
})),
results: PropTypes.arrayOf(PropTypes.shape({})),
query: PropTypes.string,
}

Expand Down
2 changes: 1 addition & 1 deletion src/admin/components/SearchResult/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ ResultLink.propTypes = {

export default class SearchResult extends React.Component {
static propTypes = {
result: PropTypes.object.isRequired,
result: PropTypes.shape({}).isRequired,
}

render() {
Expand Down
6 changes: 2 additions & 4 deletions src/admin/containers/AddonPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ function siteLink(url, text) {

class AddonPage extends React.Component {
static propTypes = {
addon: PropTypes.shape({
name: PropTypes.string.isRequired,
slug: PropTypes.string.isRequired,
}),
addon: PropTypes.shape({}).isRequired,
// eslint-disable-next-line react/no-unused-prop-types
slug: PropTypes.string.isRequired,
}

Expand Down
9 changes: 3 additions & 6 deletions src/amo/components/AddonDetail.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable react/no-danger */
import React, { PropTypes } from 'react';

import AddonMeta from 'amo/components/AddonMeta';
Expand Down Expand Up @@ -29,12 +30,8 @@ export const allowedDescriptionTags = [

class AddonDetail extends React.Component {
static propTypes = {
i18n: PropTypes.object,
addon: PropTypes.shape({
name: PropTypes.string.isRequired,
authors: PropTypes.array.isRequired,
slug: PropTypes.string.isRequired,
}),
i18n: PropTypes.shape({}).isRequired,
addon: PropTypes.shape({}),
}

render() {
Expand Down
2 changes: 1 addition & 1 deletion src/amo/components/AddonMeta.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'amo/css/AddonMeta.scss';

export class AddonMetaBase extends React.Component {
static propTypes = {
i18n: PropTypes.object,
i18n: PropTypes.shape({}).isRequired,
}

render() {
Expand Down
2 changes: 1 addition & 1 deletion src/amo/components/LikeButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'amo/css/LikeButton.scss';

export class LikeButtonBase extends React.Component {
static propTypes = {
i18n: PropTypes.object,
i18n: PropTypes.shape({}).isRequired,
}

render() {
Expand Down
2 changes: 1 addition & 1 deletion src/amo/components/ScreenShots.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'amo/css/ScreenShots.scss';

export class ScreenShotsBase extends React.Component {
static propTypes = {
i18n: PropTypes.object,
i18n: PropTypes.shape({}).isRequired,
}

render() {
Expand Down
5 changes: 4 additions & 1 deletion src/amo/components/SearchBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import 'amo/css/SearchBox.scss';

export class SearchBoxBase extends React.Component {
static propTypes = {
i18n: PropTypes.object,
i18n: PropTypes.shape({
// TODO
// gettext: PropTypes.func,
}).isRequired,
}

render() {
Expand Down
5 changes: 4 additions & 1 deletion src/amo/containers/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import translate from 'core/i18n/translate';
export class AppBase extends React.Component {
static propTypes = {
children: PropTypes.node,
i18n: PropTypes.object.isRequired,
i18n: PropTypes.shape({
// TODO
// gettext: PropTypes.func,
}).isRequired,
}

render() {
Expand Down
5 changes: 1 addition & 4 deletions src/amo/containers/DetailPage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { PropTypes } from 'react';
import React from 'react';
import { compose } from 'redux';
import { asyncConnect } from 'redux-connect';
import { connect } from 'react-redux';
Expand All @@ -8,9 +8,6 @@ import translate from 'core/i18n/translate';
import { loadAddonIfNeeded } from 'core/utils';

export class DetailPageBase extends React.Component {
static propTypes = {
addon: PropTypes.object,
}

render() {
return (
Expand Down
7 changes: 5 additions & 2 deletions src/core/components/InstallButton/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ export class InstallButtonBase extends React.Component {
enable: PropTypes.func,
guid: PropTypes.string.isRequired,
handleChange: PropTypes.func,
i18n: PropTypes.object.isRequired,
i18n: PropTypes.shape({
// TODO:
// gettext: PropTypes.func,
// sprintf: PropTypes.func,
}).isRequired,
install: PropTypes.func.isRequired,
installTheme: PropTypes.func.isRequired,
installURL: PropTypes.string,
Expand All @@ -34,7 +38,6 @@ export class InstallButtonBase extends React.Component {
status: PropTypes.oneOf(validStates),
type: PropTypes.oneOf(validAddonTypes),
uninstall: PropTypes.func.isRequired,
url: PropTypes.string,
}

static defaultProps = {
Expand Down
2 changes: 1 addition & 1 deletion src/core/components/Paginate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default class Paginate extends React.Component {
count: PropTypes.number.isRequired,
currentPage: PropTypes.number.isRequired,
pathname: PropTypes.string.isRequired,
query: PropTypes.object,
query: PropTypes.shape({}),
perPage: PropTypes.number,
showPages: PropTypes.number,
}
Expand Down
11 changes: 8 additions & 3 deletions src/core/containers/HandleLogin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@ import { gettext as _ } from 'core/utils';

class HandleLogin extends React.Component {
static propTypes = {
api: PropTypes.object.isRequired,
auth: PropTypes.object.isRequired,
api: PropTypes.shape({}).isRequired,
auth: PropTypes.shape({}).isRequired,
loadData: PropTypes.func.isRequired,
location: PropTypes.object.isRequired,
location: PropTypes.shape({
query: PropTypes.shape({
code: PropTypes.string,
state: PropTypes.shape({}),
}),
}).isRequired,
}

static contextTypes = {
Expand Down
14 changes: 9 additions & 5 deletions src/core/containers/ServerHtml.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable react/no-danger */
import React, { Component, PropTypes } from 'react';
import ReactDOM from 'react-dom/server';
import serialize from 'serialize-javascript';
Expand All @@ -8,13 +9,16 @@ export default class ServerHtml extends Component {

static propTypes = {
appName: PropTypes.string.isRequired,
assets: PropTypes.object.isRequired,
component: PropTypes.object.isRequired,
assets: PropTypes.shape({
javascript: PropTypes.shape({}),
styles: PropTypes.shape({}),
}).isRequired,
component: PropTypes.element.isRequired,
htmlDir: PropTypes.string,
htmlLang: PropTypes.string,
includeSri: PropTypes.bool,
sriData: PropTypes.object,
store: PropTypes.object.isRequired,
includeSri: PropTypes.bool.isRequired,
sriData: PropTypes.shape({}).isRequired,
store: PropTypes.shape({}).isRequired,
trackingEnabled: PropTypes.bool,
};

Expand Down
4 changes: 2 additions & 2 deletions src/core/i18n/Provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import { Children, Component, PropTypes } from 'react';

export default class I18nProvider extends Component {
static propTypes = {
i18n: PropTypes.object.isRequired,
i18n: PropTypes.shape({}).isRequired,
children: PropTypes.element.isRequired,
}

static childContextTypes = {
i18n: PropTypes.object.isRequired,
i18n: PropTypes.shape({}).isRequired,
}

constructor(props, context) {
Expand Down
4 changes: 2 additions & 2 deletions src/core/i18n/translate.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ export default function translate(options = {}) {
Translate.WrappedComponent = WrappedComponent;

Translate.contextTypes = {
i18n: PropTypes.object.isRequired,
i18n: PropTypes.shape({}).isRequired,
};

Translate.childContextTypes = {
i18n: PropTypes.object.isRequired,
i18n: PropTypes.shape({}).isRequired,
};

Translate.displayName = `Translate[${getDisplayName(WrappedComponent)}]`;
Expand Down
11 changes: 3 additions & 8 deletions src/disco/components/Addon.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* global document, CustomEvent */
/* eslint-disable react/no-danger */

import classNames from 'classnames';
import { sprintf } from 'jed';
Expand Down Expand Up @@ -50,28 +51,22 @@ import 'disco/css/Addon.scss';

export class AddonBase extends React.Component {
static propTypes = {
accentcolor: PropTypes.string,
description: PropTypes.string,
editorialDescription: PropTypes.string.isRequired,
error: PropTypes.string,
footerURL: PropTypes.string,
guid: PropTypes.string.isRequired,
headerURL: PropTypes.string,
heading: PropTypes.string.isRequired,
i18n: PropTypes.object.isRequired,
i18n: PropTypes.shape({}).isRequired,
iconUrl: PropTypes.string,
id: PropTypes.string.isRequired,
installTheme: PropTypes.func.isRequired,
installURL: PropTypes.string,
needsRestart: PropTypes.bool.isRequired,
previewURL: PropTypes.string,
name: PropTypes.string.isRequired,
setCurrentStatus: PropTypes.func.isRequired,
status: PropTypes.oneOf(validInstallStates).isRequired,
textcolor: PropTypes.string,
themeAction: PropTypes.func,
type: PropTypes.oneOf(validAddonTypes).isRequired,
_tracking: PropTypes.object,
_tracking: PropTypes.shape({}),
}

static defaultProps = {
Expand Down
2 changes: 1 addition & 1 deletion src/disco/components/InfoDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class InfoDialogBase extends React.Component {
addonName: PropTypes.string.isRequired,
closeAction: PropTypes.func.isRequired,
imageURL: PropTypes.string.isRequired,
i18n: PropTypes.object.isRequired,
i18n: PropTypes.shape({}).isRequired,
}

handleClickOutside() {
Expand Down
2 changes: 1 addition & 1 deletion src/disco/containers/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import translate from 'core/i18n/translate';
export class AppBase extends React.Component {
static propTypes = {
children: PropTypes.node,
i18n: PropTypes.object.isRequired,
i18n: PropTypes.shape({}).isRequired,
}

render() {
Expand Down
15 changes: 9 additions & 6 deletions src/disco/containers/DiscoPane.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,18 @@ import videoWebm from 'disco/video/AddOns.webm';

export class DiscoPaneBase extends React.Component {
static propTypes = {
AddonComponent: PropTypes.func.isRequred,
AddonComponent: PropTypes.func,
handleGlobalEvent: PropTypes.func.isRequired,
i18n: PropTypes.object.isRequired,
infoDialogData: PropTypes.object,
mozAddonManager: PropTypes.object,
results: PropTypes.arrayOf(PropTypes.object),
i18n: PropTypes.shape({}).isRequired,
infoDialogData: PropTypes.shape({}).isRequired,
mozAddonManager: PropTypes.shape({}),
results: PropTypes.arrayOf(PropTypes.shape({
// TODO: eslint says this is unsed but it is used. Check on bug reports.
// guid: PropTypes.string.isRequired,
})),
showInfoDialog: PropTypes.boolean,
_addChangeListeners: PropTypes.func,
_tracking: PropTypes.object,
_tracking: PropTypes.shape({}),
}

static defaultProps = {
Expand Down
2 changes: 1 addition & 1 deletion tests/client/core/containers/TestHandleLogin.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('<HandleLogin />', () => {
class MyRouter extends React.Component {
static propTypes = {
children: React.PropTypes.node.isRequired,
router: React.PropTypes.object.isRequired,
router: React.PropTypes.shape({}).isRequired,
}

static childContextTypes = {
Expand Down
2 changes: 1 addition & 1 deletion tests/client/core/i18n/TestI18nProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class OuterComponent extends Component {

class InnerComponent extends Component {
static propTypes = {
i18n: PropTypes.object.isRequired,
i18n: PropTypes.shape({}).isRequired,
}
render() {
const { i18n } = this.props;
Expand Down
2 changes: 1 addition & 1 deletion tests/client/disco/components/TestInfoDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ describe('Clicking outside <InfoDialog />', () => {
<I18nProvider i18n={getFakeI18nInst()}>
<div>
{getInfoDialog()}
<div id="outside-component" onClick={(e) => e.stopPropagation()} />
<button id="outside-component" onClick={(e) => e.stopPropagation()} />
</div>
</I18nProvider>
);
Expand Down

0 comments on commit 2c3054d

Please sign in to comment.