diff --git a/.babelrc b/.babelrc index 83438d76e..d759eb4ec 100644 --- a/.babelrc +++ b/.babelrc @@ -1,8 +1,16 @@ { "presets": ["react-native-stage-0/decorator-support"], + "plugins": [ + ["module-resolver", { + "root": ["./src"], + "extensions": [".android.js", ".ios.js", ".js"] + }] + ], "env": { "development": { - "plugins": ["transform-react-jsx-source"] + "plugins": [ + "transform-react-jsx-source" + ] } } } \ No newline at end of file diff --git a/.eslintrc.js b/.eslintrc.js index 33bfdb690..9a64e5fac 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -5,7 +5,7 @@ module.exports = { "jest", ], "rules": { - "import/no-extraneous-dependencies": ["error", { "devDependencies": true }], + "import/no-extraneous-dependencies": 0, "react/jsx-filename-extension": 0, "react/jsx-curly-brace-presence": 0, "react/prefer-stateless-function": [2, { "ignorePureComponents": true }], @@ -17,6 +17,11 @@ module.exports = { "jsx-a11y/media-has-caption": 0, "global-require": 0, }, + "settings": { + "import/resolver": { + "babel-module": {} + } + }, "env": { "jest/globals": true, "browser": true, diff --git a/package.json b/package.json index 81182b15e..87e5d30d2 100644 --- a/package.json +++ b/package.json @@ -11,11 +11,13 @@ "@storybook/react-native": "^3.2.14", "appr": "conrad-vanl/appr#commit-statuses", "babel-eslint": "^8.0.1", + "babel-plugin-module-resolver": "3.0.0-beta.5", "babel-preset-react-native-stage-0": "^1.0.1", "danger": "^2.0.0-alpha.20", "dotenv": "^4.0.0", "eslint": "^4.10.0", "eslint-config-airbnb": "^16.1.0", + "eslint-import-resolver-babel-module": "^4.0.0-beta.3", "eslint-plugin-import": "^2.8.0", "eslint-plugin-jest": "21.2.0", "eslint-plugin-jsx-a11y": "6.0.2", @@ -32,7 +34,7 @@ "start": "npm run create-app-entrypoint && npm run run-with-settings 'react-native-scripts start'", "android": "npm run create-app-entrypoint && npm run run-with-settings 'react-native-scripts android'", "ios": "npm run create-app-entrypoint && npm run run-with-settings 'react-native-scripts ios'", - "web": "npm run create-app-entrypoint && npm run run-with-settings 'react-scripts start'", + "web": "npm run create-app-entrypoint && NODE_PATH=./src npm run run-with-settings 'react-scripts start'", "build": "npm run create-app-entrypoint && npm run run-with-settings 'react-scripts build'", "build-storybook": "npm run create-storybook-entrypoint && npm run storybook-load-stories && build-storybook -c src/.storybook/web -s public", "test": "npm run lint && npm run jest", diff --git a/src/@modules/Audio/Audio.stories.js b/src/@modules/Audio/Audio.stories.js index 9294ae664..3fc9ff4f7 100644 --- a/src/@modules/Audio/Audio.stories.js +++ b/src/@modules/Audio/Audio.stories.js @@ -4,10 +4,10 @@ import { storiesOf } from '@storybook/react-native'; import { View, } from 'react-native'; -import Play from '../../@primitives/icons/Play'; -import Pause from '../../@primitives/icons/Pause'; +import Play from '@primitives/icons/Play'; +import Pause from '@primitives/icons/Pause'; -import ThemeProvider from '../../@primitives/ThemeProvider'; +import ThemeProvider from '@primitives/ThemeProvider'; import Audio from './'; storiesOf('Audio', module) diff --git a/src/@modules/Audio/Audio.tests.js b/src/@modules/Audio/Audio.tests.js index 2332695c3..e5fdc3e03 100644 --- a/src/@modules/Audio/Audio.tests.js +++ b/src/@modules/Audio/Audio.tests.js @@ -3,10 +3,10 @@ import renderer from 'react-test-renderer'; import { View, } from 'react-native'; -import ThemeProvider from '../../@primitives/ThemeProvider'; +import ThemeProvider from '@primitives/ThemeProvider'; +import Play from '@primitives/icons/Play'; +import Pause from '@primitives/icons/Pause'; import Audio from './'; -import Play from '../../@primitives/icons/Play'; -import Pause from '../../@primitives/icons/Pause'; it('renders correctly', () => { const tree = renderer.create( diff --git a/src/@modules/Audio/AudioPause.js b/src/@modules/Audio/AudioPause.js index 5dfed035b..bd3cca3e1 100644 --- a/src/@modules/Audio/AudioPause.js +++ b/src/@modules/Audio/AudioPause.js @@ -5,7 +5,7 @@ import PropTypes from 'prop-types'; import { TouchableHighlight, } from 'react-native'; -import onlyPropTypes from '../../@utils/onlyPropTypes'; +import onlyPropTypes from '@utils/onlyPropTypes'; export class AudioPause extends PureComponent { static propTypes = { diff --git a/src/@modules/Audio/AudioPlay.js b/src/@modules/Audio/AudioPlay.js index c90d8daf0..8ef41b0f7 100644 --- a/src/@modules/Audio/AudioPlay.js +++ b/src/@modules/Audio/AudioPlay.js @@ -5,7 +5,7 @@ import PropTypes from 'prop-types'; import { TouchableHighlight, } from 'react-native'; -import onlyPropTypes from '../../@utils/onlyPropTypes'; +import onlyPropTypes from '@utils/onlyPropTypes'; export class AudioPlay extends PureComponent { static propTypes = { diff --git a/src/@modules/Audio/AudioSeeker.js b/src/@modules/Audio/AudioSeeker.js index 2fda74fca..962571034 100644 --- a/src/@modules/Audio/AudioSeeker.js +++ b/src/@modules/Audio/AudioSeeker.js @@ -2,7 +2,7 @@ import React, { PureComponent } from 'react'; import getContext from 'recompose/getContext'; import compose from 'recompose/compose'; import PropTypes from 'prop-types'; -import Seeker from '../../@primitives/Seeker'; +import Seeker from '@primitives/Seeker'; export class AudioSeeker extends PureComponent { static propTypes = { diff --git a/src/@modules/FooterNav/FooterNavLink.js b/src/@modules/FooterNav/FooterNavLink.js index 39a5df36b..44c01ecdd 100644 --- a/src/@modules/FooterNav/FooterNavLink.js +++ b/src/@modules/FooterNav/FooterNavLink.js @@ -5,7 +5,7 @@ import { View, } from 'react-native'; import PropTypes from 'prop-types'; -import NavLink from '../NativeWebRouter/NavLink'; +import NavLink from '@modules/NativeWebRouter/NavLink'; const styles = StyleSheet.create({ container: { diff --git a/src/@modules/Header/Header.stories.js b/src/@modules/Header/Header.stories.js index 805006661..45e2fc038 100644 --- a/src/@modules/Header/Header.stories.js +++ b/src/@modules/Header/Header.stories.js @@ -2,7 +2,7 @@ import React from 'react'; import { storiesOf } from '@storybook/react-native'; -import Header from './'; +import Header from '@modules/Header'; storiesOf('Header', module) .add('renders', () =>
); diff --git a/src/@primitives/FontLoader/index.js b/src/@primitives/FontLoader/index.js index dc858be03..aac21b17b 100644 --- a/src/@primitives/FontLoader/index.js +++ b/src/@primitives/FontLoader/index.js @@ -1,7 +1,7 @@ import { Component } from 'react'; import { Font } from 'expo'; import PropTypes from 'prop-types'; -import FONTS from '../../assets/fonts'; +import FONTS from 'assets/fonts'; export default class FontLoader extends Component { static propTypes = { diff --git a/src/index.js b/src/index.js index 60541be08..75394817f 100644 --- a/src/index.js +++ b/src/index.js @@ -6,12 +6,12 @@ import { } from 'react-native'; import { Provider as ReduxProvider } from 'react-redux'; import { ApolloProvider } from 'react-apollo'; -import { Router, Route, AndroidBackButton } from './@modules/NativeWebRouter'; -import * as pages from './pages'; -import ThemeProvider from './@primitives/ThemeProvider'; -import FontLoader from './@primitives/FontLoader'; -import Store from './@data/Store'; -import Client from './@data/Client'; +import { Router, Route, AndroidBackButton } from '@modules/NativeWebRouter'; +import * as pages from 'pages'; +import ThemeProvider from '@primitives/ThemeProvider'; +import FontLoader from '@primitives/FontLoader'; +import Store from '@data/Store'; +import Client from '@data/Client'; const App = () => ( diff --git a/src/pages/Feed.js b/src/pages/Feed.js index a7cf042d1..1448731da 100644 --- a/src/pages/Feed.js +++ b/src/pages/Feed.js @@ -2,14 +2,14 @@ import React from 'react'; import { View, } from 'react-native'; -import Header from '../@modules/Header'; -import FooterNav from '../@modules/FooterNav'; -import H1 from '../@primitives/H1'; -import Umbrella from '../@primitives/icons/Umbrella'; -import { Desktop, Mobile } from '../@primitives/MediaQuery'; -import Audio from '../@modules/Audio'; -import Play from '../@primitives/icons/Play'; -import Pause from '../@primitives/icons/Pause'; +import Header from '@modules/Header'; +import FooterNav from '@modules/FooterNav'; +import H1 from '@primitives/H1'; +import Umbrella from '@primitives/icons/Umbrella'; +import { Desktop, Mobile } from '@primitives/MediaQuery'; +import Audio from '@modules/Audio'; +import Play from '@primitives/icons/Play'; +import Pause from '@primitives/icons/Pause'; export default function Feed() { return ( diff --git a/src/pages/Sections.js b/src/pages/Sections.js index 84ba98200..d7411f844 100644 --- a/src/pages/Sections.js +++ b/src/pages/Sections.js @@ -3,8 +3,8 @@ import { StyleSheet, View, } from 'react-native'; -import Header from '../@modules/Header'; -import FooterNav from '../@modules/FooterNav'; +import Header from '@modules/Header'; +import FooterNav from '@modules/FooterNav'; const styles = StyleSheet.create({ container: { diff --git a/yarn.lock b/yarn.lock index aba34febd..af0269baa 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1112,6 +1112,16 @@ babel-plugin-minify-type-constructors@^0.2.0: dependencies: babel-helper-is-void-0 "^0.2.0" +babel-plugin-module-resolver@3.0.0-beta.5: + version "3.0.0-beta.5" + resolved "https://registry.yarnpkg.com/babel-plugin-module-resolver/-/babel-plugin-module-resolver-3.0.0-beta.5.tgz#8e2873d841e4c800994a19e54ca5e2d08db9dd42" + dependencies: + find-babel-config "^1.1.0" + glob "^7.1.2" + pkg-up "^2.0.0" + reselect "^3.0.1" + resolve "^1.4.0" + babel-plugin-module-resolver@^2.7.1: version "2.7.1" resolved "https://registry.yarnpkg.com/babel-plugin-module-resolver/-/babel-plugin-module-resolver-2.7.1.tgz#18be3c42ddf59f7a456c9e0512cd91394f6e4be1" @@ -3688,6 +3698,15 @@ eslint-config-react-app@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/eslint-config-react-app/-/eslint-config-react-app-2.0.1.tgz#fd0503da01ae608f0c6ae8861de084975142230e" +eslint-import-resolver-babel-module@^4.0.0-beta.3: + version "4.0.0-beta.3" + resolved "https://registry.yarnpkg.com/eslint-import-resolver-babel-module/-/eslint-import-resolver-babel-module-4.0.0-beta.3.tgz#b9d6fbec09863c25c6f23304662c3ca068bddc64" + dependencies: + babel-jest "^20.0.3" + jest "^20.0.3" + pkg-up "^2.0.0" + resolve "^1.3.3" + eslint-import-resolver-node@^0.3.1: version "0.3.1" resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.1.tgz#4422574cde66a9a7b099938ee4d508a199e0e3cc" @@ -4271,7 +4290,7 @@ finalhandler@1.1.0: statuses "~1.3.1" unpipe "~1.0.0" -find-babel-config@^1.0.1: +find-babel-config@^1.0.1, find-babel-config@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/find-babel-config/-/find-babel-config-1.1.0.tgz#acc01043a6749fec34429be6b64f542ebb5d6355" dependencies: @@ -5831,7 +5850,7 @@ jest-validate@^20.0.3: leven "^2.1.0" pretty-format "^20.0.3" -jest@20.0.4, jest@^20.0.4: +jest@20.0.4, jest@^20.0.3, jest@^20.0.4: version "20.0.4" resolved "https://registry.yarnpkg.com/jest/-/jest-20.0.4.tgz#3dd260c2989d6dad678b1e9cc4d91944f6d602ac" dependencies: @@ -7458,6 +7477,12 @@ pkg-dir@^2.0.0: dependencies: find-up "^2.1.0" +pkg-up@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/pkg-up/-/pkg-up-2.0.0.tgz#c819ac728059a461cab1c3889a2be3c49a004d7f" + dependencies: + find-up "^2.1.0" + plist@2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/plist/-/plist-2.0.1.tgz#0a32ca9481b1c364e92e18dc55c876de9d01da8b" @@ -8871,6 +8896,10 @@ reqwest@2.0.5: version "2.0.5" resolved "https://registry.yarnpkg.com/reqwest/-/reqwest-2.0.5.tgz#00fb15ac4918c419ca82b43f24c78882e66039a1" +reselect@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/reselect/-/reselect-3.0.1.tgz#efdaa98ea7451324d092b2b2163a6a1d7a9a2147" + resolve-cwd@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/resolve-cwd/-/resolve-cwd-2.0.0.tgz#00a9f7387556e27038eae232caa372a6a59b665a" @@ -8900,7 +8929,7 @@ resolve@1.1.7: version "1.1.7" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b" -resolve@^1.1.6, resolve@^1.2.0, resolve@^1.3.2: +resolve@^1.1.6, resolve@^1.2.0, resolve@^1.3.2, resolve@^1.3.3, resolve@^1.4.0: version "1.5.0" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.5.0.tgz#1f09acce796c9a762579f31b2c1cc4c3cddf9f36" dependencies: @@ -10272,7 +10301,7 @@ vm-browserify@0.0.4: dependencies: indexof "0.0.1" -"vm2@github:patriksimek/vm2#custom_files": +vm2@patriksimek/vm2#custom_files: version "3.5.0" resolved "https://codeload.github.com/patriksimek/vm2/tar.gz/7e82f90ac705fc44fad044147cb0df09b4c79a57"