From fc86f25f9a0e8f5d75b31f3c21e612a47aacfb0a Mon Sep 17 00:00:00 2001 From: Eli White Date: Wed, 12 Jul 2017 13:48:49 -0700 Subject: [PATCH] Run eslint on all js files Reviewed By: zertosh Differential Revision: D5405047 fbshipit-source-id: 5ade9d8beb3688d8bb08a208709c0dbf1ec671b2 --- .eslintignore | 8 ++++++++ flow/Map.js | 2 -- flow/Position.js | 2 -- flow/Promise.js | 2 -- flow/Set.js | 2 -- flow/console.js | 2 -- flow/react.js | 2 -- jest/preprocessor.js | 3 +++ local-cli/runIOS/runIOS.js | 2 +- local-cli/wrong-react-native.js | 6 ++++-- package.json | 2 +- scripts/android-e2e-test.js | 13 +++++++++++-- website/publish-gh-pages.js | 1 + 13 files changed, 29 insertions(+), 18 deletions(-) diff --git a/.eslintignore b/.eslintignore index d67d67ef2..6d8d3470c 100644 --- a/.eslintignore +++ b/.eslintignore @@ -4,3 +4,11 @@ **/main.js Libraries/vendor/**/* Libraries/Renderer/* +website/node_modules +pr-inactivity-bookmarklet.js +question-bookmarklet.js +flow/ +website/core/metadata.js +website/core/metadata-blog.js +website/src/react-native/docs/ +website/src/react-native/blog/ diff --git a/flow/Map.js b/flow/Map.js index 99d0a0ab6..03ead0225 100644 --- a/flow/Map.js +++ b/flow/Map.js @@ -10,8 +10,6 @@ * @nolint */ -/* eslint-disable */ - // These annotations are copy/pasted from the built-in Flow definitions for // Native Map. diff --git a/flow/Position.js b/flow/Position.js index afe4a0227..d72ff6aa0 100644 --- a/flow/Position.js +++ b/flow/Position.js @@ -10,8 +10,6 @@ * @nolint */ -/* eslint-disable */ - declare class Position { coords: Coordinates, timestamp: number, diff --git a/flow/Promise.js b/flow/Promise.js index e59802e1b..4dfdcd7d5 100644 --- a/flow/Promise.js +++ b/flow/Promise.js @@ -10,8 +10,6 @@ * @nolint */ -/* eslint-disable */ - // These annotations are copy/pasted from the built-in Flow definitions for // Native Promises with some non-standard APIs added in declare class Promise<+R> { diff --git a/flow/Set.js b/flow/Set.js index 7293d3b08..0d88bf45a 100644 --- a/flow/Set.js +++ b/flow/Set.js @@ -10,8 +10,6 @@ * @nolint */ -/* eslint-disable */ - // These annotations are copy/pasted from the built-in Flow definitions for // Native Set. diff --git a/flow/console.js b/flow/console.js index c298bbe6d..bcc90713b 100644 --- a/flow/console.js +++ b/flow/console.js @@ -10,8 +10,6 @@ * @nolint */ -/* eslint-disable */ - declare module 'console' { declare function assert(value: any, ...message: any): void; declare function dir( diff --git a/flow/react.js b/flow/react.js index c771d4e54..30c41f9b2 100644 --- a/flow/react.js +++ b/flow/react.js @@ -10,8 +10,6 @@ * @nolint */ -/* eslint-disable */ - // Temporary patches for React.Component and React.Element. declare var ReactComponent: typeof React$Component; declare var ReactElement: typeof React$Element; diff --git a/jest/preprocessor.js b/jest/preprocessor.js index c32e0abea..50962fd12 100644 --- a/jest/preprocessor.js +++ b/jest/preprocessor.js @@ -8,6 +8,9 @@ * * @flow */ + +/* eslint-env node */ + 'use strict'; const babel = require('babel-core'); diff --git a/local-cli/runIOS/runIOS.js b/local-cli/runIOS/runIOS.js index 484b430b8..9a70bb405 100644 --- a/local-cli/runIOS/runIOS.js +++ b/local-cli/runIOS/runIOS.js @@ -161,7 +161,7 @@ function buildProject(xcodeProject, udid, scheme, configuration = 'Debug', launc if (productNameMatch && productNameMatch.length && productNameMatch.length > 1) { return resolve(productNameMatch[1]);//0 is the full match, 1 is the app name } - return buildProcess.error? reject(error) : resolve(); + return buildProcess.error? reject(buildProcess.error) : resolve(); }); }); } diff --git a/local-cli/wrong-react-native.js b/local-cli/wrong-react-native.js index 768ad8ce4..7489aa3a6 100755 --- a/local-cli/wrong-react-native.js +++ b/local-cli/wrong-react-native.js @@ -13,9 +13,11 @@ var script = process.argv[1]; var installedGlobally = script.indexOf('node_modules/.bin/react-native') === -1; if (installedGlobally) { + const chalk = require('chalk'); + console.error([ - '\033[31mLooks like you installed react-native globally, maybe you meant react-native-cli?', - 'To fix the issue, run:\033[0m', + chalk.red('Looks like you installed react-native globally, maybe you meant react-native-cli?'), + chalk.red('To fix the issue, run:'), 'npm uninstall -g react-native', 'npm install -g react-native-cli' ].join('\n')); diff --git a/package.json b/package.json index e2cf2a76e..251553ab2 100644 --- a/package.json +++ b/package.json @@ -116,7 +116,7 @@ "scripts": { "test": "jest", "flow": "flow", - "lint": "eslint RNTester/ Libraries/", + "lint": "eslint .", "start": "/usr/bin/env bash -c './scripts/packager.sh \"$@\" || true' --", "test-android-setup": "docker pull containership/android-base:latest", "test-android-build": "docker build -t react/android -f ContainerShip/Dockerfile.android .", diff --git a/scripts/android-e2e-test.js b/scripts/android-e2e-test.js index a0401049f..45736c8dc 100644 --- a/scripts/android-e2e-test.js +++ b/scripts/android-e2e-test.js @@ -1,6 +1,11 @@ -'use strict'; - /** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * * Used in run-ci-e2e-test.js and executed in Travis and Circle CI. * E2e test that verifies that init app can be installed, compiled, started and Hot Module reloading and Chrome debugging work. * For other examples of appium refer to: https://github.com/appium/sample-code/tree/master/sample-code/examples/node and @@ -20,6 +25,10 @@ * - node ../node_modules/.bin/_mocha ../android-e2e-test.js */ + /* eslint-env mocha */ + +'use strict'; + const wd = require('wd'); const path = require('path'); const fs = require('fs'); diff --git a/website/publish-gh-pages.js b/website/publish-gh-pages.js index ee8fafacb..146b7a8dc 100644 --- a/website/publish-gh-pages.js +++ b/website/publish-gh-pages.js @@ -9,6 +9,7 @@ 'use strict'; var semverCmp = require('semver-compare'); +/*eslint-disable no-undef */ require(`shelljs/global`); const CIRCLE_BRANCH = process.env.CIRCLE_BRANCH;