From ae2d6cc1ebd6c89a72d8c5eeb5c7a05b2a9c43de Mon Sep 17 00:00:00 2001 From: Hanwen Cheng Date: Fri, 1 Nov 2019 14:54:32 +0100 Subject: [PATCH 1/2] chore: es lint with root folder --- .eslintignore | 1 + .eslintrc.js | 8 ++++++++ ReactotronConfig.js | 12 ++++++------ babel.config.js | 42 +++++++++++++++++++++--------------------- e2e/firstTest.spec.js | 18 ++++++++++-------- e2e/init.js | 8 ++++---- e2e/testIDs.js | 12 ++++++------ index.android.js | 6 +++--- index.ios.js | 11 +++++++---- index.js | 11 +++++++---- ios/metro.config.js | 18 +++++++++--------- jest-setup.js | 2 +- jest.config.js | 22 ++++++++-------------- metro.config.js | 18 +++++++++--------- package.json | 4 ++-- 15 files changed, 102 insertions(+), 91 deletions(-) diff --git a/.eslintignore b/.eslintignore index e4aaf3a635..1d0e3affdc 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,4 +1,5 @@ # /node_modules/* and /bower_components/* in the project root are ignored by default +**/*.md.js /NDK **/build diff --git a/.eslintrc.js b/.eslintrc.js index f754fba7c9..aa2b7b50ef 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,5 +1,13 @@ module.exports = { extends: ["@react-native-community", "plugin:prettier/recommended"], + overrides: [ + { + "files": ["e2e/*.spec.js", "e2e/init.js"], + "rules": { + "no-undef": "off" + } + } + ], parserOptions: { "ecmaVersion": 6, "sourceType": "module", diff --git a/ReactotronConfig.js b/ReactotronConfig.js index 99d44c6617..109b0a1792 100644 --- a/ReactotronConfig.js +++ b/ReactotronConfig.js @@ -1,9 +1,9 @@ -import Reactotron from "reactotron-react-native"; +import Reactotron from 'reactotron-react-native'; if (__DEV__) { - Reactotron.configure({ - host: "192.168.1.63" - }) // controls connection & communication settings - .useReactNative() // add all built-in react native plugins - .connect(); // let's connect! + Reactotron.configure({ + host: '192.168.1.63' + }) // controls connection & communication settings + .useReactNative() // add all built-in react native plugins + .connect(); // let's connect! } diff --git a/babel.config.js b/babel.config.js index 638c47a678..1beb49178e 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,22 +1,22 @@ module.exports = { - "presets": ["module:metro-react-native-babel-preset"], - "plugins": [ - [ - "rewrite-require", - { - "aliases": { - "crypto": "react-native-crypto", - "stream": "readable-stream", - "_stream_duplex": "readable-stream/duplex", - "_stream_passthrough": "readable-stream/passthrough", - "_stream_readable": "readable-stream/readable", - "_stream_transform": "readable-stream/transform", - "_stream_writable": "readable-stream/writable", - "@polkadot/wasm-crypto": "@plugnet/wasm-crypto-js", - "@plugnet/util": "@polkadot/util", - "vm": "vm-browserify" - } - } - ] - ] -} \ No newline at end of file + plugins: [ + [ + 'rewrite-require', + { + aliases: { + '@plugnet/util': '@polkadot/util', + '@polkadot/wasm-crypto': '@plugnet/wasm-crypto-js', + _stream_duplex: 'readable-stream/duplex', + _stream_passthrough: 'readable-stream/passthrough', + _stream_readable: 'readable-stream/readable', + _stream_transform: 'readable-stream/transform', + _stream_writable: 'readable-stream/writable', + crypto: 'react-native-crypto', + stream: 'readable-stream', + vm: 'vm-browserify' + } + } + ] + ], + presets: ['module:metro-react-native-babel-preset'] +}; diff --git a/e2e/firstTest.spec.js b/e2e/firstTest.spec.js index 036e52d20d..8ac8de3f36 100644 --- a/e2e/firstTest.spec.js +++ b/e2e/firstTest.spec.js @@ -1,11 +1,13 @@ -import testIDs from "./testIDs"; +import testIDs from './testIDs'; describe('Load test', () => { - it('should have account list screen', async () => { - await expect(element(by.id(testIDs.TacScreen.tacView))).toBeVisible(); - await element(by.id(testIDs.TacScreen.agreePrivacyButton)).tap(); - await element(by.id(testIDs.TacScreen.agreeTacButton)).tap(); - await element(by.id(testIDs.TacScreen.nextButton)).tap(); - await expect(element(by.id(testIDs.AccountListScreen.accountList))).toBeVisible(); - }); + it('should have account list screen', async () => { + await expect(element(by.id(testIDs.TacScreen.tacView))).toBeVisible(); + await element(by.id(testIDs.TacScreen.agreePrivacyButton)).tap(); + await element(by.id(testIDs.TacScreen.agreeTacButton)).tap(); + await element(by.id(testIDs.TacScreen.nextButton)).tap(); + await expect( + element(by.id(testIDs.AccountListScreen.accountList)) + ).toBeVisible(); + }); }); diff --git a/e2e/init.js b/e2e/init.js index 26d2bff411..7a5ed06347 100644 --- a/e2e/init.js +++ b/e2e/init.js @@ -12,14 +12,14 @@ jasmine.getEnv().addReporter(adapter); jasmine.getEnv().addReporter(specReporter); beforeAll(async () => { - await detox.init(config); + await detox.init(config); }); beforeEach(async () => { - await adapter.beforeEach(); + await adapter.beforeEach(); }); afterAll(async () => { - await adapter.afterAll(); - await detox.cleanup(); + await adapter.afterAll(); + await detox.cleanup(); }); diff --git a/e2e/testIDs.js b/e2e/testIDs.js index 0ea7d48b44..48d607c51d 100644 --- a/e2e/testIDs.js +++ b/e2e/testIDs.js @@ -1,12 +1,12 @@ const testIDs = { + AccountListScreen: { + accountList: 'accountList' + }, TacScreen: { - tacView: 'tac_view', - agreeTacButton: 'tac_agree', agreePrivacyButton: 'tac_privacy', - nextButton: 'tac_next' - }, - AccountListScreen: { - accountList: 'accountList', + agreeTacButton: 'tac_agree', + nextButton: 'tac_next', + tacView: 'tac_view' } }; diff --git a/index.android.js b/index.android.js index 043ec55b97..9614183616 100644 --- a/index.android.js +++ b/index.android.js @@ -20,11 +20,11 @@ * @flow */ -import { AppRegistry, YellowBox } from 'react-native' +import { AppRegistry, YellowBox } from 'react-native'; import App from './src/App'; YellowBox.ignoreWarnings([ - 'Warning: isMounted(...) is deprecated', - 'Module RCTImageLoader' + 'Warning: isMounted(...) is deprecated', + 'Module RCTImageLoader' ]); AppRegistry.registerComponent('NativeSigner', () => App); diff --git a/index.ios.js b/index.ios.js index 839decc2ab..9614183616 100644 --- a/index.ios.js +++ b/index.ios.js @@ -20,8 +20,11 @@ * @flow */ -import { AppRegistry, YellowBox } from 'react-native' -import App from './src/App' -YellowBox.ignoreWarnings(['Warning: isMounted(...) is deprecated', 'Module RCTImageLoader']) +import { AppRegistry, YellowBox } from 'react-native'; +import App from './src/App'; +YellowBox.ignoreWarnings([ + 'Warning: isMounted(...) is deprecated', + 'Module RCTImageLoader' +]); -AppRegistry.registerComponent('NativeSigner', () => App) +AppRegistry.registerComponent('NativeSigner', () => App); diff --git a/index.js b/index.js index 839decc2ab..9614183616 100644 --- a/index.js +++ b/index.js @@ -20,8 +20,11 @@ * @flow */ -import { AppRegistry, YellowBox } from 'react-native' -import App from './src/App' -YellowBox.ignoreWarnings(['Warning: isMounted(...) is deprecated', 'Module RCTImageLoader']) +import { AppRegistry, YellowBox } from 'react-native'; +import App from './src/App'; +YellowBox.ignoreWarnings([ + 'Warning: isMounted(...) is deprecated', + 'Module RCTImageLoader' +]); -AppRegistry.registerComponent('NativeSigner', () => App) +AppRegistry.registerComponent('NativeSigner', () => App); diff --git a/ios/metro.config.js b/ios/metro.config.js index 9840b7729d..d9e17e3394 100644 --- a/ios/metro.config.js +++ b/ios/metro.config.js @@ -5,12 +5,12 @@ * @format */ module.exports = { - transformer: { - getTransformOptions: async () => ({ - transform: { - experimentalImportSupport: false, - inlineRequires: false, - }, - }), - }, -}; \ No newline at end of file + transformer: { + getTransformOptions: async () => ({ + transform: { + experimentalImportSupport: false, + inlineRequires: false + } + }) + } +}; diff --git a/jest-setup.js b/jest-setup.js index d504646150..09c6ec3cb1 100644 --- a/jest-setup.js +++ b/jest-setup.js @@ -17,4 +17,4 @@ /* global jest */ // import mockCamera from './__mocks__/Camera' -jest.doMock('react-native', () => 'reactNativeMock') \ No newline at end of file +jest.doMock('react-native', () => 'reactNativeMock'); diff --git a/jest.config.js b/jest.config.js index c95987d139..4c729261f3 100644 --- a/jest.config.js +++ b/jest.config.js @@ -17,17 +17,11 @@ const { defaults } = require('jest-config'); module.exports = { - preset: "react-native", - moduleFileExtensions: [...defaults.moduleFileExtensions, 'ts', 'tsx'], - verbose: true, - roots: [ - "/src" - ], - setupFiles: [ - "/jest-setup.js" - ], - testEnvironment: "node", - testPathIgnorePatterns: [ - "/node_modules/" - ] -} \ No newline at end of file + moduleFileExtensions: [...defaults.moduleFileExtensions, 'ts', 'tsx'], + preset: 'react-native', + roots: ['/src'], + setupFiles: ['/jest-setup.js'], + testEnvironment: 'node', + testPathIgnorePatterns: ['/node_modules/'], + verbose: true +}; diff --git a/metro.config.js b/metro.config.js index d6814bbda2..d9e17e3394 100644 --- a/metro.config.js +++ b/metro.config.js @@ -5,12 +5,12 @@ * @format */ module.exports = { - transformer: { - getTransformOptions: async () => ({ - transform: { - experimentalImportSupport: false, - inlineRequires: false, - } - }) - } -}; \ No newline at end of file + transformer: { + getTransformOptions: async () => ({ + transform: { + experimentalImportSupport: false, + inlineRequires: false + } + }) + } +}; diff --git a/package.json b/package.json index 2fe3cd476b..f7de53e439 100644 --- a/package.json +++ b/package.json @@ -16,8 +16,8 @@ "clean-rust" : "cd rust/signer && cargo clean && cd ../..", "commit": "commit-wizard", "ios": "yarn run build-rust-ios && react-native run-ios", - "lint": "npx eslint ./src/ --ext .js,.jsx", - "lint:fix": "npx eslint ./src/ --ext .js,.jsx --fix", + "lint": "npx eslint . --ext .js,.jsx", + "lint:fix": "npx eslint . --ext .js,.jsx --fix", "postinstall": "npx jetify && chmod +x ./scripts/fix-rn-camera-path.sh && ./scripts/fix-rn-camera-path.sh ./node_modules/react-native-camera/ios/RNCamera.xcodeproj/project.pbxproj", "start": "NODE_OPTIONS=--max_old_space_size=8192 react-native start", "test": "jest", From 89394834ca3cf8e64f78a1b72675781dd89f578b Mon Sep 17 00:00:00 2001 From: Hanwen Cheng Date: Fri, 1 Nov 2019 15:01:11 +0100 Subject: [PATCH 2/2] update eslint ignore path --- .eslintignore | 5 ----- docs/privacy-policy.md.js | 2 +- docs/terms-and-conditions.md.js | 2 +- package.json | 4 ++-- 4 files changed, 4 insertions(+), 9 deletions(-) delete mode 100644 .eslintignore diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 1d0e3affdc..0000000000 --- a/.eslintignore +++ /dev/null @@ -1,5 +0,0 @@ -# /node_modules/* and /bower_components/* in the project root are ignored by default - -**/*.md.js -/NDK -**/build diff --git a/docs/privacy-policy.md.js b/docs/privacy-policy.md.js index 37f87c8ec3..ffe7ebf907 100644 --- a/docs/privacy-policy.md.js +++ b/docs/privacy-policy.md.js @@ -223,4 +223,4 @@ Statutory information - Registered Number: 09760015 - Registered Office: Ignition Law, Moray House Floor 1, 23-31 Great Titchfield Street, London, United Kingdom, WC1W 7PA. -` +`; diff --git a/docs/terms-and-conditions.md.js b/docs/terms-and-conditions.md.js index 99bad21379..2daa1e4262 100644 --- a/docs/terms-and-conditions.md.js +++ b/docs/terms-and-conditions.md.js @@ -177,4 +177,4 @@ All disputes or claims arising out of, relating to, or in connection with the Te If you are a business entity, then the individual accepting on behalf of the entity (for the avoidance of doubt, for business entities, in these Terms, "you" means the entity) represents and warrants that he or she has the authority to act on your behalf, that you represent that you are duly authorized to do business in the country or countries where you operate, and that your employees, officers, representatives, and other agents accessing Parity Technologies' Products are duly authorized to access Parity Signer and to legally bind you to these Terms. Subject to these Terms and subject to the Software Licence Terms, Parity Technologies grants you a non-exclusive, non-transferable licence to use Parity Signer solely on machines intended for use by your employees, officers, representatives, and agents in connection with your business entity, and provided that their use of Parity Signer will be subject to these Terms (including the Software Licence Terms). -` +`; diff --git a/package.json b/package.json index f7de53e439..927e52087e 100644 --- a/package.json +++ b/package.json @@ -16,8 +16,8 @@ "clean-rust" : "cd rust/signer && cargo clean && cd ../..", "commit": "commit-wizard", "ios": "yarn run build-rust-ios && react-native run-ios", - "lint": "npx eslint . --ext .js,.jsx", - "lint:fix": "npx eslint . --ext .js,.jsx --fix", + "lint": "npx eslint . --ext .js,.jsx --ignore-path .gitignore", + "lint:fix": "npx eslint . --ext .js,.jsx --fix --ignore-path .gitignore", "postinstall": "npx jetify && chmod +x ./scripts/fix-rn-camera-path.sh && ./scripts/fix-rn-camera-path.sh ./node_modules/react-native-camera/ios/RNCamera.xcodeproj/project.pbxproj", "start": "NODE_OPTIONS=--max_old_space_size=8192 react-native start", "test": "jest",