From 67b849f3a6f57f9094da0630f555f134459b5973 Mon Sep 17 00:00:00 2001 From: Stuart Colville Date: Mon, 3 Jul 2017 10:41:36 +0100 Subject: [PATCH 1/3] Use amo eslint config --- .eslintrc | 84 +------------------ package.json | 6 +- src/amo/components/Addon/index.js | 8 +- src/amo/components/AddonMeta.js | 6 +- src/amo/components/AddonReview.js | 3 +- src/amo/components/Categories.js | 5 +- src/amo/components/CategoriesHeader/index.js | 8 +- src/amo/components/FeaturedAddons/index.js | 7 +- src/amo/components/Footer/index.js | 3 +- src/amo/components/LandingPage/index.js | 20 +++-- src/amo/components/LanguagePicker.js | 11 ++- src/amo/components/ScreenShots.js | 11 ++- src/amo/components/Search/index.js | 14 +++- src/amo/components/SearchForm.js | 26 ++++-- .../components/SearchSort/SearchSortLink.js | 5 +- src/amo/components/SearchSort/index.js | 16 ++-- src/amo/components/SectionLinks/index.js | 6 +- src/core/actions/installations.js | 1 - src/core/components/InstallButton/index.js | 3 +- src/core/components/InstallSwitch/index.js | 11 ++- src/core/components/Paginate/index.js | 9 +- src/core/containers/InfoDialog/index.js | 6 +- src/core/containers/ServerHtml.js | 11 ++- src/core/installAddon.js | 1 - src/core/utils.js | 2 +- src/disco/components/Addon.js | 6 +- src/disco/containers/DiscoPane.js | 21 +++-- src/ui/components/Card/index.js | 3 +- src/ui/components/ErrorList/index.js | 3 +- src/ui/components/Overlay/index.js | 6 +- src/ui/components/Rating/index.js | 3 +- src/ui/components/SearchInput/index.js | 16 +++- src/ui/components/ShowMoreCard/index.js | 11 ++- src/ui/components/Switch/index.js | 8 +- tests/.eslintrc | 7 +- tests/unit/amo/components/TestAddon.js | 1 - .../unit/amo/components/TestAddonMoreInfo.js | 3 +- tests/unit/amo/components/TestLandingPage.js | 3 +- tests/unit/amo/components/TestSearchForm.js | 10 ++- tests/unit/core/TestInstallAddon.js | 10 ++- tests/unit/core/components/TestPaginate.js | 2 +- tests/unit/disco/components/TestAddon.js | 9 +- tests/unit/ui/TestSearchInput.js | 2 +- yarn.lock | 59 +++++-------- 44 files changed, 225 insertions(+), 241 deletions(-) diff --git a/.eslintrc b/.eslintrc index abecd5c4377..d63d48d8487 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,8 +1,5 @@ { - "env": { - "mocha": true, - }, - "extends": "airbnb", + "extends": "amo", "globals": { "CLIENT_CONFIG": true, "dedent": true, @@ -13,85 +10,6 @@ "jest" ], "rules": { - "arrow-body-style": "off", - "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", - "comma-dangle": ['error', { - arrays: 'always-multiline', - objects: 'always-multiline', - imports: 'always-multiline', - exports: 'always-multiline', - functions: 'ignore', - }], - // This makes sure imported modules exist. - "import/no-unresolved": ["error"], - // This makes sure imported names exist. - "import/named": ["error"], - // This will catch accidental default imports when no default is defined. - "import/default": ["error"], - // This makes sure `*' imports are dereferenced to real exports. - "import/namespace": ["error"], - // This catches any export mistakes. - "import/export": ["error"], - // This catches default names that conflict with actual exported names. - // For example, this was probably a typo: - // import foo from 'bar'; - // that should be corrected as: - // import { foo } from 'bar'; - "import/no-named-as-default": ["error"], - // This catches possible typos like trying to access a real export on a - // default import. - "import/no-named-as-default-member": ["error"], - // This prevents exporting a mutable variable. - "import/no-mutable-exports": ["error"], - // This makes sure package.json defines dev vs. prod dependencies correctly. - "import/no-extraneous-dependencies": ["error", { - // The following are not allowed to be imported. See .eslintrc in other - // directories (like ./test) for where this gets overidden. - "devDependencies": false, "optionalDependencies": false, "peerDependencies": false - }], - // This ensures imports are at the top of the file. - "import/imports-first": ["error"], - // This reports when you accidentally import/export an object twice. - "import/no-duplicates": ["error"], - // This ensures import statements never provide a file extension in the path. - "import/extensions": ["error", "never"], - // This ensures imports are organized by type and that groups are separated - // by a new line. - "import/order": ["error", { - "groups": [ - "builtin", "external", "internal", ["parent", "sibling"], "index" - ], - "newlines-between": "always" - }], - "import/prefer-default-export": ["off"], - // This ensures a new line after all import statements. - "import/newline-after-import": ["error"], - "jest/no-disabled-tests": "warn", - "jest/no-focused-tests": "error", - "jest/no-identical-title": "error", - "jest/valid-expect": "error", - "jsx-a11y/no-static-element-interactions": "off", - "no-console": "error", - // We use import/no-duplicates instead because it supports Flow types. - "no-duplicate-imports": "off", - "no-plusplus": "off", - "no-underscore-dangle": "off", - "space-before-function-paren": ["error", "never"], - // The airbnb default of this rule mainly encourages `shape` over `object` - // but there are too many bugs in the linter to use `shape` accurately. - 'react/forbid-prop-types': "off", - "react/prefer-stateless-function": "off", - "react/jsx-indent-props": "off", - "react/jsx-closing-bracket-location": "off", - "react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }], - "react/jsx-first-prop-new-line": "off", - "react/jsx-key": "error", - "react/no-string-refs": "error", // FIXME: Deprecate use of findDOMNode https://github.com/mozilla/addons-frontend/issues/968 "react/no-find-dom-node": "off", }, diff --git a/package.json b/package.json index b4f1cb9f860..d3e1e97392e 100644 --- a/package.json +++ b/package.json @@ -115,7 +115,6 @@ "deep-eql": "2.0.2", "dompurify": "0.9.0", "es6-error": "4.0.2", - "eslint-plugin-jest": "20.0.3", "express": "4.15.2", "extract-text-webpack-plugin": "2.1.0", "fastclick": "1.0.6", @@ -184,11 +183,8 @@ "deepcopy": "^0.6.3", "enzyme": "^2.8.2", "eslint": "^3.19.0", - "eslint-config-airbnb": "^13.0.0", - "eslint-plugin-import": "^2.2.0", - "eslint-plugin-jsx-a11y": "^2.2.3", + "eslint-config-amo": "^0.0.4", "eslint-plugin-promise": "^3.5.0", - "eslint-plugin-react": "^6.10.3", "fetch-mock": "^5.10.0", "file-loader": "^0.11.1", "flow-bin": "^0.46.0", diff --git a/src/amo/components/Addon/index.js b/src/amo/components/Addon/index.js index f1cf350c7ec..58ddfaa6169 100644 --- a/src/amo/components/Addon/index.js +++ b/src/amo/components/Addon/index.js @@ -67,6 +67,7 @@ export class AddonBase extends React.Component { location: PropTypes.object.isRequired, params: PropTypes.object.isRequired, resetThemePreview: PropTypes.func.isRequired, + // eslint-disable-next-line react/require-default-props themePreviewNode: PropTypes.element, installStatus: PropTypes.string.isRequired, toggleThemePreview: PropTypes.func.isRequired, @@ -135,6 +136,7 @@ export class AddonBase extends React.Component { id="Addon-theme-header" data-browsertheme={getBrowserThemeData()} onClick={this.onClick} + role="presentation" > {installStatus !== ENABLED ? ( - + header={html.featuredHeader} + /> - + footerText={html.highlyRatedFooterText} + header={html.highlyRatedHeader} + /> + footerText={html.popularFooterText} + header={html.popularHeader} + /> ); } diff --git a/src/amo/components/LanguagePicker.js b/src/amo/components/LanguagePicker.js index 1a6b127e0fe..bb63c63f24d 100644 --- a/src/amo/components/LanguagePicker.js +++ b/src/amo/components/LanguagePicker.js @@ -49,10 +49,13 @@ export class LanguagePickerBase extends React.Component {

{i18n.gettext('Browse in your language')}

- { this.selector = ref; }} + onChange={this.onChange}> + {Object.keys(languages).map((locale) => ( + ))} diff --git a/src/amo/components/ScreenShots.js b/src/amo/components/ScreenShots.js index b969eb4c185..ff7647d406c 100644 --- a/src/amo/components/ScreenShots.js +++ b/src/amo/components/ScreenShots.js @@ -1,5 +1,5 @@ -/* global document, requestAnimationFrame, window - * eslint-disable jsx-a11y/href-no-hash */ +/* global document, window */ +/* eslint-disable jsx-a11y/href-no-hash */ import React from 'react'; import PropTypes from 'prop-types'; @@ -66,8 +66,11 @@ export default class ScreenShots extends React.Component {
{ this.viewport = el; }}> + className="ScreenShots-list" + close={this.onClose} + items={formatPreviews(previews)} + options={PHOTO_SWIPE_OPTIONS} + thumbnailContent={thumbnailContent} />
); diff --git a/src/amo/components/Search/index.js b/src/amo/components/Search/index.js index 764689b2e71..08acaadd7e7 100644 --- a/src/amo/components/Search/index.js +++ b/src/amo/components/Search/index.js @@ -70,8 +70,11 @@ export class SearchBase extends React.Component { const queryParams = this.props.queryParams || convertFiltersToQueryParams(filters); const paginator = count > 0 && hasSearchParams ? ( - + ) : []; const searchSort = enableSearchSort && hasSearchParams && results.length ? ( @@ -81,8 +84,11 @@ export class SearchBase extends React.Component {
{searchSort} - {paginator}
diff --git a/src/amo/components/SearchForm.js b/src/amo/components/SearchForm.js index 671b48d1aff..f1bbe6f42fb 100644 --- a/src/amo/components/SearchForm.js +++ b/src/amo/components/SearchForm.js @@ -57,19 +57,29 @@ export class SearchFormBase extends React.Component { } return ( -
{ this.form = ref; }}> -
{ this.searchToggle = ref; }}> {i18n.gettext('Sort')}