├── .babelrc ├── .eslintrc ├── .flowconfig ├── .gitignore ├── .npmignore ├── .travis.yml ├── README.md ├── assets └── reducer.js ├── package.json ├── src ├── __testfixtures__ │ └── addToExisting │ │ ├── actions.js │ │ ├── constants.js │ │ └── reducer.js ├── __tests__ │ ├── __snapshots__ │ │ ├── cli.test.js.snap │ │ ├── createAction.test.js.snap │ │ └── fileOperations.test.js.snap │ ├── cli.test.js │ ├── createAction.test.js │ ├── fileOperations.test.js │ └── helper.test.js ├── cli.js ├── createAction.js ├── fileOperations.js ├── helper.js └── testUtils.js ├── webpack.config.babel.js └── yarn.lock /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["latest", "stage-0"], 3 | "plugins": [ 4 | "transform-runtime", 5 | "transform-flow-strip-types" 6 | ], 7 | "sourceMaps": "both" 8 | } 9 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "parser" : "babel-eslint", 3 | "extends" : "eslint-config-airbnb-base", 4 | "env" : { 5 | "browser" : false 6 | }, 7 | "rules": { 8 | "arrow-parens": 0 9 | }, 10 | "globals" : { 11 | "__DEV__" : false, 12 | "__PROD__" : false, 13 | "__DEBUG__" : false, 14 | "__DEBUG_NEW_WINDOW__" : false 15 | }, 16 | } 17 | -------------------------------------------------------------------------------- /.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | 7 | [options] 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | typings 3 | keys.js 4 | dist 5 | npm-debug.log.env 6 | .env 7 | .vagrant 8 | coverage 9 | .nyc_output 10 | logfile.log 11 | npm-debug.log 12 | .idea 13 | bin -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | src 2 | coverage 3 | node_modules 4 | webpack.config.* 5 | .babelrc 6 | .eslintrc 7 | .gitignore 8 | yarn.lock 9 | .flowconfig 10 | .travis.yml 11 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "node" 4 | cache: yarn 5 | before_install: yarn global add greenkeeper-lockfile@1 6 | before_script: greenkeeper-lockfile-update 7 | script: npm run coveralls 8 | after_script: greenkeeper-lockfile-upload 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # redux-boilerplate-helpers 2 | 3 | [![Build Status](https://travis-ci.org/alxlu/redux-boilerplate-helpers.svg?branch=master)](https://travis-ci.org/alxlu/redux-boilerplate-helpers) 4 | [![Coverage Status](https://coveralls.io/repos/github/alxlu/redux-boilerplate-helpers/badge.svg?branch=master)](https://coveralls.io/github/alxlu/redux-boilerplate-helpers?branch=master) 5 | [![npm](https://img.shields.io/npm/v/redux-boilerplate-helpers.svg)](https://www.npmjs.com/package/redux-boilerplate-helpers) 6 | [![Greenkeeper badge](https://badges.greenkeeper.io/alxlu/redux-boilerplate-helpers.svg)](https://greenkeeper.io/) 7 | [![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier) 8 | 9 |
10 | Table of Contents 11 | 12 | - [Demo](#demo) 13 | - [Tool](#tool) 14 | - [Action Creator](#actioncreator) 15 | - [Usage](#usage) 16 | - [Installation](#installation) 17 | - [Roadmap](#roadmap) 18 | - [Contributing](#contributing) 19 |
20 | 21 | --- 22 | 23 | A commandline tool and small helper library that helps you cut down on the amount of typing you need 24 | to do while writing Redux boilerplate. 25 | 26 | Currently, the existing tools used for automating Redux Boilerplate only create new files from 27 | templates and are unable to modify existing files. `redux-boilerplate-helpers`'s tool parses your 28 | code into an AST (Abstract Syntax Tree) to automate adding Redux boilerplate code into your existing 29 | files. If you already have existing[\*](#format-footnote) action creators, constants, or a reducer 30 | in a file, it will ensure the code you want to add is put in the correct place. And if you are 31 | missing any of the files, the tool will create new ones for you. 32 | 33 | \* Provided your code follows the following 34 | format. That being said, this tool should flexible enough to be modified to handle most setups (See 35 | [Roadmap](#roadmap) for more info). 36 | 37 | 38 | ## Demo 39 | Try out the online interactive demo [here](http://alx.lu/rdxh-demo/). 40 | 41 | ## Tool 42 | Let's start out with the following three files which already have content in them: 43 | `Demo/constants.js`, `Demo/actions.js`, `Demo/reducer.js` 44 | 45 | ```javascript 46 | // Demo/constants.js 47 | export const SOME_ACTION = 'Demo/SOME_ACTION'; 48 | export const ANOTHER_ACTION = 'Demo/ANOTHER_ACTION'; 49 | 50 | ``` 51 | 52 | ```javascript 53 | // Demo/actions.js 54 | import { createAction } from 'redux-boilerplate-helpers'; // see `Lib` section 55 | import { SOME_ACTION, ANOTHER_ACTION } from './constants'; 56 | 57 | // this is equivalent to `export const someAction = payload => ({ type: SOME_ACTION, payload }); 58 | export const someAction = createAction(SOME_ACTION); 59 | export const anotherAction = createAction(ANOTHER_ACTION); 60 | ``` 61 | 62 | ```javascript 63 | // Demo/reducer.js 64 | import { SOME_ACTION, ANOTHER_ACTION } from './constants'; 65 | 66 | const initialState = {}; 67 | 68 | function demoReducer (state = initialState, action) { 69 | switch(action.type) { 70 | case SOME_ACTION: 71 | return { ...state, id: action.payload.id, result: action.payload.result }; 72 | case ANOTHER_ACTION: 73 | return { ...state, something: action.payload }; 74 | default: 75 | return state; 76 | } 77 | } 78 | 79 | export default demoReducer; 80 | ``` 81 | 82 | If we want to add three more actions: `GET_SOMETHING`, `GET_SOMETHING_SUCCESS`, and 83 | `GET_SOMETHING_ERROR`, we can simply run 84 | ```bash 85 | rdxh --dir ./Demo getSomething get_something_success getSomethingError --single-quote --trailing-comma all 86 | ``` 87 | We can use any combination of camelCase, PascalCase, snake_case, or CONSTANT_CASE to specify the 88 | action names. Formatting options are passed directly to 89 | [`prettier`](https://github.com/prettier/prettier)—which is what this tool uses to format the 90 | finalized output: 91 | 92 | 93 | ```javascript 94 | // Demo/constants.js 95 | export const SOME_ACTION = 'Demo/SOME_ACTION'; 96 | export const ANOTHER_ACTION = 'Demo/ANOTHER_ACTION'; 97 | export const GET_SOMETHING = 'Demo/GET_SOMETHING'; 98 | export const GET_SOMETHING_SUCCESS = 'Demo/GET_SOMETHING_SUCCESS'; 99 | export const GET_SOMETHING_ERROR = 'Demo/GET_SOMETHING_ERROR'; 100 | 101 | ``` 102 | 103 | ```javascript 104 | // Demo/actions.js 105 | import { createAction } from 'redux-boilerplate-helpers'; // see `Lib` section 106 | import { 107 | SOME_ACTION, 108 | ANOTHER_ACTION, 109 | GET_SOMETHING, 110 | GET_SOMETHING_SUCCESS, 111 | GET_SOMETHING_ERROR, 112 | } from './constants'; 113 | 114 | // this is equivalent to `export const someAction = payload => ({ type: SOME_ACTION, payload }); 115 | export const someAction = createAction(SOME_ACTION); 116 | export const anotherAction = createAction(ANOTHER_ACTION); 117 | export const getSomething = createAction(GET_SOMETHING); 118 | export const getSomethingSuccess = createAction(GET_SOMETHING_SUCCESS); 119 | export const getSomethingError = createAction(GET_SOMETHING_ERROR); 120 | ``` 121 | 122 | ```javascript 123 | // Demo/reducer.js 124 | import { 125 | SOME_ACTION, 126 | ANOTHER_ACTION, 127 | GET_SOMETHING, 128 | GET_SOMETHING_SUCCESS, 129 | GET_SOMETHING_ERROR, 130 | } from './constants'; 131 | const initialState = {}; 132 | 133 | function demoReducer(state = initialState, action) { 134 | switch (action.type) { 135 | case SOME_ACTION: 136 | return { ...state, id: action.payload.id, result: action.payload.result }; 137 | case ANOTHER_ACTION: 138 | return { ...state, something: action.payload }; 139 | case GET_SOMETHING: 140 | return { 141 | ...state, 142 | }; 143 | case GET_SOMETHING_SUCCESS: 144 | return { 145 | ...state, 146 | }; 147 | case GET_SOMETHING_ERROR: 148 | return { 149 | ...state, 150 | }; 151 | default: 152 | return state; 153 | } 154 | } 155 | 156 | export default demoReducer; 157 | ``` 158 | 159 | The tool will also make sure it doesn't add duplicate entries if parts of the code are already 160 | in place (e.g. if you define a constant and create an action for it, if you run the tool with 161 | that constant name as a paramter, the tool will only modify the reducers.js file). 162 | 163 | And if the `constants.js`, `actions.js`, or `reducer.js` file is not present in the directory, the 164 | tool will create them for you. 165 | 166 | ## ActionCreator 167 | 168 | ```javascript 169 | createAction( 170 | type: string, 171 | payloadCreator: function = identity, 172 | { name: string = 'payload', meta: function }, 173 | ); 174 | ``` 175 | 176 | This little util is inspired by [`redux actions`](https://github.com/acdlite/redux-actions). This 177 | tool is a little simpler and less prescriptive and does not enforce the [FSA 178 | pattern](https://github.com/acdlite/flux-standard-action). It also does not replicate the other 179 | helper functions `redux actions` provides. 180 | 181 | A lot actions often wind up looking similar, so this helper cuts down on some code for the most 182 | basic case (similar to redux-actions). 183 | 184 | In it's simplest form, you just call `createAction()` with your constant, and it will return an 185 | action creator with an identity function. 186 | 187 | ```javascript 188 | const ACTION = 'ACTION'; 189 | const act = createAction(ACTION); 190 | 191 | expect(act('test')).toEqual({ type: ACTION, payload: 42 }); 192 | ``` 193 | 194 | The `name` field allows you to override the named of the member that the payloadCreator funcion 195 | returns to (defaults to `payload`). The `meta` field is an optional function that creates metadata 196 | for the payload. It receives the same arguments as the payload creator, but its result becomes the 197 | meta field of the resulting action. If metaCreator is undefined or not a function, the meta field is 198 | omitted. 199 | 200 | I'm still not entirely sure how useful this helper function is and will likely end up updating the 201 | tool to directly add an action creator (without a helper function) and put adding the helper library 202 | behind a flag. 203 | 204 | ## Installation 205 | 206 | ### Project Specific 207 | First run: 208 | ```bash 209 | npm i redux-boilerplate-helpers 210 | # or yarn add redux-boilerplate-helpers 211 | 212 | ``` 213 | then add the following to the `scripts` secion of your `package.json` 214 | 215 | ```javascript 216 | { 217 | ... 218 | "scripts": { 219 | "rdxh": "rdxh" 220 | }, 221 | ... 222 | } 223 | ``` 224 | 225 | ### Globally 226 | ```bash 227 | npm i -g redux-boilerplate-helpers 228 | npm i redux-boilerplate-helpers 229 | 230 | # or yarn global add redux-boilerplate-helpers 231 | # yarn add redux-boilerplate-helpers 232 | ``` 233 | 234 | ## Usage 235 | 236 | ### Project Specific 237 | Note that the `--dir` option requires a path relative to your project root. You can use `pwd` if you 238 | want to run the tool in the directory you are currently in. This limitation is due to how `npm` 239 | scripts work. If you'd like to use relative paths, the tool will need to be installed globally (see 240 | next section). 241 | ```bash 242 | npm run rdxh -- --dir path/to/folder actionName anotherAction --trailing-comma all --single-quote 243 | # if you prefer to run it in the path you are currently in, you need to run 244 | npm run rdxh -- --dir `pwd` actionName anotherAction --trailing-comma all --single-quote 245 | ``` 246 | 247 | ### Globally 248 | Installing the tool globaly allows you to use a relative path for the `--dir` option. 249 | 250 | ```bash 251 | rdxh --dir ./ actionName anotherAction --trailing-comma all -single-quote 252 | ``` 253 | 254 | ## Roadmap 255 | I created this to help with my specific use case. However, there are many different ways people 256 | structure their code. With some changes, this tool should be able to support a majority of use 257 | cases. A few quick future changes which could be useful include (but are not limited to): 258 | 259 | - Ability to specify the exact location of each file (this includes support for people using the 260 | ducks pattern). 261 | 262 | - Add an option to insert the new code into the files without running it through `prettier`. This 263 | would basically mean passing the formatting options directly to the `recast` print function. 264 | 265 | - Provide a way to customize the default ActionCreators. 266 | 267 | - Additional configuration options (TBD). 268 | 269 | 270 | ## Contributing 271 | 272 | To set up the environment, clone the repository, install the dependencies and run the tests: 273 | ```bash 274 | yarn 275 | yarn test 276 | ``` 277 | 278 | Before you make a PR, please make sure you run: 279 | ```bash 280 | yarn run format 281 | ``` 282 | 283 | This command runs `eslint` and `prettier` to esure that the PR conforms to the existing codebase. 284 | -------------------------------------------------------------------------------- /assets/reducer.js: -------------------------------------------------------------------------------- 1 | const initialState = {}; 2 | 3 | function reducer(state = initialState, action) { 4 | switch (action.type) { 5 | default: 6 | return state; 7 | } 8 | } 9 | 10 | export default reducer; 11 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "redux-boilerplate-helpers", 3 | "version": "0.0.3", 4 | "main": "./dist/index.js", 5 | "bin": { 6 | "rdxh": "./bin/index.js" 7 | }, 8 | "license": "MIT", 9 | "repository": "https://github.com/alxlu/redux-boilerplate-helpers.git", 10 | "dependencies": { 11 | "assert": "^1.4.1", 12 | "babylon": "^6.17.2", 13 | "change-case": "^3.0.1", 14 | "invariant": "^2.2.2", 15 | "minimist": "^1.2.0", 16 | "prettier": "^1.4.4", 17 | "recast": "^0.12.5" 18 | }, 19 | "scripts": { 20 | "start": "bin/index.js", 21 | "test": "jest", 22 | "coverage": "npm test -- --coverage", 23 | "build": "webpack", 24 | "format": "eslint src --fix && prettier --write --single-quote --trailing-comma=all --print-width=100 \"src/**/*.js\"", 25 | "coveralls": "npm run coverage && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js" 26 | }, 27 | "devDependencies": { 28 | "babel-cli": "^6.24.1", 29 | "babel-eslint": "^7.2.3", 30 | "babel-jest": "^20.0.3", 31 | "babel-loader": "^7.0.0", 32 | "babel-plugin-transform-flow-strip-types": "^6.22.0", 33 | "babel-plugin-transform-runtime": "^6.23.0", 34 | "babel-preset-latest": "^6.24.1", 35 | "babel-preset-stage-0": "^6.24.1", 36 | "babel-register": "^6.24.1", 37 | "babel-runtime": "^6.23.0", 38 | "coveralls": "^2.13.1", 39 | "cross-spawn": "^5.1.0", 40 | "del": "^3.0.0", 41 | "eslint": "^4.1.0", 42 | "eslint-config-airbnb-base": "^11.2.0", 43 | "eslint-plugin-import": "^2.2.0", 44 | "flow-bin": "^0.48.0", 45 | "jest": "^20.0.4", 46 | "mkdirp": "^0.5.1", 47 | "webpack": "^3.0.0", 48 | "webpack-node-externals": "^1.6.0" 49 | }, 50 | "jest": { 51 | "moduleDirectories": [ 52 | "src", 53 | "node_modules" 54 | ], 55 | "coverageDirectory": "coverage", 56 | "collectCoverage": false, 57 | "collectCoverageFrom": [ 58 | "src/**/*.js" 59 | ], 60 | "coveragePathIgnorePatterns": [ 61 | "__*", 62 | "/src/cli.js", 63 | "/src/testUtils.js" 64 | ] 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/__testfixtures__/addToExisting/actions.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import { createAction } from 'redux-boilerplate-helpers'; 3 | import { TEST_ACTION, ANOTHER_ACTION } from './constants'; 4 | 5 | export const testAction = createAction(TEST_ACTION); 6 | export const anotherAction = createAction(ANOTHER_ACTION); 7 | -------------------------------------------------------------------------------- /src/__testfixtures__/addToExisting/constants.js: -------------------------------------------------------------------------------- 1 | export const TEST_ACTION = '__testfixtures__/TEST_ACTION'; 2 | export const ANOTHER_ACTION = '__testfixtures__/ANOTHER_ACTION'; 3 | -------------------------------------------------------------------------------- /src/__testfixtures__/addToExisting/reducer.js: -------------------------------------------------------------------------------- 1 | import { TEST_ACTION, ANOTHER_ACTION } from './constants'; 2 | 3 | const initialState = {}; 4 | 5 | function testReducer(state = initialState, action) { 6 | switch (action.type) { 7 | case TEST_ACTION: 8 | return { ...state, test: 10 }; 9 | case ANOTHER_ACTION: 10 | return { ...state, another: 'test' }; 11 | default: 12 | return state; 13 | } 14 | } 15 | 16 | export default testReducer; 17 | -------------------------------------------------------------------------------- /src/__tests__/__snapshots__/cli.test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`cli adds actions to existing files in dry run 1`] = ` 4 | "==== addToExisting/constants.js ==== 5 | export const TEST_ACTION = '__testfixtures__/TEST_ACTION'; 6 | export const ANOTHER_ACTION = '__testfixtures__/ANOTHER_ACTION'; 7 | export const ONE_ACTION = 'addToExisting/ONE_ACTION'; 8 | export const TWO_ACTION = 'addToExisting/TWO_ACTION'; 9 | 10 | ==== addToExisting/actions.js ==== 11 | /* eslint-disable */ 12 | import { createAction } from 'redux-boilerplate-helpers'; 13 | import { 14 | TEST_ACTION, 15 | ANOTHER_ACTION, 16 | ONE_ACTION, 17 | TWO_ACTION, 18 | } from './constants'; 19 | 20 | export const testAction = createAction(TEST_ACTION); 21 | export const anotherAction = createAction(ANOTHER_ACTION); 22 | export const oneAction = createAction(ONE_ACTION); 23 | export const twoAction = createAction(TWO_ACTION); 24 | 25 | ==== addToExisting/reducer.js ==== 26 | import { 27 | TEST_ACTION, 28 | ANOTHER_ACTION, 29 | ONE_ACTION, 30 | TWO_ACTION, 31 | } from './constants'; 32 | 33 | const initialState = {}; 34 | 35 | function testReducer(state = initialState, action) { 36 | switch (action.type) { 37 | case TEST_ACTION: 38 | return { ...state, test: 10 }; 39 | case ANOTHER_ACTION: 40 | return { ...state, another: 'test' }; 41 | case ONE_ACTION: 42 | return { 43 | ...state, 44 | }; 45 | case TWO_ACTION: 46 | return { 47 | ...state, 48 | }; 49 | default: 50 | return state; 51 | } 52 | } 53 | 54 | export default testReducer; 55 | 56 | " 57 | `; 58 | 59 | exports[`cli creates files if they are not present 1`] = ` 60 | "export const ONE_ACTION = 'blank/ONE_ACTION'; 61 | export const TWO_ACTION = 'blank/TWO_ACTION'; 62 | " 63 | `; 64 | 65 | exports[`cli creates files if they are not present 2`] = ` 66 | "import { createAction } from 'redux-boilerplate-helpers'; 67 | import { ONE_ACTION, TWO_ACTION } from './constants'; 68 | export const oneAction = createAction(ONE_ACTION); 69 | export const twoAction = createAction(TWO_ACTION); 70 | " 71 | `; 72 | 73 | exports[`cli creates files if they are not present 3`] = ` 74 | "import { ONE_ACTION, TWO_ACTION } from './constants'; 75 | const initialState = {}; 76 | 77 | function reducer(state = initialState, action) { 78 | switch (action.type) { 79 | case ONE_ACTION: 80 | return { 81 | ...state, 82 | }; 83 | case TWO_ACTION: 84 | return { 85 | ...state, 86 | }; 87 | default: 88 | return state; 89 | } 90 | } 91 | 92 | export default reducer; 93 | " 94 | `; 95 | -------------------------------------------------------------------------------- /src/__tests__/__snapshots__/createAction.test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`createAction Reducer Case creates an entry for the action handler above default 1`] = ` 4 | Node { 5 | "end": 309, 6 | "loc": SourceLocation { 7 | "end": Object { 8 | "column": 26, 9 | "line": 11, 10 | }, 11 | "indent": 0, 12 | "lines": Lines {}, 13 | "start": Object { 14 | "column": 0, 15 | "line": 1, 16 | }, 17 | }, 18 | "name": null, 19 | "program": Node { 20 | "body": Array [ 21 | Node { 22 | "end": 57, 23 | "importKind": "value", 24 | "loc": SourceLocation { 25 | "end": Position { 26 | "column": 57, 27 | "line": 1, 28 | }, 29 | "indent": 0, 30 | "lines": Lines {}, 31 | "start": Position { 32 | "column": 0, 33 | "line": 1, 34 | }, 35 | }, 36 | "source": Node { 37 | "end": 56, 38 | "extra": Object { 39 | "raw": "\\"redux-boilerplate-helpers\\"", 40 | "rawValue": "redux-boilerplate-helpers", 41 | }, 42 | "loc": SourceLocation { 43 | "end": Position { 44 | "column": 56, 45 | "line": 1, 46 | }, 47 | "indent": 0, 48 | "lines": Lines {}, 49 | "start": Position { 50 | "column": 29, 51 | "line": 1, 52 | }, 53 | }, 54 | "regex": null, 55 | "start": 29, 56 | "type": "StringLiteral", 57 | "value": "redux-boilerplate-helpers", 58 | }, 59 | "specifiers": Array [ 60 | Node { 61 | "end": 21, 62 | "id": null, 63 | "importKind": null, 64 | "imported": Node { 65 | "end": 21, 66 | "loc": SourceLocation { 67 | "end": Position { 68 | "column": 21, 69 | "line": 1, 70 | }, 71 | "identifierName": "createAction", 72 | "indent": 0, 73 | "lines": Lines {}, 74 | "start": Position { 75 | "column": 9, 76 | "line": 1, 77 | }, 78 | }, 79 | "name": "createAction", 80 | "start": 9, 81 | "type": "Identifier", 82 | "typeAnnotation": null, 83 | }, 84 | "loc": SourceLocation { 85 | "end": Position { 86 | "column": 21, 87 | "line": 1, 88 | }, 89 | "indent": 0, 90 | "lines": Lines {}, 91 | "start": Position { 92 | "column": 9, 93 | "line": 1, 94 | }, 95 | }, 96 | "local": Node { 97 | "__clone": [Function], 98 | "end": 21, 99 | "loc": SourceLocation { 100 | "end": Position { 101 | "column": 21, 102 | "line": 1, 103 | }, 104 | "identifierName": "createAction", 105 | "indent": 0, 106 | "lines": Lines {}, 107 | "start": Position { 108 | "column": 9, 109 | "line": 1, 110 | }, 111 | }, 112 | "name": "createAction", 113 | "start": 9, 114 | "type": "Identifier", 115 | "typeAnnotation": null, 116 | }, 117 | "name": null, 118 | "start": 9, 119 | "type": "ImportSpecifier", 120 | }, 121 | ], 122 | "start": 0, 123 | "type": "ImportDeclaration", 124 | }, 125 | Node { 126 | "end": 104, 127 | "importKind": "value", 128 | "loc": SourceLocation { 129 | "end": Position { 130 | "column": 46, 131 | "line": 2, 132 | }, 133 | "indent": 0, 134 | "lines": Lines {}, 135 | "start": Position { 136 | "column": 0, 137 | "line": 2, 138 | }, 139 | }, 140 | "source": Node { 141 | "end": 103, 142 | "extra": Object { 143 | "raw": "'./constants'", 144 | "rawValue": "./constants", 145 | }, 146 | "loc": SourceLocation { 147 | "end": Position { 148 | "column": 45, 149 | "line": 2, 150 | }, 151 | "indent": 0, 152 | "lines": Lines {}, 153 | "start": Position { 154 | "column": 32, 155 | "line": 2, 156 | }, 157 | }, 158 | "regex": null, 159 | "start": 90, 160 | "type": "StringLiteral", 161 | "value": "./constants", 162 | }, 163 | "specifiers": Array [ 164 | Node { 165 | "end": 70, 166 | "id": null, 167 | "importKind": null, 168 | "imported": Node { 169 | "end": 70, 170 | "loc": SourceLocation { 171 | "end": Position { 172 | "column": 12, 173 | "line": 2, 174 | }, 175 | "identifierName": "ONE", 176 | "indent": 0, 177 | "lines": Lines {}, 178 | "start": Position { 179 | "column": 9, 180 | "line": 2, 181 | }, 182 | }, 183 | "name": "ONE", 184 | "start": 67, 185 | "type": "Identifier", 186 | "typeAnnotation": null, 187 | }, 188 | "loc": SourceLocation { 189 | "end": Position { 190 | "column": 12, 191 | "line": 2, 192 | }, 193 | "indent": 0, 194 | "lines": Lines {}, 195 | "start": Position { 196 | "column": 9, 197 | "line": 2, 198 | }, 199 | }, 200 | "local": Node { 201 | "__clone": [Function], 202 | "end": 70, 203 | "loc": SourceLocation { 204 | "end": Position { 205 | "column": 12, 206 | "line": 2, 207 | }, 208 | "identifierName": "ONE", 209 | "indent": 0, 210 | "lines": Lines {}, 211 | "start": Position { 212 | "column": 9, 213 | "line": 2, 214 | }, 215 | }, 216 | "name": "ONE", 217 | "start": 67, 218 | "type": "Identifier", 219 | "typeAnnotation": null, 220 | }, 221 | "name": null, 222 | "start": 67, 223 | "type": "ImportSpecifier", 224 | }, 225 | Node { 226 | "end": 82, 227 | "id": null, 228 | "importKind": null, 229 | "imported": Node { 230 | "end": 82, 231 | "loc": SourceLocation { 232 | "end": Position { 233 | "column": 24, 234 | "line": 2, 235 | }, 236 | "identifierName": "TEST_ENTRY", 237 | "indent": 0, 238 | "lines": Lines {}, 239 | "start": Position { 240 | "column": 14, 241 | "line": 2, 242 | }, 243 | }, 244 | "name": "TEST_ENTRY", 245 | "start": 72, 246 | "type": "Identifier", 247 | "typeAnnotation": null, 248 | }, 249 | "loc": SourceLocation { 250 | "end": Position { 251 | "column": 24, 252 | "line": 2, 253 | }, 254 | "indent": 0, 255 | "lines": Lines {}, 256 | "start": Position { 257 | "column": 14, 258 | "line": 2, 259 | }, 260 | }, 261 | "local": Node { 262 | "__clone": [Function], 263 | "end": 82, 264 | "loc": SourceLocation { 265 | "end": Position { 266 | "column": 24, 267 | "line": 2, 268 | }, 269 | "identifierName": "TEST_ENTRY", 270 | "indent": 0, 271 | "lines": Lines {}, 272 | "start": Position { 273 | "column": 14, 274 | "line": 2, 275 | }, 276 | }, 277 | "name": "TEST_ENTRY", 278 | "start": 72, 279 | "type": "Identifier", 280 | "typeAnnotation": null, 281 | }, 282 | "name": null, 283 | "start": 72, 284 | "type": "ImportSpecifier", 285 | }, 286 | ], 287 | "start": 58, 288 | "type": "ImportDeclaration", 289 | }, 290 | Node { 291 | "async": false, 292 | "body": Node { 293 | "body": Array [ 294 | Node { 295 | "cases": Array [ 296 | Node { 297 | "consequent": Array [ 298 | Node { 299 | "argument": Node { 300 | "end": 242, 301 | "loc": SourceLocation { 302 | "end": Position { 303 | "column": 46, 304 | "line": 6, 305 | }, 306 | "indent": 6, 307 | "lines": Lines {}, 308 | "start": Position { 309 | "column": 13, 310 | "line": 6, 311 | }, 312 | }, 313 | "properties": Array [ 314 | Node { 315 | "argument": Node { 316 | "end": 219, 317 | "loc": SourceLocation { 318 | "end": Position { 319 | "column": 23, 320 | "line": 6, 321 | }, 322 | "identifierName": "state", 323 | "indent": 6, 324 | "lines": Lines {}, 325 | "start": Position { 326 | "column": 18, 327 | "line": 6, 328 | }, 329 | }, 330 | "name": "state", 331 | "start": 214, 332 | "type": "Identifier", 333 | "typeAnnotation": null, 334 | }, 335 | "end": 219, 336 | "loc": SourceLocation { 337 | "end": Position { 338 | "column": 23, 339 | "line": 6, 340 | }, 341 | "indent": 6, 342 | "lines": Lines {}, 343 | "start": Position { 344 | "column": 15, 345 | "line": 6, 346 | }, 347 | }, 348 | "start": 211, 349 | "type": "SpreadProperty", 350 | }, 351 | Node { 352 | "computed": false, 353 | "end": 240, 354 | "key": Node { 355 | "end": 224, 356 | "loc": SourceLocation { 357 | "end": Position { 358 | "column": 28, 359 | "line": 6, 360 | }, 361 | "identifierName": "one", 362 | "indent": 6, 363 | "lines": Lines {}, 364 | "start": Position { 365 | "column": 25, 366 | "line": 6, 367 | }, 368 | }, 369 | "name": "one", 370 | "start": 221, 371 | "type": "Identifier", 372 | "typeAnnotation": null, 373 | }, 374 | "loc": SourceLocation { 375 | "end": Position { 376 | "column": 44, 377 | "line": 6, 378 | }, 379 | "indent": 6, 380 | "lines": Lines {}, 381 | "start": Position { 382 | "column": 25, 383 | "line": 6, 384 | }, 385 | }, 386 | "method": false, 387 | "shorthand": false, 388 | "start": 221, 389 | "type": "ObjectProperty", 390 | "value": Node { 391 | "computed": false, 392 | "end": 240, 393 | "loc": SourceLocation { 394 | "end": Position { 395 | "column": 44, 396 | "line": 6, 397 | }, 398 | "indent": 6, 399 | "lines": Lines {}, 400 | "start": Position { 401 | "column": 30, 402 | "line": 6, 403 | }, 404 | }, 405 | "object": Node { 406 | "end": 232, 407 | "loc": SourceLocation { 408 | "end": Position { 409 | "column": 36, 410 | "line": 6, 411 | }, 412 | "identifierName": "action", 413 | "indent": 6, 414 | "lines": Lines {}, 415 | "start": Position { 416 | "column": 30, 417 | "line": 6, 418 | }, 419 | }, 420 | "name": "action", 421 | "start": 226, 422 | "type": "Identifier", 423 | "typeAnnotation": null, 424 | }, 425 | "property": Node { 426 | "end": 240, 427 | "loc": SourceLocation { 428 | "end": Position { 429 | "column": 44, 430 | "line": 6, 431 | }, 432 | "identifierName": "payload", 433 | "indent": 6, 434 | "lines": Lines {}, 435 | "start": Position { 436 | "column": 37, 437 | "line": 6, 438 | }, 439 | }, 440 | "name": "payload", 441 | "start": 233, 442 | "type": "Identifier", 443 | "typeAnnotation": null, 444 | }, 445 | "start": 226, 446 | "type": "MemberExpression", 447 | }, 448 | }, 449 | ], 450 | "start": 209, 451 | "type": "ObjectExpression", 452 | }, 453 | "end": 243, 454 | "loc": SourceLocation { 455 | "end": Position { 456 | "column": 47, 457 | "line": 6, 458 | }, 459 | "indent": 6, 460 | "lines": Lines {}, 461 | "start": Position { 462 | "column": 6, 463 | "line": 6, 464 | }, 465 | }, 466 | "start": 202, 467 | "type": "ReturnStatement", 468 | }, 469 | ], 470 | "end": 243, 471 | "loc": SourceLocation { 472 | "end": Position { 473 | "column": 47, 474 | "line": 6, 475 | }, 476 | "indent": 4, 477 | "lines": Lines {}, 478 | "start": Position { 479 | "column": 4, 480 | "line": 5, 481 | }, 482 | }, 483 | "start": 186, 484 | "test": Node { 485 | "end": 194, 486 | "loc": SourceLocation { 487 | "end": Position { 488 | "column": 12, 489 | "line": 5, 490 | }, 491 | "identifierName": "ONE", 492 | "indent": 4, 493 | "lines": Lines {}, 494 | "start": Position { 495 | "column": 9, 496 | "line": 5, 497 | }, 498 | }, 499 | "name": "ONE", 500 | "start": 191, 501 | "type": "Identifier", 502 | "typeAnnotation": null, 503 | }, 504 | "type": "SwitchCase", 505 | }, 506 | Object { 507 | "comments": null, 508 | "consequent": Array [ 509 | Object { 510 | "argument": Object { 511 | "comments": null, 512 | "loc": null, 513 | "properties": Array [ 514 | Object { 515 | "argument": Object { 516 | "comments": null, 517 | "loc": null, 518 | "name": "state", 519 | "type": "Identifier", 520 | "typeAnnotation": null, 521 | }, 522 | "comments": null, 523 | "loc": null, 524 | "type": "SpreadProperty", 525 | }, 526 | ], 527 | "type": "ObjectExpression", 528 | }, 529 | "comments": null, 530 | "loc": null, 531 | "type": "ReturnStatement", 532 | }, 533 | ], 534 | "loc": null, 535 | "test": Object { 536 | "comments": null, 537 | "loc": null, 538 | "name": "TEST_ENTRY", 539 | "type": "Identifier", 540 | "typeAnnotation": null, 541 | }, 542 | "type": "SwitchCase", 543 | }, 544 | Node { 545 | "consequent": Array [ 546 | Node { 547 | "argument": Node { 548 | "end": 275, 549 | "loc": SourceLocation { 550 | "end": Position { 551 | "column": 18, 552 | "line": 8, 553 | }, 554 | "identifierName": "state", 555 | "indent": 6, 556 | "lines": Lines {}, 557 | "start": Position { 558 | "column": 13, 559 | "line": 8, 560 | }, 561 | }, 562 | "name": "state", 563 | "start": 270, 564 | "type": "Identifier", 565 | "typeAnnotation": null, 566 | }, 567 | "end": 276, 568 | "loc": SourceLocation { 569 | "end": Position { 570 | "column": 19, 571 | "line": 8, 572 | }, 573 | "indent": 6, 574 | "lines": Lines {}, 575 | "start": Position { 576 | "column": 6, 577 | "line": 8, 578 | }, 579 | }, 580 | "start": 263, 581 | "type": "ReturnStatement", 582 | }, 583 | ], 584 | "end": 276, 585 | "loc": SourceLocation { 586 | "end": Position { 587 | "column": 19, 588 | "line": 8, 589 | }, 590 | "indent": 4, 591 | "lines": Lines {}, 592 | "start": Position { 593 | "column": 4, 594 | "line": 7, 595 | }, 596 | }, 597 | "start": 248, 598 | "test": null, 599 | "type": "SwitchCase", 600 | }, 601 | ], 602 | "discriminant": Node { 603 | "computed": false, 604 | "end": 178, 605 | "loc": SourceLocation { 606 | "end": Position { 607 | "column": 20, 608 | "line": 4, 609 | }, 610 | "indent": 2, 611 | "lines": Lines {}, 612 | "start": Position { 613 | "column": 9, 614 | "line": 4, 615 | }, 616 | }, 617 | "object": Node { 618 | "end": 173, 619 | "loc": SourceLocation { 620 | "end": Position { 621 | "column": 15, 622 | "line": 4, 623 | }, 624 | "identifierName": "action", 625 | "indent": 2, 626 | "lines": Lines {}, 627 | "start": Position { 628 | "column": 9, 629 | "line": 4, 630 | }, 631 | }, 632 | "name": "action", 633 | "start": 167, 634 | "type": "Identifier", 635 | "typeAnnotation": null, 636 | }, 637 | "property": Node { 638 | "end": 178, 639 | "loc": SourceLocation { 640 | "end": Position { 641 | "column": 20, 642 | "line": 4, 643 | }, 644 | "identifierName": "type", 645 | "indent": 2, 646 | "lines": Lines {}, 647 | "start": Position { 648 | "column": 16, 649 | "line": 4, 650 | }, 651 | }, 652 | "name": "type", 653 | "start": 174, 654 | "type": "Identifier", 655 | "typeAnnotation": null, 656 | }, 657 | "start": 167, 658 | "type": "MemberExpression", 659 | }, 660 | "end": 280, 661 | "lexical": false, 662 | "loc": SourceLocation { 663 | "end": Position { 664 | "column": 3, 665 | "line": 9, 666 | }, 667 | "indent": 2, 668 | "lines": Lines {}, 669 | "start": Position { 670 | "column": 2, 671 | "line": 4, 672 | }, 673 | }, 674 | "start": 160, 675 | "type": "SwitchStatement", 676 | }, 677 | ], 678 | "directives": Array [], 679 | "end": 282, 680 | "loc": SourceLocation { 681 | "end": Position { 682 | "column": 1, 683 | "line": 10, 684 | }, 685 | "indent": 0, 686 | "lines": Lines {}, 687 | "start": Position { 688 | "column": 51, 689 | "line": 3, 690 | }, 691 | }, 692 | "start": 156, 693 | "type": "BlockStatement", 694 | }, 695 | "defaults": Array [], 696 | "end": 282, 697 | "expression": false, 698 | "generator": false, 699 | "id": Node { 700 | "end": 125, 701 | "loc": SourceLocation { 702 | "end": Position { 703 | "column": 20, 704 | "line": 3, 705 | }, 706 | "identifierName": "testReducer", 707 | "indent": 0, 708 | "lines": Lines {}, 709 | "start": Position { 710 | "column": 9, 711 | "line": 3, 712 | }, 713 | }, 714 | "name": "testReducer", 715 | "start": 114, 716 | "type": "Identifier", 717 | "typeAnnotation": null, 718 | }, 719 | "loc": SourceLocation { 720 | "end": Position { 721 | "column": 1, 722 | "line": 10, 723 | }, 724 | "indent": 0, 725 | "lines": Lines {}, 726 | "start": Position { 727 | "column": 0, 728 | "line": 3, 729 | }, 730 | }, 731 | "params": Array [ 732 | Node { 733 | "end": 146, 734 | "left": Node { 735 | "end": 131, 736 | "loc": SourceLocation { 737 | "end": Position { 738 | "column": 26, 739 | "line": 3, 740 | }, 741 | "identifierName": "state", 742 | "indent": 0, 743 | "lines": Lines {}, 744 | "start": Position { 745 | "column": 21, 746 | "line": 3, 747 | }, 748 | }, 749 | "name": "state", 750 | "start": 126, 751 | "type": "Identifier", 752 | "typeAnnotation": null, 753 | }, 754 | "loc": SourceLocation { 755 | "end": Position { 756 | "column": 41, 757 | "line": 3, 758 | }, 759 | "indent": 0, 760 | "lines": Lines {}, 761 | "start": Position { 762 | "column": 21, 763 | "line": 3, 764 | }, 765 | }, 766 | "right": Node { 767 | "end": 146, 768 | "loc": SourceLocation { 769 | "end": Position { 770 | "column": 41, 771 | "line": 3, 772 | }, 773 | "identifierName": "initialState", 774 | "indent": 0, 775 | "lines": Lines {}, 776 | "start": Position { 777 | "column": 29, 778 | "line": 3, 779 | }, 780 | }, 781 | "name": "initialState", 782 | "start": 134, 783 | "type": "Identifier", 784 | "typeAnnotation": null, 785 | }, 786 | "start": 126, 787 | "type": "AssignmentPattern", 788 | }, 789 | Node { 790 | "end": 154, 791 | "loc": SourceLocation { 792 | "end": Position { 793 | "column": 49, 794 | "line": 3, 795 | }, 796 | "identifierName": "action", 797 | "indent": 0, 798 | "lines": Lines {}, 799 | "start": Position { 800 | "column": 43, 801 | "line": 3, 802 | }, 803 | }, 804 | "name": "action", 805 | "start": 148, 806 | "type": "Identifier", 807 | "typeAnnotation": null, 808 | }, 809 | ], 810 | "rest": null, 811 | "returnType": null, 812 | "start": 105, 813 | "type": "FunctionDeclaration", 814 | "typeParameters": null, 815 | }, 816 | Node { 817 | "declaration": Node { 818 | "end": 309, 819 | "loc": null, 820 | "name": "testReducer", 821 | "start": 298, 822 | "type": "Identifier", 823 | "typeAnnotation": null, 824 | }, 825 | "end": 309, 826 | "loc": SourceLocation { 827 | "end": Position { 828 | "column": 26, 829 | "line": 11, 830 | }, 831 | "indent": 0, 832 | "lines": Lines {}, 833 | "start": Position { 834 | "column": 0, 835 | "line": 11, 836 | }, 837 | }, 838 | "start": 283, 839 | "type": "ExportDefaultDeclaration", 840 | }, 841 | ], 842 | "directives": Array [], 843 | "end": 309, 844 | "loc": SourceLocation { 845 | "end": Position { 846 | "column": 26, 847 | "line": 11, 848 | }, 849 | "indent": 0, 850 | "lines": Lines {}, 851 | "start": Position { 852 | "column": 0, 853 | "line": 1, 854 | }, 855 | }, 856 | "sourceType": "module", 857 | "start": 0, 858 | "type": "Program", 859 | }, 860 | "start": 0, 861 | "tokens": Array [ 862 | Token { 863 | "end": 6, 864 | "loc": SourceLocation { 865 | "end": Position { 866 | "column": 6, 867 | "line": 1, 868 | }, 869 | "start": Position { 870 | "column": 0, 871 | "line": 1, 872 | }, 873 | }, 874 | "start": 0, 875 | "type": KeywordTokenType { 876 | "beforeExpr": false, 877 | "binop": null, 878 | "isAssign": false, 879 | "isLoop": false, 880 | "keyword": "import", 881 | "label": "import", 882 | "postfix": false, 883 | "prefix": false, 884 | "rightAssociative": false, 885 | "startsExpr": true, 886 | "updateContext": null, 887 | }, 888 | "value": "import", 889 | }, 890 | Token { 891 | "end": 8, 892 | "loc": SourceLocation { 893 | "end": Position { 894 | "column": 8, 895 | "line": 1, 896 | }, 897 | "start": Position { 898 | "column": 7, 899 | "line": 1, 900 | }, 901 | }, 902 | "start": 7, 903 | "type": TokenType { 904 | "beforeExpr": true, 905 | "binop": null, 906 | "isAssign": false, 907 | "isLoop": false, 908 | "keyword": undefined, 909 | "label": "{", 910 | "postfix": false, 911 | "prefix": false, 912 | "rightAssociative": false, 913 | "startsExpr": true, 914 | "updateContext": [Function], 915 | }, 916 | "value": undefined, 917 | }, 918 | Token { 919 | "end": 21, 920 | "loc": SourceLocation { 921 | "end": Position { 922 | "column": 21, 923 | "line": 1, 924 | }, 925 | "start": Position { 926 | "column": 9, 927 | "line": 1, 928 | }, 929 | }, 930 | "start": 9, 931 | "type": TokenType { 932 | "beforeExpr": false, 933 | "binop": null, 934 | "isAssign": false, 935 | "isLoop": false, 936 | "keyword": undefined, 937 | "label": "name", 938 | "postfix": false, 939 | "prefix": false, 940 | "rightAssociative": false, 941 | "startsExpr": true, 942 | "updateContext": [Function], 943 | }, 944 | "value": "createAction", 945 | }, 946 | Token { 947 | "end": 23, 948 | "loc": SourceLocation { 949 | "end": Position { 950 | "column": 23, 951 | "line": 1, 952 | }, 953 | "start": Position { 954 | "column": 22, 955 | "line": 1, 956 | }, 957 | }, 958 | "start": 22, 959 | "type": TokenType { 960 | "beforeExpr": false, 961 | "binop": null, 962 | "isAssign": false, 963 | "isLoop": false, 964 | "keyword": undefined, 965 | "label": "}", 966 | "postfix": false, 967 | "prefix": false, 968 | "rightAssociative": false, 969 | "startsExpr": false, 970 | "updateContext": [Function], 971 | }, 972 | "value": undefined, 973 | }, 974 | Token { 975 | "end": 28, 976 | "loc": SourceLocation { 977 | "end": Position { 978 | "column": 28, 979 | "line": 1, 980 | }, 981 | "start": Position { 982 | "column": 24, 983 | "line": 1, 984 | }, 985 | }, 986 | "start": 24, 987 | "type": TokenType { 988 | "beforeExpr": false, 989 | "binop": null, 990 | "isAssign": false, 991 | "isLoop": false, 992 | "keyword": undefined, 993 | "label": "name", 994 | "postfix": false, 995 | "prefix": false, 996 | "rightAssociative": false, 997 | "startsExpr": true, 998 | "updateContext": [Function], 999 | }, 1000 | "value": "from", 1001 | }, 1002 | Token { 1003 | "end": 56, 1004 | "loc": SourceLocation { 1005 | "end": Position { 1006 | "column": 56, 1007 | "line": 1, 1008 | }, 1009 | "start": Position { 1010 | "column": 29, 1011 | "line": 1, 1012 | }, 1013 | }, 1014 | "start": 29, 1015 | "type": TokenType { 1016 | "beforeExpr": false, 1017 | "binop": null, 1018 | "isAssign": false, 1019 | "isLoop": false, 1020 | "keyword": undefined, 1021 | "label": "string", 1022 | "postfix": false, 1023 | "prefix": false, 1024 | "rightAssociative": false, 1025 | "startsExpr": true, 1026 | "updateContext": null, 1027 | }, 1028 | "value": "redux-boilerplate-helpers", 1029 | }, 1030 | Token { 1031 | "end": 57, 1032 | "loc": SourceLocation { 1033 | "end": Position { 1034 | "column": 57, 1035 | "line": 1, 1036 | }, 1037 | "start": Position { 1038 | "column": 56, 1039 | "line": 1, 1040 | }, 1041 | }, 1042 | "start": 56, 1043 | "type": TokenType { 1044 | "beforeExpr": true, 1045 | "binop": null, 1046 | "isAssign": false, 1047 | "isLoop": false, 1048 | "keyword": undefined, 1049 | "label": ";", 1050 | "postfix": false, 1051 | "prefix": false, 1052 | "rightAssociative": false, 1053 | "startsExpr": false, 1054 | "updateContext": null, 1055 | }, 1056 | "value": undefined, 1057 | }, 1058 | Token { 1059 | "end": 64, 1060 | "loc": SourceLocation { 1061 | "end": Position { 1062 | "column": 6, 1063 | "line": 2, 1064 | }, 1065 | "start": Position { 1066 | "column": 0, 1067 | "line": 2, 1068 | }, 1069 | }, 1070 | "start": 58, 1071 | "type": KeywordTokenType { 1072 | "beforeExpr": false, 1073 | "binop": null, 1074 | "isAssign": false, 1075 | "isLoop": false, 1076 | "keyword": "import", 1077 | "label": "import", 1078 | "postfix": false, 1079 | "prefix": false, 1080 | "rightAssociative": false, 1081 | "startsExpr": true, 1082 | "updateContext": null, 1083 | }, 1084 | "value": "import", 1085 | }, 1086 | Token { 1087 | "end": 66, 1088 | "loc": SourceLocation { 1089 | "end": Position { 1090 | "column": 8, 1091 | "line": 2, 1092 | }, 1093 | "start": Position { 1094 | "column": 7, 1095 | "line": 2, 1096 | }, 1097 | }, 1098 | "start": 65, 1099 | "type": TokenType { 1100 | "beforeExpr": true, 1101 | "binop": null, 1102 | "isAssign": false, 1103 | "isLoop": false, 1104 | "keyword": undefined, 1105 | "label": "{", 1106 | "postfix": false, 1107 | "prefix": false, 1108 | "rightAssociative": false, 1109 | "startsExpr": true, 1110 | "updateContext": [Function], 1111 | }, 1112 | "value": undefined, 1113 | }, 1114 | Token { 1115 | "end": 70, 1116 | "loc": SourceLocation { 1117 | "end": Position { 1118 | "column": 12, 1119 | "line": 2, 1120 | }, 1121 | "start": Position { 1122 | "column": 9, 1123 | "line": 2, 1124 | }, 1125 | }, 1126 | "start": 67, 1127 | "type": TokenType { 1128 | "beforeExpr": false, 1129 | "binop": null, 1130 | "isAssign": false, 1131 | "isLoop": false, 1132 | "keyword": undefined, 1133 | "label": "name", 1134 | "postfix": false, 1135 | "prefix": false, 1136 | "rightAssociative": false, 1137 | "startsExpr": true, 1138 | "updateContext": [Function], 1139 | }, 1140 | "value": "ONE", 1141 | }, 1142 | Token { 1143 | "end": 71, 1144 | "loc": SourceLocation { 1145 | "end": Position { 1146 | "column": 13, 1147 | "line": 2, 1148 | }, 1149 | "start": Position { 1150 | "column": 12, 1151 | "line": 2, 1152 | }, 1153 | }, 1154 | "start": 70, 1155 | "type": TokenType { 1156 | "beforeExpr": true, 1157 | "binop": null, 1158 | "isAssign": false, 1159 | "isLoop": false, 1160 | "keyword": undefined, 1161 | "label": ",", 1162 | "postfix": false, 1163 | "prefix": false, 1164 | "rightAssociative": false, 1165 | "startsExpr": false, 1166 | "updateContext": null, 1167 | }, 1168 | "value": undefined, 1169 | }, 1170 | Token { 1171 | "end": 82, 1172 | "loc": SourceLocation { 1173 | "end": Position { 1174 | "column": 24, 1175 | "line": 2, 1176 | }, 1177 | "start": Position { 1178 | "column": 14, 1179 | "line": 2, 1180 | }, 1181 | }, 1182 | "start": 72, 1183 | "type": TokenType { 1184 | "beforeExpr": false, 1185 | "binop": null, 1186 | "isAssign": false, 1187 | "isLoop": false, 1188 | "keyword": undefined, 1189 | "label": "name", 1190 | "postfix": false, 1191 | "prefix": false, 1192 | "rightAssociative": false, 1193 | "startsExpr": true, 1194 | "updateContext": [Function], 1195 | }, 1196 | "value": "TEST_ENTRY", 1197 | }, 1198 | Token { 1199 | "end": 84, 1200 | "loc": SourceLocation { 1201 | "end": Position { 1202 | "column": 26, 1203 | "line": 2, 1204 | }, 1205 | "start": Position { 1206 | "column": 25, 1207 | "line": 2, 1208 | }, 1209 | }, 1210 | "start": 83, 1211 | "type": TokenType { 1212 | "beforeExpr": false, 1213 | "binop": null, 1214 | "isAssign": false, 1215 | "isLoop": false, 1216 | "keyword": undefined, 1217 | "label": "}", 1218 | "postfix": false, 1219 | "prefix": false, 1220 | "rightAssociative": false, 1221 | "startsExpr": false, 1222 | "updateContext": [Function], 1223 | }, 1224 | "value": undefined, 1225 | }, 1226 | Token { 1227 | "end": 89, 1228 | "loc": SourceLocation { 1229 | "end": Position { 1230 | "column": 31, 1231 | "line": 2, 1232 | }, 1233 | "start": Position { 1234 | "column": 27, 1235 | "line": 2, 1236 | }, 1237 | }, 1238 | "start": 85, 1239 | "type": TokenType { 1240 | "beforeExpr": false, 1241 | "binop": null, 1242 | "isAssign": false, 1243 | "isLoop": false, 1244 | "keyword": undefined, 1245 | "label": "name", 1246 | "postfix": false, 1247 | "prefix": false, 1248 | "rightAssociative": false, 1249 | "startsExpr": true, 1250 | "updateContext": [Function], 1251 | }, 1252 | "value": "from", 1253 | }, 1254 | Token { 1255 | "end": 103, 1256 | "loc": SourceLocation { 1257 | "end": Position { 1258 | "column": 45, 1259 | "line": 2, 1260 | }, 1261 | "start": Position { 1262 | "column": 32, 1263 | "line": 2, 1264 | }, 1265 | }, 1266 | "start": 90, 1267 | "type": TokenType { 1268 | "beforeExpr": false, 1269 | "binop": null, 1270 | "isAssign": false, 1271 | "isLoop": false, 1272 | "keyword": undefined, 1273 | "label": "string", 1274 | "postfix": false, 1275 | "prefix": false, 1276 | "rightAssociative": false, 1277 | "startsExpr": true, 1278 | "updateContext": null, 1279 | }, 1280 | "value": "./constants", 1281 | }, 1282 | Token { 1283 | "end": 104, 1284 | "loc": SourceLocation { 1285 | "end": Position { 1286 | "column": 46, 1287 | "line": 2, 1288 | }, 1289 | "start": Position { 1290 | "column": 45, 1291 | "line": 2, 1292 | }, 1293 | }, 1294 | "start": 103, 1295 | "type": TokenType { 1296 | "beforeExpr": true, 1297 | "binop": null, 1298 | "isAssign": false, 1299 | "isLoop": false, 1300 | "keyword": undefined, 1301 | "label": ";", 1302 | "postfix": false, 1303 | "prefix": false, 1304 | "rightAssociative": false, 1305 | "startsExpr": false, 1306 | "updateContext": null, 1307 | }, 1308 | "value": undefined, 1309 | }, 1310 | Token { 1311 | "end": 113, 1312 | "loc": SourceLocation { 1313 | "end": Position { 1314 | "column": 8, 1315 | "line": 3, 1316 | }, 1317 | "start": Position { 1318 | "column": 0, 1319 | "line": 3, 1320 | }, 1321 | }, 1322 | "start": 105, 1323 | "type": KeywordTokenType { 1324 | "beforeExpr": false, 1325 | "binop": null, 1326 | "isAssign": false, 1327 | "isLoop": false, 1328 | "keyword": "function", 1329 | "label": "function", 1330 | "postfix": false, 1331 | "prefix": false, 1332 | "rightAssociative": false, 1333 | "startsExpr": true, 1334 | "updateContext": [Function], 1335 | }, 1336 | "value": "function", 1337 | }, 1338 | Token { 1339 | "end": 125, 1340 | "loc": SourceLocation { 1341 | "end": Position { 1342 | "column": 20, 1343 | "line": 3, 1344 | }, 1345 | "start": Position { 1346 | "column": 9, 1347 | "line": 3, 1348 | }, 1349 | }, 1350 | "start": 114, 1351 | "type": TokenType { 1352 | "beforeExpr": false, 1353 | "binop": null, 1354 | "isAssign": false, 1355 | "isLoop": false, 1356 | "keyword": undefined, 1357 | "label": "name", 1358 | "postfix": false, 1359 | "prefix": false, 1360 | "rightAssociative": false, 1361 | "startsExpr": true, 1362 | "updateContext": [Function], 1363 | }, 1364 | "value": "testReducer", 1365 | }, 1366 | Token { 1367 | "end": 126, 1368 | "loc": SourceLocation { 1369 | "end": Position { 1370 | "column": 21, 1371 | "line": 3, 1372 | }, 1373 | "start": Position { 1374 | "column": 20, 1375 | "line": 3, 1376 | }, 1377 | }, 1378 | "start": 125, 1379 | "type": TokenType { 1380 | "beforeExpr": true, 1381 | "binop": null, 1382 | "isAssign": false, 1383 | "isLoop": false, 1384 | "keyword": undefined, 1385 | "label": "(", 1386 | "postfix": false, 1387 | "prefix": false, 1388 | "rightAssociative": false, 1389 | "startsExpr": true, 1390 | "updateContext": [Function], 1391 | }, 1392 | "value": undefined, 1393 | }, 1394 | Token { 1395 | "end": 131, 1396 | "loc": SourceLocation { 1397 | "end": Position { 1398 | "column": 26, 1399 | "line": 3, 1400 | }, 1401 | "start": Position { 1402 | "column": 21, 1403 | "line": 3, 1404 | }, 1405 | }, 1406 | "start": 126, 1407 | "type": TokenType { 1408 | "beforeExpr": false, 1409 | "binop": null, 1410 | "isAssign": false, 1411 | "isLoop": false, 1412 | "keyword": undefined, 1413 | "label": "name", 1414 | "postfix": false, 1415 | "prefix": false, 1416 | "rightAssociative": false, 1417 | "startsExpr": true, 1418 | "updateContext": [Function], 1419 | }, 1420 | "value": "state", 1421 | }, 1422 | Token { 1423 | "end": 133, 1424 | "loc": SourceLocation { 1425 | "end": Position { 1426 | "column": 28, 1427 | "line": 3, 1428 | }, 1429 | "start": Position { 1430 | "column": 27, 1431 | "line": 3, 1432 | }, 1433 | }, 1434 | "start": 132, 1435 | "type": TokenType { 1436 | "beforeExpr": true, 1437 | "binop": null, 1438 | "isAssign": true, 1439 | "isLoop": false, 1440 | "keyword": undefined, 1441 | "label": "=", 1442 | "postfix": false, 1443 | "prefix": false, 1444 | "rightAssociative": false, 1445 | "startsExpr": false, 1446 | "updateContext": null, 1447 | }, 1448 | "value": "=", 1449 | }, 1450 | Token { 1451 | "end": 146, 1452 | "loc": SourceLocation { 1453 | "end": Position { 1454 | "column": 41, 1455 | "line": 3, 1456 | }, 1457 | "start": Position { 1458 | "column": 29, 1459 | "line": 3, 1460 | }, 1461 | }, 1462 | "start": 134, 1463 | "type": TokenType { 1464 | "beforeExpr": false, 1465 | "binop": null, 1466 | "isAssign": false, 1467 | "isLoop": false, 1468 | "keyword": undefined, 1469 | "label": "name", 1470 | "postfix": false, 1471 | "prefix": false, 1472 | "rightAssociative": false, 1473 | "startsExpr": true, 1474 | "updateContext": [Function], 1475 | }, 1476 | "value": "initialState", 1477 | }, 1478 | Token { 1479 | "end": 147, 1480 | "loc": SourceLocation { 1481 | "end": Position { 1482 | "column": 42, 1483 | "line": 3, 1484 | }, 1485 | "start": Position { 1486 | "column": 41, 1487 | "line": 3, 1488 | }, 1489 | }, 1490 | "start": 146, 1491 | "type": TokenType { 1492 | "beforeExpr": true, 1493 | "binop": null, 1494 | "isAssign": false, 1495 | "isLoop": false, 1496 | "keyword": undefined, 1497 | "label": ",", 1498 | "postfix": false, 1499 | "prefix": false, 1500 | "rightAssociative": false, 1501 | "startsExpr": false, 1502 | "updateContext": null, 1503 | }, 1504 | "value": undefined, 1505 | }, 1506 | Token { 1507 | "end": 154, 1508 | "loc": SourceLocation { 1509 | "end": Position { 1510 | "column": 49, 1511 | "line": 3, 1512 | }, 1513 | "start": Position { 1514 | "column": 43, 1515 | "line": 3, 1516 | }, 1517 | }, 1518 | "start": 148, 1519 | "type": TokenType { 1520 | "beforeExpr": false, 1521 | "binop": null, 1522 | "isAssign": false, 1523 | "isLoop": false, 1524 | "keyword": undefined, 1525 | "label": "name", 1526 | "postfix": false, 1527 | "prefix": false, 1528 | "rightAssociative": false, 1529 | "startsExpr": true, 1530 | "updateContext": [Function], 1531 | }, 1532 | "value": "action", 1533 | }, 1534 | Token { 1535 | "end": 155, 1536 | "loc": SourceLocation { 1537 | "end": Position { 1538 | "column": 50, 1539 | "line": 3, 1540 | }, 1541 | "start": Position { 1542 | "column": 49, 1543 | "line": 3, 1544 | }, 1545 | }, 1546 | "start": 154, 1547 | "type": TokenType { 1548 | "beforeExpr": false, 1549 | "binop": null, 1550 | "isAssign": false, 1551 | "isLoop": false, 1552 | "keyword": undefined, 1553 | "label": ")", 1554 | "postfix": false, 1555 | "prefix": false, 1556 | "rightAssociative": false, 1557 | "startsExpr": false, 1558 | "updateContext": [Function], 1559 | }, 1560 | "value": undefined, 1561 | }, 1562 | Token { 1563 | "end": 157, 1564 | "loc": SourceLocation { 1565 | "end": Position { 1566 | "column": 52, 1567 | "line": 3, 1568 | }, 1569 | "start": Position { 1570 | "column": 51, 1571 | "line": 3, 1572 | }, 1573 | }, 1574 | "start": 156, 1575 | "type": TokenType { 1576 | "beforeExpr": true, 1577 | "binop": null, 1578 | "isAssign": false, 1579 | "isLoop": false, 1580 | "keyword": undefined, 1581 | "label": "{", 1582 | "postfix": false, 1583 | "prefix": false, 1584 | "rightAssociative": false, 1585 | "startsExpr": true, 1586 | "updateContext": [Function], 1587 | }, 1588 | "value": undefined, 1589 | }, 1590 | Token { 1591 | "end": 166, 1592 | "loc": SourceLocation { 1593 | "end": Position { 1594 | "column": 8, 1595 | "line": 4, 1596 | }, 1597 | "start": Position { 1598 | "column": 2, 1599 | "line": 4, 1600 | }, 1601 | }, 1602 | "start": 160, 1603 | "type": KeywordTokenType { 1604 | "beforeExpr": false, 1605 | "binop": null, 1606 | "isAssign": false, 1607 | "isLoop": false, 1608 | "keyword": "switch", 1609 | "label": "switch", 1610 | "postfix": false, 1611 | "prefix": false, 1612 | "rightAssociative": false, 1613 | "startsExpr": false, 1614 | "updateContext": null, 1615 | }, 1616 | "value": "switch", 1617 | }, 1618 | Token { 1619 | "end": 167, 1620 | "loc": SourceLocation { 1621 | "end": Position { 1622 | "column": 9, 1623 | "line": 4, 1624 | }, 1625 | "start": Position { 1626 | "column": 8, 1627 | "line": 4, 1628 | }, 1629 | }, 1630 | "start": 166, 1631 | "type": TokenType { 1632 | "beforeExpr": true, 1633 | "binop": null, 1634 | "isAssign": false, 1635 | "isLoop": false, 1636 | "keyword": undefined, 1637 | "label": "(", 1638 | "postfix": false, 1639 | "prefix": false, 1640 | "rightAssociative": false, 1641 | "startsExpr": true, 1642 | "updateContext": [Function], 1643 | }, 1644 | "value": undefined, 1645 | }, 1646 | Token { 1647 | "end": 173, 1648 | "loc": SourceLocation { 1649 | "end": Position { 1650 | "column": 15, 1651 | "line": 4, 1652 | }, 1653 | "start": Position { 1654 | "column": 9, 1655 | "line": 4, 1656 | }, 1657 | }, 1658 | "start": 167, 1659 | "type": TokenType { 1660 | "beforeExpr": false, 1661 | "binop": null, 1662 | "isAssign": false, 1663 | "isLoop": false, 1664 | "keyword": undefined, 1665 | "label": "name", 1666 | "postfix": false, 1667 | "prefix": false, 1668 | "rightAssociative": false, 1669 | "startsExpr": true, 1670 | "updateContext": [Function], 1671 | }, 1672 | "value": "action", 1673 | }, 1674 | Token { 1675 | "end": 174, 1676 | "loc": SourceLocation { 1677 | "end": Position { 1678 | "column": 16, 1679 | "line": 4, 1680 | }, 1681 | "start": Position { 1682 | "column": 15, 1683 | "line": 4, 1684 | }, 1685 | }, 1686 | "start": 173, 1687 | "type": TokenType { 1688 | "beforeExpr": false, 1689 | "binop": null, 1690 | "isAssign": false, 1691 | "isLoop": false, 1692 | "keyword": undefined, 1693 | "label": ".", 1694 | "postfix": false, 1695 | "prefix": false, 1696 | "rightAssociative": false, 1697 | "startsExpr": false, 1698 | "updateContext": null, 1699 | }, 1700 | "value": undefined, 1701 | }, 1702 | Token { 1703 | "end": 178, 1704 | "loc": SourceLocation { 1705 | "end": Position { 1706 | "column": 20, 1707 | "line": 4, 1708 | }, 1709 | "start": Position { 1710 | "column": 16, 1711 | "line": 4, 1712 | }, 1713 | }, 1714 | "start": 174, 1715 | "type": TokenType { 1716 | "beforeExpr": false, 1717 | "binop": null, 1718 | "isAssign": false, 1719 | "isLoop": false, 1720 | "keyword": undefined, 1721 | "label": "name", 1722 | "postfix": false, 1723 | "prefix": false, 1724 | "rightAssociative": false, 1725 | "startsExpr": true, 1726 | "updateContext": [Function], 1727 | }, 1728 | "value": "type", 1729 | }, 1730 | Token { 1731 | "end": 179, 1732 | "loc": SourceLocation { 1733 | "end": Position { 1734 | "column": 21, 1735 | "line": 4, 1736 | }, 1737 | "start": Position { 1738 | "column": 20, 1739 | "line": 4, 1740 | }, 1741 | }, 1742 | "start": 178, 1743 | "type": TokenType { 1744 | "beforeExpr": false, 1745 | "binop": null, 1746 | "isAssign": false, 1747 | "isLoop": false, 1748 | "keyword": undefined, 1749 | "label": ")", 1750 | "postfix": false, 1751 | "prefix": false, 1752 | "rightAssociative": false, 1753 | "startsExpr": false, 1754 | "updateContext": [Function], 1755 | }, 1756 | "value": undefined, 1757 | }, 1758 | Token { 1759 | "end": 181, 1760 | "loc": SourceLocation { 1761 | "end": Position { 1762 | "column": 23, 1763 | "line": 4, 1764 | }, 1765 | "start": Position { 1766 | "column": 22, 1767 | "line": 4, 1768 | }, 1769 | }, 1770 | "start": 180, 1771 | "type": TokenType { 1772 | "beforeExpr": true, 1773 | "binop": null, 1774 | "isAssign": false, 1775 | "isLoop": false, 1776 | "keyword": undefined, 1777 | "label": "{", 1778 | "postfix": false, 1779 | "prefix": false, 1780 | "rightAssociative": false, 1781 | "startsExpr": true, 1782 | "updateContext": [Function], 1783 | }, 1784 | "value": undefined, 1785 | }, 1786 | Token { 1787 | "end": 190, 1788 | "loc": SourceLocation { 1789 | "end": Position { 1790 | "column": 8, 1791 | "line": 5, 1792 | }, 1793 | "start": Position { 1794 | "column": 4, 1795 | "line": 5, 1796 | }, 1797 | }, 1798 | "start": 186, 1799 | "type": KeywordTokenType { 1800 | "beforeExpr": true, 1801 | "binop": null, 1802 | "isAssign": false, 1803 | "isLoop": false, 1804 | "keyword": "case", 1805 | "label": "case", 1806 | "postfix": false, 1807 | "prefix": false, 1808 | "rightAssociative": false, 1809 | "startsExpr": false, 1810 | "updateContext": null, 1811 | }, 1812 | "value": "case", 1813 | }, 1814 | Token { 1815 | "end": 194, 1816 | "loc": SourceLocation { 1817 | "end": Position { 1818 | "column": 12, 1819 | "line": 5, 1820 | }, 1821 | "start": Position { 1822 | "column": 9, 1823 | "line": 5, 1824 | }, 1825 | }, 1826 | "start": 191, 1827 | "type": TokenType { 1828 | "beforeExpr": false, 1829 | "binop": null, 1830 | "isAssign": false, 1831 | "isLoop": false, 1832 | "keyword": undefined, 1833 | "label": "name", 1834 | "postfix": false, 1835 | "prefix": false, 1836 | "rightAssociative": false, 1837 | "startsExpr": true, 1838 | "updateContext": [Function], 1839 | }, 1840 | "value": "ONE", 1841 | }, 1842 | Token { 1843 | "end": 195, 1844 | "loc": SourceLocation { 1845 | "end": Position { 1846 | "column": 13, 1847 | "line": 5, 1848 | }, 1849 | "start": Position { 1850 | "column": 12, 1851 | "line": 5, 1852 | }, 1853 | }, 1854 | "start": 194, 1855 | "type": TokenType { 1856 | "beforeExpr": true, 1857 | "binop": null, 1858 | "isAssign": false, 1859 | "isLoop": false, 1860 | "keyword": undefined, 1861 | "label": ":", 1862 | "postfix": false, 1863 | "prefix": false, 1864 | "rightAssociative": false, 1865 | "startsExpr": false, 1866 | "updateContext": null, 1867 | }, 1868 | "value": undefined, 1869 | }, 1870 | Token { 1871 | "end": 208, 1872 | "loc": SourceLocation { 1873 | "end": Position { 1874 | "column": 12, 1875 | "line": 6, 1876 | }, 1877 | "start": Position { 1878 | "column": 6, 1879 | "line": 6, 1880 | }, 1881 | }, 1882 | "start": 202, 1883 | "type": KeywordTokenType { 1884 | "beforeExpr": true, 1885 | "binop": null, 1886 | "isAssign": false, 1887 | "isLoop": false, 1888 | "keyword": "return", 1889 | "label": "return", 1890 | "postfix": false, 1891 | "prefix": false, 1892 | "rightAssociative": false, 1893 | "startsExpr": false, 1894 | "updateContext": null, 1895 | }, 1896 | "value": "return", 1897 | }, 1898 | Token { 1899 | "end": 210, 1900 | "loc": SourceLocation { 1901 | "end": Position { 1902 | "column": 14, 1903 | "line": 6, 1904 | }, 1905 | "start": Position { 1906 | "column": 13, 1907 | "line": 6, 1908 | }, 1909 | }, 1910 | "start": 209, 1911 | "type": TokenType { 1912 | "beforeExpr": true, 1913 | "binop": null, 1914 | "isAssign": false, 1915 | "isLoop": false, 1916 | "keyword": undefined, 1917 | "label": "{", 1918 | "postfix": false, 1919 | "prefix": false, 1920 | "rightAssociative": false, 1921 | "startsExpr": true, 1922 | "updateContext": [Function], 1923 | }, 1924 | "value": undefined, 1925 | }, 1926 | Token { 1927 | "end": 214, 1928 | "loc": SourceLocation { 1929 | "end": Position { 1930 | "column": 18, 1931 | "line": 6, 1932 | }, 1933 | "start": Position { 1934 | "column": 15, 1935 | "line": 6, 1936 | }, 1937 | }, 1938 | "start": 211, 1939 | "type": TokenType { 1940 | "beforeExpr": true, 1941 | "binop": null, 1942 | "isAssign": false, 1943 | "isLoop": false, 1944 | "keyword": undefined, 1945 | "label": "...", 1946 | "postfix": false, 1947 | "prefix": false, 1948 | "rightAssociative": false, 1949 | "startsExpr": false, 1950 | "updateContext": null, 1951 | }, 1952 | "value": undefined, 1953 | }, 1954 | Token { 1955 | "end": 219, 1956 | "loc": SourceLocation { 1957 | "end": Position { 1958 | "column": 23, 1959 | "line": 6, 1960 | }, 1961 | "start": Position { 1962 | "column": 18, 1963 | "line": 6, 1964 | }, 1965 | }, 1966 | "start": 214, 1967 | "type": TokenType { 1968 | "beforeExpr": false, 1969 | "binop": null, 1970 | "isAssign": false, 1971 | "isLoop": false, 1972 | "keyword": undefined, 1973 | "label": "name", 1974 | "postfix": false, 1975 | "prefix": false, 1976 | "rightAssociative": false, 1977 | "startsExpr": true, 1978 | "updateContext": [Function], 1979 | }, 1980 | "value": "state", 1981 | }, 1982 | Token { 1983 | "end": 220, 1984 | "loc": SourceLocation { 1985 | "end": Position { 1986 | "column": 24, 1987 | "line": 6, 1988 | }, 1989 | "start": Position { 1990 | "column": 23, 1991 | "line": 6, 1992 | }, 1993 | }, 1994 | "start": 219, 1995 | "type": TokenType { 1996 | "beforeExpr": true, 1997 | "binop": null, 1998 | "isAssign": false, 1999 | "isLoop": false, 2000 | "keyword": undefined, 2001 | "label": ",", 2002 | "postfix": false, 2003 | "prefix": false, 2004 | "rightAssociative": false, 2005 | "startsExpr": false, 2006 | "updateContext": null, 2007 | }, 2008 | "value": undefined, 2009 | }, 2010 | Token { 2011 | "end": 224, 2012 | "loc": SourceLocation { 2013 | "end": Position { 2014 | "column": 28, 2015 | "line": 6, 2016 | }, 2017 | "start": Position { 2018 | "column": 25, 2019 | "line": 6, 2020 | }, 2021 | }, 2022 | "start": 221, 2023 | "type": TokenType { 2024 | "beforeExpr": false, 2025 | "binop": null, 2026 | "isAssign": false, 2027 | "isLoop": false, 2028 | "keyword": undefined, 2029 | "label": "name", 2030 | "postfix": false, 2031 | "prefix": false, 2032 | "rightAssociative": false, 2033 | "startsExpr": true, 2034 | "updateContext": [Function], 2035 | }, 2036 | "value": "one", 2037 | }, 2038 | Token { 2039 | "end": 225, 2040 | "loc": SourceLocation { 2041 | "end": Position { 2042 | "column": 29, 2043 | "line": 6, 2044 | }, 2045 | "start": Position { 2046 | "column": 28, 2047 | "line": 6, 2048 | }, 2049 | }, 2050 | "start": 224, 2051 | "type": TokenType { 2052 | "beforeExpr": true, 2053 | "binop": null, 2054 | "isAssign": false, 2055 | "isLoop": false, 2056 | "keyword": undefined, 2057 | "label": ":", 2058 | "postfix": false, 2059 | "prefix": false, 2060 | "rightAssociative": false, 2061 | "startsExpr": false, 2062 | "updateContext": null, 2063 | }, 2064 | "value": undefined, 2065 | }, 2066 | Token { 2067 | "end": 232, 2068 | "loc": SourceLocation { 2069 | "end": Position { 2070 | "column": 36, 2071 | "line": 6, 2072 | }, 2073 | "start": Position { 2074 | "column": 30, 2075 | "line": 6, 2076 | }, 2077 | }, 2078 | "start": 226, 2079 | "type": TokenType { 2080 | "beforeExpr": false, 2081 | "binop": null, 2082 | "isAssign": false, 2083 | "isLoop": false, 2084 | "keyword": undefined, 2085 | "label": "name", 2086 | "postfix": false, 2087 | "prefix": false, 2088 | "rightAssociative": false, 2089 | "startsExpr": true, 2090 | "updateContext": [Function], 2091 | }, 2092 | "value": "action", 2093 | }, 2094 | Token { 2095 | "end": 233, 2096 | "loc": SourceLocation { 2097 | "end": Position { 2098 | "column": 37, 2099 | "line": 6, 2100 | }, 2101 | "start": Position { 2102 | "column": 36, 2103 | "line": 6, 2104 | }, 2105 | }, 2106 | "start": 232, 2107 | "type": TokenType { 2108 | "beforeExpr": false, 2109 | "binop": null, 2110 | "isAssign": false, 2111 | "isLoop": false, 2112 | "keyword": undefined, 2113 | "label": ".", 2114 | "postfix": false, 2115 | "prefix": false, 2116 | "rightAssociative": false, 2117 | "startsExpr": false, 2118 | "updateContext": null, 2119 | }, 2120 | "value": undefined, 2121 | }, 2122 | Token { 2123 | "end": 240, 2124 | "loc": SourceLocation { 2125 | "end": Position { 2126 | "column": 44, 2127 | "line": 6, 2128 | }, 2129 | "start": Position { 2130 | "column": 37, 2131 | "line": 6, 2132 | }, 2133 | }, 2134 | "start": 233, 2135 | "type": TokenType { 2136 | "beforeExpr": false, 2137 | "binop": null, 2138 | "isAssign": false, 2139 | "isLoop": false, 2140 | "keyword": undefined, 2141 | "label": "name", 2142 | "postfix": false, 2143 | "prefix": false, 2144 | "rightAssociative": false, 2145 | "startsExpr": true, 2146 | "updateContext": [Function], 2147 | }, 2148 | "value": "payload", 2149 | }, 2150 | Token { 2151 | "end": 242, 2152 | "loc": SourceLocation { 2153 | "end": Position { 2154 | "column": 46, 2155 | "line": 6, 2156 | }, 2157 | "start": Position { 2158 | "column": 45, 2159 | "line": 6, 2160 | }, 2161 | }, 2162 | "start": 241, 2163 | "type": TokenType { 2164 | "beforeExpr": false, 2165 | "binop": null, 2166 | "isAssign": false, 2167 | "isLoop": false, 2168 | "keyword": undefined, 2169 | "label": "}", 2170 | "postfix": false, 2171 | "prefix": false, 2172 | "rightAssociative": false, 2173 | "startsExpr": false, 2174 | "updateContext": [Function], 2175 | }, 2176 | "value": undefined, 2177 | }, 2178 | Token { 2179 | "end": 243, 2180 | "loc": SourceLocation { 2181 | "end": Position { 2182 | "column": 47, 2183 | "line": 6, 2184 | }, 2185 | "start": Position { 2186 | "column": 46, 2187 | "line": 6, 2188 | }, 2189 | }, 2190 | "start": 242, 2191 | "type": TokenType { 2192 | "beforeExpr": true, 2193 | "binop": null, 2194 | "isAssign": false, 2195 | "isLoop": false, 2196 | "keyword": undefined, 2197 | "label": ";", 2198 | "postfix": false, 2199 | "prefix": false, 2200 | "rightAssociative": false, 2201 | "startsExpr": false, 2202 | "updateContext": null, 2203 | }, 2204 | "value": undefined, 2205 | }, 2206 | Token { 2207 | "end": 255, 2208 | "loc": SourceLocation { 2209 | "end": Position { 2210 | "column": 11, 2211 | "line": 7, 2212 | }, 2213 | "start": Position { 2214 | "column": 4, 2215 | "line": 7, 2216 | }, 2217 | }, 2218 | "start": 248, 2219 | "type": KeywordTokenType { 2220 | "beforeExpr": true, 2221 | "binop": null, 2222 | "isAssign": false, 2223 | "isLoop": false, 2224 | "keyword": "default", 2225 | "label": "default", 2226 | "postfix": false, 2227 | "prefix": false, 2228 | "rightAssociative": false, 2229 | "startsExpr": false, 2230 | "updateContext": null, 2231 | }, 2232 | "value": "default", 2233 | }, 2234 | Token { 2235 | "end": 256, 2236 | "loc": SourceLocation { 2237 | "end": Position { 2238 | "column": 12, 2239 | "line": 7, 2240 | }, 2241 | "start": Position { 2242 | "column": 11, 2243 | "line": 7, 2244 | }, 2245 | }, 2246 | "start": 255, 2247 | "type": TokenType { 2248 | "beforeExpr": true, 2249 | "binop": null, 2250 | "isAssign": false, 2251 | "isLoop": false, 2252 | "keyword": undefined, 2253 | "label": ":", 2254 | "postfix": false, 2255 | "prefix": false, 2256 | "rightAssociative": false, 2257 | "startsExpr": false, 2258 | "updateContext": null, 2259 | }, 2260 | "value": undefined, 2261 | }, 2262 | Token { 2263 | "end": 269, 2264 | "loc": SourceLocation { 2265 | "end": Position { 2266 | "column": 12, 2267 | "line": 8, 2268 | }, 2269 | "start": Position { 2270 | "column": 6, 2271 | "line": 8, 2272 | }, 2273 | }, 2274 | "start": 263, 2275 | "type": KeywordTokenType { 2276 | "beforeExpr": true, 2277 | "binop": null, 2278 | "isAssign": false, 2279 | "isLoop": false, 2280 | "keyword": "return", 2281 | "label": "return", 2282 | "postfix": false, 2283 | "prefix": false, 2284 | "rightAssociative": false, 2285 | "startsExpr": false, 2286 | "updateContext": null, 2287 | }, 2288 | "value": "return", 2289 | }, 2290 | Token { 2291 | "end": 275, 2292 | "loc": SourceLocation { 2293 | "end": Position { 2294 | "column": 18, 2295 | "line": 8, 2296 | }, 2297 | "start": Position { 2298 | "column": 13, 2299 | "line": 8, 2300 | }, 2301 | }, 2302 | "start": 270, 2303 | "type": TokenType { 2304 | "beforeExpr": false, 2305 | "binop": null, 2306 | "isAssign": false, 2307 | "isLoop": false, 2308 | "keyword": undefined, 2309 | "label": "name", 2310 | "postfix": false, 2311 | "prefix": false, 2312 | "rightAssociative": false, 2313 | "startsExpr": true, 2314 | "updateContext": [Function], 2315 | }, 2316 | "value": "state", 2317 | }, 2318 | Token { 2319 | "end": 276, 2320 | "loc": SourceLocation { 2321 | "end": Position { 2322 | "column": 19, 2323 | "line": 8, 2324 | }, 2325 | "start": Position { 2326 | "column": 18, 2327 | "line": 8, 2328 | }, 2329 | }, 2330 | "start": 275, 2331 | "type": TokenType { 2332 | "beforeExpr": true, 2333 | "binop": null, 2334 | "isAssign": false, 2335 | "isLoop": false, 2336 | "keyword": undefined, 2337 | "label": ";", 2338 | "postfix": false, 2339 | "prefix": false, 2340 | "rightAssociative": false, 2341 | "startsExpr": false, 2342 | "updateContext": null, 2343 | }, 2344 | "value": undefined, 2345 | }, 2346 | Token { 2347 | "end": 280, 2348 | "loc": SourceLocation { 2349 | "end": Position { 2350 | "column": 3, 2351 | "line": 9, 2352 | }, 2353 | "start": Position { 2354 | "column": 2, 2355 | "line": 9, 2356 | }, 2357 | }, 2358 | "start": 279, 2359 | "type": TokenType { 2360 | "beforeExpr": false, 2361 | "binop": null, 2362 | "isAssign": false, 2363 | "isLoop": false, 2364 | "keyword": undefined, 2365 | "label": "}", 2366 | "postfix": false, 2367 | "prefix": false, 2368 | "rightAssociative": false, 2369 | "startsExpr": false, 2370 | "updateContext": [Function], 2371 | }, 2372 | "value": undefined, 2373 | }, 2374 | Token { 2375 | "end": 282, 2376 | "loc": SourceLocation { 2377 | "end": Position { 2378 | "column": 1, 2379 | "line": 10, 2380 | }, 2381 | "start": Position { 2382 | "column": 0, 2383 | "line": 10, 2384 | }, 2385 | }, 2386 | "start": 281, 2387 | "type": TokenType { 2388 | "beforeExpr": false, 2389 | "binop": null, 2390 | "isAssign": false, 2391 | "isLoop": false, 2392 | "keyword": undefined, 2393 | "label": "}", 2394 | "postfix": false, 2395 | "prefix": false, 2396 | "rightAssociative": false, 2397 | "startsExpr": false, 2398 | "updateContext": [Function], 2399 | }, 2400 | "value": undefined, 2401 | }, 2402 | Token { 2403 | "end": 289, 2404 | "loc": SourceLocation { 2405 | "end": Position { 2406 | "column": 6, 2407 | "line": 11, 2408 | }, 2409 | "start": Position { 2410 | "column": 0, 2411 | "line": 11, 2412 | }, 2413 | }, 2414 | "start": 283, 2415 | "type": KeywordTokenType { 2416 | "beforeExpr": false, 2417 | "binop": null, 2418 | "isAssign": false, 2419 | "isLoop": false, 2420 | "keyword": "export", 2421 | "label": "export", 2422 | "postfix": false, 2423 | "prefix": false, 2424 | "rightAssociative": false, 2425 | "startsExpr": false, 2426 | "updateContext": null, 2427 | }, 2428 | "value": "export", 2429 | }, 2430 | Token { 2431 | "end": 297, 2432 | "loc": SourceLocation { 2433 | "end": Position { 2434 | "column": 14, 2435 | "line": 11, 2436 | }, 2437 | "start": Position { 2438 | "column": 7, 2439 | "line": 11, 2440 | }, 2441 | }, 2442 | "start": 290, 2443 | "type": KeywordTokenType { 2444 | "beforeExpr": true, 2445 | "binop": null, 2446 | "isAssign": false, 2447 | "isLoop": false, 2448 | "keyword": "default", 2449 | "label": "default", 2450 | "postfix": false, 2451 | "prefix": false, 2452 | "rightAssociative": false, 2453 | "startsExpr": false, 2454 | "updateContext": null, 2455 | }, 2456 | "value": "default", 2457 | }, 2458 | Token { 2459 | "end": 309, 2460 | "loc": SourceLocation { 2461 | "end": Position { 2462 | "column": 26, 2463 | "line": 11, 2464 | }, 2465 | "start": Position { 2466 | "column": 15, 2467 | "line": 11, 2468 | }, 2469 | }, 2470 | "start": 298, 2471 | "type": TokenType { 2472 | "beforeExpr": false, 2473 | "binop": null, 2474 | "isAssign": false, 2475 | "isLoop": false, 2476 | "keyword": undefined, 2477 | "label": "name", 2478 | "postfix": false, 2479 | "prefix": false, 2480 | "rightAssociative": false, 2481 | "startsExpr": true, 2482 | "updateContext": [Function], 2483 | }, 2484 | "value": "testReducer", 2485 | }, 2486 | Token { 2487 | "end": 309, 2488 | "loc": SourceLocation { 2489 | "end": Position { 2490 | "column": 26, 2491 | "line": 11, 2492 | }, 2493 | "start": Position { 2494 | "column": 26, 2495 | "line": 11, 2496 | }, 2497 | }, 2498 | "start": 309, 2499 | "type": TokenType { 2500 | "beforeExpr": false, 2501 | "binop": null, 2502 | "isAssign": false, 2503 | "isLoop": false, 2504 | "keyword": undefined, 2505 | "label": "eof", 2506 | "postfix": false, 2507 | "prefix": false, 2508 | "rightAssociative": false, 2509 | "startsExpr": false, 2510 | "updateContext": null, 2511 | }, 2512 | "value": undefined, 2513 | }, 2514 | ], 2515 | "type": "File", 2516 | } 2517 | `; 2518 | 2519 | exports[`createAction Reducer Case creates an entry for the action handler at the end 1`] = ` 2520 | Node { 2521 | "end": 276, 2522 | "loc": SourceLocation { 2523 | "end": Object { 2524 | "column": 26, 2525 | "line": 9, 2526 | }, 2527 | "indent": 0, 2528 | "lines": Lines {}, 2529 | "start": Object { 2530 | "column": 0, 2531 | "line": 1, 2532 | }, 2533 | }, 2534 | "name": null, 2535 | "program": Node { 2536 | "body": Array [ 2537 | Node { 2538 | "end": 57, 2539 | "importKind": "value", 2540 | "loc": SourceLocation { 2541 | "end": Position { 2542 | "column": 57, 2543 | "line": 1, 2544 | }, 2545 | "indent": 0, 2546 | "lines": Lines {}, 2547 | "start": Position { 2548 | "column": 0, 2549 | "line": 1, 2550 | }, 2551 | }, 2552 | "source": Node { 2553 | "end": 56, 2554 | "extra": Object { 2555 | "raw": "\\"redux-boilerplate-helpers\\"", 2556 | "rawValue": "redux-boilerplate-helpers", 2557 | }, 2558 | "loc": SourceLocation { 2559 | "end": Position { 2560 | "column": 56, 2561 | "line": 1, 2562 | }, 2563 | "indent": 0, 2564 | "lines": Lines {}, 2565 | "start": Position { 2566 | "column": 29, 2567 | "line": 1, 2568 | }, 2569 | }, 2570 | "regex": null, 2571 | "start": 29, 2572 | "type": "StringLiteral", 2573 | "value": "redux-boilerplate-helpers", 2574 | }, 2575 | "specifiers": Array [ 2576 | Node { 2577 | "end": 21, 2578 | "id": null, 2579 | "importKind": null, 2580 | "imported": Node { 2581 | "end": 21, 2582 | "loc": SourceLocation { 2583 | "end": Position { 2584 | "column": 21, 2585 | "line": 1, 2586 | }, 2587 | "identifierName": "createAction", 2588 | "indent": 0, 2589 | "lines": Lines {}, 2590 | "start": Position { 2591 | "column": 9, 2592 | "line": 1, 2593 | }, 2594 | }, 2595 | "name": "createAction", 2596 | "start": 9, 2597 | "type": "Identifier", 2598 | "typeAnnotation": null, 2599 | }, 2600 | "loc": SourceLocation { 2601 | "end": Position { 2602 | "column": 21, 2603 | "line": 1, 2604 | }, 2605 | "indent": 0, 2606 | "lines": Lines {}, 2607 | "start": Position { 2608 | "column": 9, 2609 | "line": 1, 2610 | }, 2611 | }, 2612 | "local": Node { 2613 | "__clone": [Function], 2614 | "end": 21, 2615 | "loc": SourceLocation { 2616 | "end": Position { 2617 | "column": 21, 2618 | "line": 1, 2619 | }, 2620 | "identifierName": "createAction", 2621 | "indent": 0, 2622 | "lines": Lines {}, 2623 | "start": Position { 2624 | "column": 9, 2625 | "line": 1, 2626 | }, 2627 | }, 2628 | "name": "createAction", 2629 | "start": 9, 2630 | "type": "Identifier", 2631 | "typeAnnotation": null, 2632 | }, 2633 | "name": null, 2634 | "start": 9, 2635 | "type": "ImportSpecifier", 2636 | }, 2637 | ], 2638 | "start": 0, 2639 | "type": "ImportDeclaration", 2640 | }, 2641 | Node { 2642 | "end": 104, 2643 | "importKind": "value", 2644 | "loc": SourceLocation { 2645 | "end": Position { 2646 | "column": 46, 2647 | "line": 2, 2648 | }, 2649 | "indent": 0, 2650 | "lines": Lines {}, 2651 | "start": Position { 2652 | "column": 0, 2653 | "line": 2, 2654 | }, 2655 | }, 2656 | "source": Node { 2657 | "end": 103, 2658 | "extra": Object { 2659 | "raw": "'./constants'", 2660 | "rawValue": "./constants", 2661 | }, 2662 | "loc": SourceLocation { 2663 | "end": Position { 2664 | "column": 45, 2665 | "line": 2, 2666 | }, 2667 | "indent": 0, 2668 | "lines": Lines {}, 2669 | "start": Position { 2670 | "column": 32, 2671 | "line": 2, 2672 | }, 2673 | }, 2674 | "regex": null, 2675 | "start": 90, 2676 | "type": "StringLiteral", 2677 | "value": "./constants", 2678 | }, 2679 | "specifiers": Array [ 2680 | Node { 2681 | "end": 70, 2682 | "id": null, 2683 | "importKind": null, 2684 | "imported": Node { 2685 | "end": 70, 2686 | "loc": SourceLocation { 2687 | "end": Position { 2688 | "column": 12, 2689 | "line": 2, 2690 | }, 2691 | "identifierName": "ONE", 2692 | "indent": 0, 2693 | "lines": Lines {}, 2694 | "start": Position { 2695 | "column": 9, 2696 | "line": 2, 2697 | }, 2698 | }, 2699 | "name": "ONE", 2700 | "start": 67, 2701 | "type": "Identifier", 2702 | "typeAnnotation": null, 2703 | }, 2704 | "loc": SourceLocation { 2705 | "end": Position { 2706 | "column": 12, 2707 | "line": 2, 2708 | }, 2709 | "indent": 0, 2710 | "lines": Lines {}, 2711 | "start": Position { 2712 | "column": 9, 2713 | "line": 2, 2714 | }, 2715 | }, 2716 | "local": Node { 2717 | "__clone": [Function], 2718 | "end": 70, 2719 | "loc": SourceLocation { 2720 | "end": Position { 2721 | "column": 12, 2722 | "line": 2, 2723 | }, 2724 | "identifierName": "ONE", 2725 | "indent": 0, 2726 | "lines": Lines {}, 2727 | "start": Position { 2728 | "column": 9, 2729 | "line": 2, 2730 | }, 2731 | }, 2732 | "name": "ONE", 2733 | "start": 67, 2734 | "type": "Identifier", 2735 | "typeAnnotation": null, 2736 | }, 2737 | "name": null, 2738 | "start": 67, 2739 | "type": "ImportSpecifier", 2740 | }, 2741 | Node { 2742 | "end": 82, 2743 | "id": null, 2744 | "importKind": null, 2745 | "imported": Node { 2746 | "end": 82, 2747 | "loc": SourceLocation { 2748 | "end": Position { 2749 | "column": 24, 2750 | "line": 2, 2751 | }, 2752 | "identifierName": "TEST_ENTRY", 2753 | "indent": 0, 2754 | "lines": Lines {}, 2755 | "start": Position { 2756 | "column": 14, 2757 | "line": 2, 2758 | }, 2759 | }, 2760 | "name": "TEST_ENTRY", 2761 | "start": 72, 2762 | "type": "Identifier", 2763 | "typeAnnotation": null, 2764 | }, 2765 | "loc": SourceLocation { 2766 | "end": Position { 2767 | "column": 24, 2768 | "line": 2, 2769 | }, 2770 | "indent": 0, 2771 | "lines": Lines {}, 2772 | "start": Position { 2773 | "column": 14, 2774 | "line": 2, 2775 | }, 2776 | }, 2777 | "local": Node { 2778 | "__clone": [Function], 2779 | "end": 82, 2780 | "loc": SourceLocation { 2781 | "end": Position { 2782 | "column": 24, 2783 | "line": 2, 2784 | }, 2785 | "identifierName": "TEST_ENTRY", 2786 | "indent": 0, 2787 | "lines": Lines {}, 2788 | "start": Position { 2789 | "column": 14, 2790 | "line": 2, 2791 | }, 2792 | }, 2793 | "name": "TEST_ENTRY", 2794 | "start": 72, 2795 | "type": "Identifier", 2796 | "typeAnnotation": null, 2797 | }, 2798 | "name": null, 2799 | "start": 72, 2800 | "type": "ImportSpecifier", 2801 | }, 2802 | ], 2803 | "start": 58, 2804 | "type": "ImportDeclaration", 2805 | }, 2806 | Node { 2807 | "async": false, 2808 | "body": Node { 2809 | "body": Array [ 2810 | Node { 2811 | "cases": Array [ 2812 | Node { 2813 | "consequent": Array [ 2814 | Node { 2815 | "argument": Node { 2816 | "end": 242, 2817 | "loc": SourceLocation { 2818 | "end": Position { 2819 | "column": 46, 2820 | "line": 6, 2821 | }, 2822 | "indent": 6, 2823 | "lines": Lines {}, 2824 | "start": Position { 2825 | "column": 13, 2826 | "line": 6, 2827 | }, 2828 | }, 2829 | "properties": Array [ 2830 | Node { 2831 | "argument": Node { 2832 | "end": 219, 2833 | "loc": SourceLocation { 2834 | "end": Position { 2835 | "column": 23, 2836 | "line": 6, 2837 | }, 2838 | "identifierName": "state", 2839 | "indent": 6, 2840 | "lines": Lines {}, 2841 | "start": Position { 2842 | "column": 18, 2843 | "line": 6, 2844 | }, 2845 | }, 2846 | "name": "state", 2847 | "start": 214, 2848 | "type": "Identifier", 2849 | "typeAnnotation": null, 2850 | }, 2851 | "end": 219, 2852 | "loc": SourceLocation { 2853 | "end": Position { 2854 | "column": 23, 2855 | "line": 6, 2856 | }, 2857 | "indent": 6, 2858 | "lines": Lines {}, 2859 | "start": Position { 2860 | "column": 15, 2861 | "line": 6, 2862 | }, 2863 | }, 2864 | "start": 211, 2865 | "type": "SpreadProperty", 2866 | }, 2867 | Node { 2868 | "computed": false, 2869 | "end": 240, 2870 | "key": Node { 2871 | "end": 224, 2872 | "loc": SourceLocation { 2873 | "end": Position { 2874 | "column": 28, 2875 | "line": 6, 2876 | }, 2877 | "identifierName": "one", 2878 | "indent": 6, 2879 | "lines": Lines {}, 2880 | "start": Position { 2881 | "column": 25, 2882 | "line": 6, 2883 | }, 2884 | }, 2885 | "name": "one", 2886 | "start": 221, 2887 | "type": "Identifier", 2888 | "typeAnnotation": null, 2889 | }, 2890 | "loc": SourceLocation { 2891 | "end": Position { 2892 | "column": 44, 2893 | "line": 6, 2894 | }, 2895 | "indent": 6, 2896 | "lines": Lines {}, 2897 | "start": Position { 2898 | "column": 25, 2899 | "line": 6, 2900 | }, 2901 | }, 2902 | "method": false, 2903 | "shorthand": false, 2904 | "start": 221, 2905 | "type": "ObjectProperty", 2906 | "value": Node { 2907 | "computed": false, 2908 | "end": 240, 2909 | "loc": SourceLocation { 2910 | "end": Position { 2911 | "column": 44, 2912 | "line": 6, 2913 | }, 2914 | "indent": 6, 2915 | "lines": Lines {}, 2916 | "start": Position { 2917 | "column": 30, 2918 | "line": 6, 2919 | }, 2920 | }, 2921 | "object": Node { 2922 | "end": 232, 2923 | "loc": SourceLocation { 2924 | "end": Position { 2925 | "column": 36, 2926 | "line": 6, 2927 | }, 2928 | "identifierName": "action", 2929 | "indent": 6, 2930 | "lines": Lines {}, 2931 | "start": Position { 2932 | "column": 30, 2933 | "line": 6, 2934 | }, 2935 | }, 2936 | "name": "action", 2937 | "start": 226, 2938 | "type": "Identifier", 2939 | "typeAnnotation": null, 2940 | }, 2941 | "property": Node { 2942 | "end": 240, 2943 | "loc": SourceLocation { 2944 | "end": Position { 2945 | "column": 44, 2946 | "line": 6, 2947 | }, 2948 | "identifierName": "payload", 2949 | "indent": 6, 2950 | "lines": Lines {}, 2951 | "start": Position { 2952 | "column": 37, 2953 | "line": 6, 2954 | }, 2955 | }, 2956 | "name": "payload", 2957 | "start": 233, 2958 | "type": "Identifier", 2959 | "typeAnnotation": null, 2960 | }, 2961 | "start": 226, 2962 | "type": "MemberExpression", 2963 | }, 2964 | }, 2965 | ], 2966 | "start": 209, 2967 | "type": "ObjectExpression", 2968 | }, 2969 | "end": 243, 2970 | "loc": SourceLocation { 2971 | "end": Position { 2972 | "column": 47, 2973 | "line": 6, 2974 | }, 2975 | "indent": 6, 2976 | "lines": Lines {}, 2977 | "start": Position { 2978 | "column": 6, 2979 | "line": 6, 2980 | }, 2981 | }, 2982 | "start": 202, 2983 | "type": "ReturnStatement", 2984 | }, 2985 | ], 2986 | "end": 243, 2987 | "loc": SourceLocation { 2988 | "end": Position { 2989 | "column": 47, 2990 | "line": 6, 2991 | }, 2992 | "indent": 4, 2993 | "lines": Lines {}, 2994 | "start": Position { 2995 | "column": 4, 2996 | "line": 5, 2997 | }, 2998 | }, 2999 | "start": 186, 3000 | "test": Node { 3001 | "end": 194, 3002 | "loc": SourceLocation { 3003 | "end": Position { 3004 | "column": 12, 3005 | "line": 5, 3006 | }, 3007 | "identifierName": "ONE", 3008 | "indent": 4, 3009 | "lines": Lines {}, 3010 | "start": Position { 3011 | "column": 9, 3012 | "line": 5, 3013 | }, 3014 | }, 3015 | "name": "ONE", 3016 | "start": 191, 3017 | "type": "Identifier", 3018 | "typeAnnotation": null, 3019 | }, 3020 | "type": "SwitchCase", 3021 | }, 3022 | Object { 3023 | "comments": null, 3024 | "consequent": Array [ 3025 | Object { 3026 | "argument": Object { 3027 | "comments": null, 3028 | "loc": null, 3029 | "properties": Array [ 3030 | Object { 3031 | "argument": Object { 3032 | "comments": null, 3033 | "loc": null, 3034 | "name": "state", 3035 | "type": "Identifier", 3036 | "typeAnnotation": null, 3037 | }, 3038 | "comments": null, 3039 | "loc": null, 3040 | "type": "SpreadProperty", 3041 | }, 3042 | ], 3043 | "type": "ObjectExpression", 3044 | }, 3045 | "comments": null, 3046 | "loc": null, 3047 | "type": "ReturnStatement", 3048 | }, 3049 | ], 3050 | "loc": null, 3051 | "test": Object { 3052 | "comments": null, 3053 | "loc": null, 3054 | "name": "TEST_ENTRY", 3055 | "type": "Identifier", 3056 | "typeAnnotation": null, 3057 | }, 3058 | "type": "SwitchCase", 3059 | }, 3060 | ], 3061 | "discriminant": Node { 3062 | "computed": false, 3063 | "end": 178, 3064 | "loc": SourceLocation { 3065 | "end": Position { 3066 | "column": 20, 3067 | "line": 4, 3068 | }, 3069 | "indent": 2, 3070 | "lines": Lines {}, 3071 | "start": Position { 3072 | "column": 9, 3073 | "line": 4, 3074 | }, 3075 | }, 3076 | "object": Node { 3077 | "end": 173, 3078 | "loc": SourceLocation { 3079 | "end": Position { 3080 | "column": 15, 3081 | "line": 4, 3082 | }, 3083 | "identifierName": "action", 3084 | "indent": 2, 3085 | "lines": Lines {}, 3086 | "start": Position { 3087 | "column": 9, 3088 | "line": 4, 3089 | }, 3090 | }, 3091 | "name": "action", 3092 | "start": 167, 3093 | "type": "Identifier", 3094 | "typeAnnotation": null, 3095 | }, 3096 | "property": Node { 3097 | "end": 178, 3098 | "loc": SourceLocation { 3099 | "end": Position { 3100 | "column": 20, 3101 | "line": 4, 3102 | }, 3103 | "identifierName": "type", 3104 | "indent": 2, 3105 | "lines": Lines {}, 3106 | "start": Position { 3107 | "column": 16, 3108 | "line": 4, 3109 | }, 3110 | }, 3111 | "name": "type", 3112 | "start": 174, 3113 | "type": "Identifier", 3114 | "typeAnnotation": null, 3115 | }, 3116 | "start": 167, 3117 | "type": "MemberExpression", 3118 | }, 3119 | "end": 247, 3120 | "lexical": false, 3121 | "loc": SourceLocation { 3122 | "end": Position { 3123 | "column": 3, 3124 | "line": 7, 3125 | }, 3126 | "indent": 2, 3127 | "lines": Lines {}, 3128 | "start": Position { 3129 | "column": 2, 3130 | "line": 4, 3131 | }, 3132 | }, 3133 | "start": 160, 3134 | "type": "SwitchStatement", 3135 | }, 3136 | ], 3137 | "directives": Array [], 3138 | "end": 249, 3139 | "loc": SourceLocation { 3140 | "end": Position { 3141 | "column": 1, 3142 | "line": 8, 3143 | }, 3144 | "indent": 0, 3145 | "lines": Lines {}, 3146 | "start": Position { 3147 | "column": 51, 3148 | "line": 3, 3149 | }, 3150 | }, 3151 | "start": 156, 3152 | "type": "BlockStatement", 3153 | }, 3154 | "defaults": Array [], 3155 | "end": 249, 3156 | "expression": false, 3157 | "generator": false, 3158 | "id": Node { 3159 | "end": 125, 3160 | "loc": SourceLocation { 3161 | "end": Position { 3162 | "column": 20, 3163 | "line": 3, 3164 | }, 3165 | "identifierName": "testReducer", 3166 | "indent": 0, 3167 | "lines": Lines {}, 3168 | "start": Position { 3169 | "column": 9, 3170 | "line": 3, 3171 | }, 3172 | }, 3173 | "name": "testReducer", 3174 | "start": 114, 3175 | "type": "Identifier", 3176 | "typeAnnotation": null, 3177 | }, 3178 | "loc": SourceLocation { 3179 | "end": Position { 3180 | "column": 1, 3181 | "line": 8, 3182 | }, 3183 | "indent": 0, 3184 | "lines": Lines {}, 3185 | "start": Position { 3186 | "column": 0, 3187 | "line": 3, 3188 | }, 3189 | }, 3190 | "params": Array [ 3191 | Node { 3192 | "end": 146, 3193 | "left": Node { 3194 | "end": 131, 3195 | "loc": SourceLocation { 3196 | "end": Position { 3197 | "column": 26, 3198 | "line": 3, 3199 | }, 3200 | "identifierName": "state", 3201 | "indent": 0, 3202 | "lines": Lines {}, 3203 | "start": Position { 3204 | "column": 21, 3205 | "line": 3, 3206 | }, 3207 | }, 3208 | "name": "state", 3209 | "start": 126, 3210 | "type": "Identifier", 3211 | "typeAnnotation": null, 3212 | }, 3213 | "loc": SourceLocation { 3214 | "end": Position { 3215 | "column": 41, 3216 | "line": 3, 3217 | }, 3218 | "indent": 0, 3219 | "lines": Lines {}, 3220 | "start": Position { 3221 | "column": 21, 3222 | "line": 3, 3223 | }, 3224 | }, 3225 | "right": Node { 3226 | "end": 146, 3227 | "loc": SourceLocation { 3228 | "end": Position { 3229 | "column": 41, 3230 | "line": 3, 3231 | }, 3232 | "identifierName": "initialState", 3233 | "indent": 0, 3234 | "lines": Lines {}, 3235 | "start": Position { 3236 | "column": 29, 3237 | "line": 3, 3238 | }, 3239 | }, 3240 | "name": "initialState", 3241 | "start": 134, 3242 | "type": "Identifier", 3243 | "typeAnnotation": null, 3244 | }, 3245 | "start": 126, 3246 | "type": "AssignmentPattern", 3247 | }, 3248 | Node { 3249 | "end": 154, 3250 | "loc": SourceLocation { 3251 | "end": Position { 3252 | "column": 49, 3253 | "line": 3, 3254 | }, 3255 | "identifierName": "action", 3256 | "indent": 0, 3257 | "lines": Lines {}, 3258 | "start": Position { 3259 | "column": 43, 3260 | "line": 3, 3261 | }, 3262 | }, 3263 | "name": "action", 3264 | "start": 148, 3265 | "type": "Identifier", 3266 | "typeAnnotation": null, 3267 | }, 3268 | ], 3269 | "rest": null, 3270 | "returnType": null, 3271 | "start": 105, 3272 | "type": "FunctionDeclaration", 3273 | "typeParameters": null, 3274 | }, 3275 | Node { 3276 | "declaration": Node { 3277 | "end": 276, 3278 | "loc": null, 3279 | "name": "testReducer", 3280 | "start": 265, 3281 | "type": "Identifier", 3282 | "typeAnnotation": null, 3283 | }, 3284 | "end": 276, 3285 | "loc": SourceLocation { 3286 | "end": Position { 3287 | "column": 26, 3288 | "line": 9, 3289 | }, 3290 | "indent": 0, 3291 | "lines": Lines {}, 3292 | "start": Position { 3293 | "column": 0, 3294 | "line": 9, 3295 | }, 3296 | }, 3297 | "start": 250, 3298 | "type": "ExportDefaultDeclaration", 3299 | }, 3300 | ], 3301 | "directives": Array [], 3302 | "end": 276, 3303 | "loc": SourceLocation { 3304 | "end": Position { 3305 | "column": 26, 3306 | "line": 9, 3307 | }, 3308 | "indent": 0, 3309 | "lines": Lines {}, 3310 | "start": Position { 3311 | "column": 0, 3312 | "line": 1, 3313 | }, 3314 | }, 3315 | "sourceType": "module", 3316 | "start": 0, 3317 | "type": "Program", 3318 | }, 3319 | "start": 0, 3320 | "tokens": Array [ 3321 | Token { 3322 | "end": 6, 3323 | "loc": SourceLocation { 3324 | "end": Position { 3325 | "column": 6, 3326 | "line": 1, 3327 | }, 3328 | "start": Position { 3329 | "column": 0, 3330 | "line": 1, 3331 | }, 3332 | }, 3333 | "start": 0, 3334 | "type": KeywordTokenType { 3335 | "beforeExpr": false, 3336 | "binop": null, 3337 | "isAssign": false, 3338 | "isLoop": false, 3339 | "keyword": "import", 3340 | "label": "import", 3341 | "postfix": false, 3342 | "prefix": false, 3343 | "rightAssociative": false, 3344 | "startsExpr": true, 3345 | "updateContext": null, 3346 | }, 3347 | "value": "import", 3348 | }, 3349 | Token { 3350 | "end": 8, 3351 | "loc": SourceLocation { 3352 | "end": Position { 3353 | "column": 8, 3354 | "line": 1, 3355 | }, 3356 | "start": Position { 3357 | "column": 7, 3358 | "line": 1, 3359 | }, 3360 | }, 3361 | "start": 7, 3362 | "type": TokenType { 3363 | "beforeExpr": true, 3364 | "binop": null, 3365 | "isAssign": false, 3366 | "isLoop": false, 3367 | "keyword": undefined, 3368 | "label": "{", 3369 | "postfix": false, 3370 | "prefix": false, 3371 | "rightAssociative": false, 3372 | "startsExpr": true, 3373 | "updateContext": [Function], 3374 | }, 3375 | "value": undefined, 3376 | }, 3377 | Token { 3378 | "end": 21, 3379 | "loc": SourceLocation { 3380 | "end": Position { 3381 | "column": 21, 3382 | "line": 1, 3383 | }, 3384 | "start": Position { 3385 | "column": 9, 3386 | "line": 1, 3387 | }, 3388 | }, 3389 | "start": 9, 3390 | "type": TokenType { 3391 | "beforeExpr": false, 3392 | "binop": null, 3393 | "isAssign": false, 3394 | "isLoop": false, 3395 | "keyword": undefined, 3396 | "label": "name", 3397 | "postfix": false, 3398 | "prefix": false, 3399 | "rightAssociative": false, 3400 | "startsExpr": true, 3401 | "updateContext": [Function], 3402 | }, 3403 | "value": "createAction", 3404 | }, 3405 | Token { 3406 | "end": 23, 3407 | "loc": SourceLocation { 3408 | "end": Position { 3409 | "column": 23, 3410 | "line": 1, 3411 | }, 3412 | "start": Position { 3413 | "column": 22, 3414 | "line": 1, 3415 | }, 3416 | }, 3417 | "start": 22, 3418 | "type": TokenType { 3419 | "beforeExpr": false, 3420 | "binop": null, 3421 | "isAssign": false, 3422 | "isLoop": false, 3423 | "keyword": undefined, 3424 | "label": "}", 3425 | "postfix": false, 3426 | "prefix": false, 3427 | "rightAssociative": false, 3428 | "startsExpr": false, 3429 | "updateContext": [Function], 3430 | }, 3431 | "value": undefined, 3432 | }, 3433 | Token { 3434 | "end": 28, 3435 | "loc": SourceLocation { 3436 | "end": Position { 3437 | "column": 28, 3438 | "line": 1, 3439 | }, 3440 | "start": Position { 3441 | "column": 24, 3442 | "line": 1, 3443 | }, 3444 | }, 3445 | "start": 24, 3446 | "type": TokenType { 3447 | "beforeExpr": false, 3448 | "binop": null, 3449 | "isAssign": false, 3450 | "isLoop": false, 3451 | "keyword": undefined, 3452 | "label": "name", 3453 | "postfix": false, 3454 | "prefix": false, 3455 | "rightAssociative": false, 3456 | "startsExpr": true, 3457 | "updateContext": [Function], 3458 | }, 3459 | "value": "from", 3460 | }, 3461 | Token { 3462 | "end": 56, 3463 | "loc": SourceLocation { 3464 | "end": Position { 3465 | "column": 56, 3466 | "line": 1, 3467 | }, 3468 | "start": Position { 3469 | "column": 29, 3470 | "line": 1, 3471 | }, 3472 | }, 3473 | "start": 29, 3474 | "type": TokenType { 3475 | "beforeExpr": false, 3476 | "binop": null, 3477 | "isAssign": false, 3478 | "isLoop": false, 3479 | "keyword": undefined, 3480 | "label": "string", 3481 | "postfix": false, 3482 | "prefix": false, 3483 | "rightAssociative": false, 3484 | "startsExpr": true, 3485 | "updateContext": null, 3486 | }, 3487 | "value": "redux-boilerplate-helpers", 3488 | }, 3489 | Token { 3490 | "end": 57, 3491 | "loc": SourceLocation { 3492 | "end": Position { 3493 | "column": 57, 3494 | "line": 1, 3495 | }, 3496 | "start": Position { 3497 | "column": 56, 3498 | "line": 1, 3499 | }, 3500 | }, 3501 | "start": 56, 3502 | "type": TokenType { 3503 | "beforeExpr": true, 3504 | "binop": null, 3505 | "isAssign": false, 3506 | "isLoop": false, 3507 | "keyword": undefined, 3508 | "label": ";", 3509 | "postfix": false, 3510 | "prefix": false, 3511 | "rightAssociative": false, 3512 | "startsExpr": false, 3513 | "updateContext": null, 3514 | }, 3515 | "value": undefined, 3516 | }, 3517 | Token { 3518 | "end": 64, 3519 | "loc": SourceLocation { 3520 | "end": Position { 3521 | "column": 6, 3522 | "line": 2, 3523 | }, 3524 | "start": Position { 3525 | "column": 0, 3526 | "line": 2, 3527 | }, 3528 | }, 3529 | "start": 58, 3530 | "type": KeywordTokenType { 3531 | "beforeExpr": false, 3532 | "binop": null, 3533 | "isAssign": false, 3534 | "isLoop": false, 3535 | "keyword": "import", 3536 | "label": "import", 3537 | "postfix": false, 3538 | "prefix": false, 3539 | "rightAssociative": false, 3540 | "startsExpr": true, 3541 | "updateContext": null, 3542 | }, 3543 | "value": "import", 3544 | }, 3545 | Token { 3546 | "end": 66, 3547 | "loc": SourceLocation { 3548 | "end": Position { 3549 | "column": 8, 3550 | "line": 2, 3551 | }, 3552 | "start": Position { 3553 | "column": 7, 3554 | "line": 2, 3555 | }, 3556 | }, 3557 | "start": 65, 3558 | "type": TokenType { 3559 | "beforeExpr": true, 3560 | "binop": null, 3561 | "isAssign": false, 3562 | "isLoop": false, 3563 | "keyword": undefined, 3564 | "label": "{", 3565 | "postfix": false, 3566 | "prefix": false, 3567 | "rightAssociative": false, 3568 | "startsExpr": true, 3569 | "updateContext": [Function], 3570 | }, 3571 | "value": undefined, 3572 | }, 3573 | Token { 3574 | "end": 70, 3575 | "loc": SourceLocation { 3576 | "end": Position { 3577 | "column": 12, 3578 | "line": 2, 3579 | }, 3580 | "start": Position { 3581 | "column": 9, 3582 | "line": 2, 3583 | }, 3584 | }, 3585 | "start": 67, 3586 | "type": TokenType { 3587 | "beforeExpr": false, 3588 | "binop": null, 3589 | "isAssign": false, 3590 | "isLoop": false, 3591 | "keyword": undefined, 3592 | "label": "name", 3593 | "postfix": false, 3594 | "prefix": false, 3595 | "rightAssociative": false, 3596 | "startsExpr": true, 3597 | "updateContext": [Function], 3598 | }, 3599 | "value": "ONE", 3600 | }, 3601 | Token { 3602 | "end": 71, 3603 | "loc": SourceLocation { 3604 | "end": Position { 3605 | "column": 13, 3606 | "line": 2, 3607 | }, 3608 | "start": Position { 3609 | "column": 12, 3610 | "line": 2, 3611 | }, 3612 | }, 3613 | "start": 70, 3614 | "type": TokenType { 3615 | "beforeExpr": true, 3616 | "binop": null, 3617 | "isAssign": false, 3618 | "isLoop": false, 3619 | "keyword": undefined, 3620 | "label": ",", 3621 | "postfix": false, 3622 | "prefix": false, 3623 | "rightAssociative": false, 3624 | "startsExpr": false, 3625 | "updateContext": null, 3626 | }, 3627 | "value": undefined, 3628 | }, 3629 | Token { 3630 | "end": 82, 3631 | "loc": SourceLocation { 3632 | "end": Position { 3633 | "column": 24, 3634 | "line": 2, 3635 | }, 3636 | "start": Position { 3637 | "column": 14, 3638 | "line": 2, 3639 | }, 3640 | }, 3641 | "start": 72, 3642 | "type": TokenType { 3643 | "beforeExpr": false, 3644 | "binop": null, 3645 | "isAssign": false, 3646 | "isLoop": false, 3647 | "keyword": undefined, 3648 | "label": "name", 3649 | "postfix": false, 3650 | "prefix": false, 3651 | "rightAssociative": false, 3652 | "startsExpr": true, 3653 | "updateContext": [Function], 3654 | }, 3655 | "value": "TEST_ENTRY", 3656 | }, 3657 | Token { 3658 | "end": 84, 3659 | "loc": SourceLocation { 3660 | "end": Position { 3661 | "column": 26, 3662 | "line": 2, 3663 | }, 3664 | "start": Position { 3665 | "column": 25, 3666 | "line": 2, 3667 | }, 3668 | }, 3669 | "start": 83, 3670 | "type": TokenType { 3671 | "beforeExpr": false, 3672 | "binop": null, 3673 | "isAssign": false, 3674 | "isLoop": false, 3675 | "keyword": undefined, 3676 | "label": "}", 3677 | "postfix": false, 3678 | "prefix": false, 3679 | "rightAssociative": false, 3680 | "startsExpr": false, 3681 | "updateContext": [Function], 3682 | }, 3683 | "value": undefined, 3684 | }, 3685 | Token { 3686 | "end": 89, 3687 | "loc": SourceLocation { 3688 | "end": Position { 3689 | "column": 31, 3690 | "line": 2, 3691 | }, 3692 | "start": Position { 3693 | "column": 27, 3694 | "line": 2, 3695 | }, 3696 | }, 3697 | "start": 85, 3698 | "type": TokenType { 3699 | "beforeExpr": false, 3700 | "binop": null, 3701 | "isAssign": false, 3702 | "isLoop": false, 3703 | "keyword": undefined, 3704 | "label": "name", 3705 | "postfix": false, 3706 | "prefix": false, 3707 | "rightAssociative": false, 3708 | "startsExpr": true, 3709 | "updateContext": [Function], 3710 | }, 3711 | "value": "from", 3712 | }, 3713 | Token { 3714 | "end": 103, 3715 | "loc": SourceLocation { 3716 | "end": Position { 3717 | "column": 45, 3718 | "line": 2, 3719 | }, 3720 | "start": Position { 3721 | "column": 32, 3722 | "line": 2, 3723 | }, 3724 | }, 3725 | "start": 90, 3726 | "type": TokenType { 3727 | "beforeExpr": false, 3728 | "binop": null, 3729 | "isAssign": false, 3730 | "isLoop": false, 3731 | "keyword": undefined, 3732 | "label": "string", 3733 | "postfix": false, 3734 | "prefix": false, 3735 | "rightAssociative": false, 3736 | "startsExpr": true, 3737 | "updateContext": null, 3738 | }, 3739 | "value": "./constants", 3740 | }, 3741 | Token { 3742 | "end": 104, 3743 | "loc": SourceLocation { 3744 | "end": Position { 3745 | "column": 46, 3746 | "line": 2, 3747 | }, 3748 | "start": Position { 3749 | "column": 45, 3750 | "line": 2, 3751 | }, 3752 | }, 3753 | "start": 103, 3754 | "type": TokenType { 3755 | "beforeExpr": true, 3756 | "binop": null, 3757 | "isAssign": false, 3758 | "isLoop": false, 3759 | "keyword": undefined, 3760 | "label": ";", 3761 | "postfix": false, 3762 | "prefix": false, 3763 | "rightAssociative": false, 3764 | "startsExpr": false, 3765 | "updateContext": null, 3766 | }, 3767 | "value": undefined, 3768 | }, 3769 | Token { 3770 | "end": 113, 3771 | "loc": SourceLocation { 3772 | "end": Position { 3773 | "column": 8, 3774 | "line": 3, 3775 | }, 3776 | "start": Position { 3777 | "column": 0, 3778 | "line": 3, 3779 | }, 3780 | }, 3781 | "start": 105, 3782 | "type": KeywordTokenType { 3783 | "beforeExpr": false, 3784 | "binop": null, 3785 | "isAssign": false, 3786 | "isLoop": false, 3787 | "keyword": "function", 3788 | "label": "function", 3789 | "postfix": false, 3790 | "prefix": false, 3791 | "rightAssociative": false, 3792 | "startsExpr": true, 3793 | "updateContext": [Function], 3794 | }, 3795 | "value": "function", 3796 | }, 3797 | Token { 3798 | "end": 125, 3799 | "loc": SourceLocation { 3800 | "end": Position { 3801 | "column": 20, 3802 | "line": 3, 3803 | }, 3804 | "start": Position { 3805 | "column": 9, 3806 | "line": 3, 3807 | }, 3808 | }, 3809 | "start": 114, 3810 | "type": TokenType { 3811 | "beforeExpr": false, 3812 | "binop": null, 3813 | "isAssign": false, 3814 | "isLoop": false, 3815 | "keyword": undefined, 3816 | "label": "name", 3817 | "postfix": false, 3818 | "prefix": false, 3819 | "rightAssociative": false, 3820 | "startsExpr": true, 3821 | "updateContext": [Function], 3822 | }, 3823 | "value": "testReducer", 3824 | }, 3825 | Token { 3826 | "end": 126, 3827 | "loc": SourceLocation { 3828 | "end": Position { 3829 | "column": 21, 3830 | "line": 3, 3831 | }, 3832 | "start": Position { 3833 | "column": 20, 3834 | "line": 3, 3835 | }, 3836 | }, 3837 | "start": 125, 3838 | "type": TokenType { 3839 | "beforeExpr": true, 3840 | "binop": null, 3841 | "isAssign": false, 3842 | "isLoop": false, 3843 | "keyword": undefined, 3844 | "label": "(", 3845 | "postfix": false, 3846 | "prefix": false, 3847 | "rightAssociative": false, 3848 | "startsExpr": true, 3849 | "updateContext": [Function], 3850 | }, 3851 | "value": undefined, 3852 | }, 3853 | Token { 3854 | "end": 131, 3855 | "loc": SourceLocation { 3856 | "end": Position { 3857 | "column": 26, 3858 | "line": 3, 3859 | }, 3860 | "start": Position { 3861 | "column": 21, 3862 | "line": 3, 3863 | }, 3864 | }, 3865 | "start": 126, 3866 | "type": TokenType { 3867 | "beforeExpr": false, 3868 | "binop": null, 3869 | "isAssign": false, 3870 | "isLoop": false, 3871 | "keyword": undefined, 3872 | "label": "name", 3873 | "postfix": false, 3874 | "prefix": false, 3875 | "rightAssociative": false, 3876 | "startsExpr": true, 3877 | "updateContext": [Function], 3878 | }, 3879 | "value": "state", 3880 | }, 3881 | Token { 3882 | "end": 133, 3883 | "loc": SourceLocation { 3884 | "end": Position { 3885 | "column": 28, 3886 | "line": 3, 3887 | }, 3888 | "start": Position { 3889 | "column": 27, 3890 | "line": 3, 3891 | }, 3892 | }, 3893 | "start": 132, 3894 | "type": TokenType { 3895 | "beforeExpr": true, 3896 | "binop": null, 3897 | "isAssign": true, 3898 | "isLoop": false, 3899 | "keyword": undefined, 3900 | "label": "=", 3901 | "postfix": false, 3902 | "prefix": false, 3903 | "rightAssociative": false, 3904 | "startsExpr": false, 3905 | "updateContext": null, 3906 | }, 3907 | "value": "=", 3908 | }, 3909 | Token { 3910 | "end": 146, 3911 | "loc": SourceLocation { 3912 | "end": Position { 3913 | "column": 41, 3914 | "line": 3, 3915 | }, 3916 | "start": Position { 3917 | "column": 29, 3918 | "line": 3, 3919 | }, 3920 | }, 3921 | "start": 134, 3922 | "type": TokenType { 3923 | "beforeExpr": false, 3924 | "binop": null, 3925 | "isAssign": false, 3926 | "isLoop": false, 3927 | "keyword": undefined, 3928 | "label": "name", 3929 | "postfix": false, 3930 | "prefix": false, 3931 | "rightAssociative": false, 3932 | "startsExpr": true, 3933 | "updateContext": [Function], 3934 | }, 3935 | "value": "initialState", 3936 | }, 3937 | Token { 3938 | "end": 147, 3939 | "loc": SourceLocation { 3940 | "end": Position { 3941 | "column": 42, 3942 | "line": 3, 3943 | }, 3944 | "start": Position { 3945 | "column": 41, 3946 | "line": 3, 3947 | }, 3948 | }, 3949 | "start": 146, 3950 | "type": TokenType { 3951 | "beforeExpr": true, 3952 | "binop": null, 3953 | "isAssign": false, 3954 | "isLoop": false, 3955 | "keyword": undefined, 3956 | "label": ",", 3957 | "postfix": false, 3958 | "prefix": false, 3959 | "rightAssociative": false, 3960 | "startsExpr": false, 3961 | "updateContext": null, 3962 | }, 3963 | "value": undefined, 3964 | }, 3965 | Token { 3966 | "end": 154, 3967 | "loc": SourceLocation { 3968 | "end": Position { 3969 | "column": 49, 3970 | "line": 3, 3971 | }, 3972 | "start": Position { 3973 | "column": 43, 3974 | "line": 3, 3975 | }, 3976 | }, 3977 | "start": 148, 3978 | "type": TokenType { 3979 | "beforeExpr": false, 3980 | "binop": null, 3981 | "isAssign": false, 3982 | "isLoop": false, 3983 | "keyword": undefined, 3984 | "label": "name", 3985 | "postfix": false, 3986 | "prefix": false, 3987 | "rightAssociative": false, 3988 | "startsExpr": true, 3989 | "updateContext": [Function], 3990 | }, 3991 | "value": "action", 3992 | }, 3993 | Token { 3994 | "end": 155, 3995 | "loc": SourceLocation { 3996 | "end": Position { 3997 | "column": 50, 3998 | "line": 3, 3999 | }, 4000 | "start": Position { 4001 | "column": 49, 4002 | "line": 3, 4003 | }, 4004 | }, 4005 | "start": 154, 4006 | "type": TokenType { 4007 | "beforeExpr": false, 4008 | "binop": null, 4009 | "isAssign": false, 4010 | "isLoop": false, 4011 | "keyword": undefined, 4012 | "label": ")", 4013 | "postfix": false, 4014 | "prefix": false, 4015 | "rightAssociative": false, 4016 | "startsExpr": false, 4017 | "updateContext": [Function], 4018 | }, 4019 | "value": undefined, 4020 | }, 4021 | Token { 4022 | "end": 157, 4023 | "loc": SourceLocation { 4024 | "end": Position { 4025 | "column": 52, 4026 | "line": 3, 4027 | }, 4028 | "start": Position { 4029 | "column": 51, 4030 | "line": 3, 4031 | }, 4032 | }, 4033 | "start": 156, 4034 | "type": TokenType { 4035 | "beforeExpr": true, 4036 | "binop": null, 4037 | "isAssign": false, 4038 | "isLoop": false, 4039 | "keyword": undefined, 4040 | "label": "{", 4041 | "postfix": false, 4042 | "prefix": false, 4043 | "rightAssociative": false, 4044 | "startsExpr": true, 4045 | "updateContext": [Function], 4046 | }, 4047 | "value": undefined, 4048 | }, 4049 | Token { 4050 | "end": 166, 4051 | "loc": SourceLocation { 4052 | "end": Position { 4053 | "column": 8, 4054 | "line": 4, 4055 | }, 4056 | "start": Position { 4057 | "column": 2, 4058 | "line": 4, 4059 | }, 4060 | }, 4061 | "start": 160, 4062 | "type": KeywordTokenType { 4063 | "beforeExpr": false, 4064 | "binop": null, 4065 | "isAssign": false, 4066 | "isLoop": false, 4067 | "keyword": "switch", 4068 | "label": "switch", 4069 | "postfix": false, 4070 | "prefix": false, 4071 | "rightAssociative": false, 4072 | "startsExpr": false, 4073 | "updateContext": null, 4074 | }, 4075 | "value": "switch", 4076 | }, 4077 | Token { 4078 | "end": 167, 4079 | "loc": SourceLocation { 4080 | "end": Position { 4081 | "column": 9, 4082 | "line": 4, 4083 | }, 4084 | "start": Position { 4085 | "column": 8, 4086 | "line": 4, 4087 | }, 4088 | }, 4089 | "start": 166, 4090 | "type": TokenType { 4091 | "beforeExpr": true, 4092 | "binop": null, 4093 | "isAssign": false, 4094 | "isLoop": false, 4095 | "keyword": undefined, 4096 | "label": "(", 4097 | "postfix": false, 4098 | "prefix": false, 4099 | "rightAssociative": false, 4100 | "startsExpr": true, 4101 | "updateContext": [Function], 4102 | }, 4103 | "value": undefined, 4104 | }, 4105 | Token { 4106 | "end": 173, 4107 | "loc": SourceLocation { 4108 | "end": Position { 4109 | "column": 15, 4110 | "line": 4, 4111 | }, 4112 | "start": Position { 4113 | "column": 9, 4114 | "line": 4, 4115 | }, 4116 | }, 4117 | "start": 167, 4118 | "type": TokenType { 4119 | "beforeExpr": false, 4120 | "binop": null, 4121 | "isAssign": false, 4122 | "isLoop": false, 4123 | "keyword": undefined, 4124 | "label": "name", 4125 | "postfix": false, 4126 | "prefix": false, 4127 | "rightAssociative": false, 4128 | "startsExpr": true, 4129 | "updateContext": [Function], 4130 | }, 4131 | "value": "action", 4132 | }, 4133 | Token { 4134 | "end": 174, 4135 | "loc": SourceLocation { 4136 | "end": Position { 4137 | "column": 16, 4138 | "line": 4, 4139 | }, 4140 | "start": Position { 4141 | "column": 15, 4142 | "line": 4, 4143 | }, 4144 | }, 4145 | "start": 173, 4146 | "type": TokenType { 4147 | "beforeExpr": false, 4148 | "binop": null, 4149 | "isAssign": false, 4150 | "isLoop": false, 4151 | "keyword": undefined, 4152 | "label": ".", 4153 | "postfix": false, 4154 | "prefix": false, 4155 | "rightAssociative": false, 4156 | "startsExpr": false, 4157 | "updateContext": null, 4158 | }, 4159 | "value": undefined, 4160 | }, 4161 | Token { 4162 | "end": 178, 4163 | "loc": SourceLocation { 4164 | "end": Position { 4165 | "column": 20, 4166 | "line": 4, 4167 | }, 4168 | "start": Position { 4169 | "column": 16, 4170 | "line": 4, 4171 | }, 4172 | }, 4173 | "start": 174, 4174 | "type": TokenType { 4175 | "beforeExpr": false, 4176 | "binop": null, 4177 | "isAssign": false, 4178 | "isLoop": false, 4179 | "keyword": undefined, 4180 | "label": "name", 4181 | "postfix": false, 4182 | "prefix": false, 4183 | "rightAssociative": false, 4184 | "startsExpr": true, 4185 | "updateContext": [Function], 4186 | }, 4187 | "value": "type", 4188 | }, 4189 | Token { 4190 | "end": 179, 4191 | "loc": SourceLocation { 4192 | "end": Position { 4193 | "column": 21, 4194 | "line": 4, 4195 | }, 4196 | "start": Position { 4197 | "column": 20, 4198 | "line": 4, 4199 | }, 4200 | }, 4201 | "start": 178, 4202 | "type": TokenType { 4203 | "beforeExpr": false, 4204 | "binop": null, 4205 | "isAssign": false, 4206 | "isLoop": false, 4207 | "keyword": undefined, 4208 | "label": ")", 4209 | "postfix": false, 4210 | "prefix": false, 4211 | "rightAssociative": false, 4212 | "startsExpr": false, 4213 | "updateContext": [Function], 4214 | }, 4215 | "value": undefined, 4216 | }, 4217 | Token { 4218 | "end": 181, 4219 | "loc": SourceLocation { 4220 | "end": Position { 4221 | "column": 23, 4222 | "line": 4, 4223 | }, 4224 | "start": Position { 4225 | "column": 22, 4226 | "line": 4, 4227 | }, 4228 | }, 4229 | "start": 180, 4230 | "type": TokenType { 4231 | "beforeExpr": true, 4232 | "binop": null, 4233 | "isAssign": false, 4234 | "isLoop": false, 4235 | "keyword": undefined, 4236 | "label": "{", 4237 | "postfix": false, 4238 | "prefix": false, 4239 | "rightAssociative": false, 4240 | "startsExpr": true, 4241 | "updateContext": [Function], 4242 | }, 4243 | "value": undefined, 4244 | }, 4245 | Token { 4246 | "end": 190, 4247 | "loc": SourceLocation { 4248 | "end": Position { 4249 | "column": 8, 4250 | "line": 5, 4251 | }, 4252 | "start": Position { 4253 | "column": 4, 4254 | "line": 5, 4255 | }, 4256 | }, 4257 | "start": 186, 4258 | "type": KeywordTokenType { 4259 | "beforeExpr": true, 4260 | "binop": null, 4261 | "isAssign": false, 4262 | "isLoop": false, 4263 | "keyword": "case", 4264 | "label": "case", 4265 | "postfix": false, 4266 | "prefix": false, 4267 | "rightAssociative": false, 4268 | "startsExpr": false, 4269 | "updateContext": null, 4270 | }, 4271 | "value": "case", 4272 | }, 4273 | Token { 4274 | "end": 194, 4275 | "loc": SourceLocation { 4276 | "end": Position { 4277 | "column": 12, 4278 | "line": 5, 4279 | }, 4280 | "start": Position { 4281 | "column": 9, 4282 | "line": 5, 4283 | }, 4284 | }, 4285 | "start": 191, 4286 | "type": TokenType { 4287 | "beforeExpr": false, 4288 | "binop": null, 4289 | "isAssign": false, 4290 | "isLoop": false, 4291 | "keyword": undefined, 4292 | "label": "name", 4293 | "postfix": false, 4294 | "prefix": false, 4295 | "rightAssociative": false, 4296 | "startsExpr": true, 4297 | "updateContext": [Function], 4298 | }, 4299 | "value": "ONE", 4300 | }, 4301 | Token { 4302 | "end": 195, 4303 | "loc": SourceLocation { 4304 | "end": Position { 4305 | "column": 13, 4306 | "line": 5, 4307 | }, 4308 | "start": Position { 4309 | "column": 12, 4310 | "line": 5, 4311 | }, 4312 | }, 4313 | "start": 194, 4314 | "type": TokenType { 4315 | "beforeExpr": true, 4316 | "binop": null, 4317 | "isAssign": false, 4318 | "isLoop": false, 4319 | "keyword": undefined, 4320 | "label": ":", 4321 | "postfix": false, 4322 | "prefix": false, 4323 | "rightAssociative": false, 4324 | "startsExpr": false, 4325 | "updateContext": null, 4326 | }, 4327 | "value": undefined, 4328 | }, 4329 | Token { 4330 | "end": 208, 4331 | "loc": SourceLocation { 4332 | "end": Position { 4333 | "column": 12, 4334 | "line": 6, 4335 | }, 4336 | "start": Position { 4337 | "column": 6, 4338 | "line": 6, 4339 | }, 4340 | }, 4341 | "start": 202, 4342 | "type": KeywordTokenType { 4343 | "beforeExpr": true, 4344 | "binop": null, 4345 | "isAssign": false, 4346 | "isLoop": false, 4347 | "keyword": "return", 4348 | "label": "return", 4349 | "postfix": false, 4350 | "prefix": false, 4351 | "rightAssociative": false, 4352 | "startsExpr": false, 4353 | "updateContext": null, 4354 | }, 4355 | "value": "return", 4356 | }, 4357 | Token { 4358 | "end": 210, 4359 | "loc": SourceLocation { 4360 | "end": Position { 4361 | "column": 14, 4362 | "line": 6, 4363 | }, 4364 | "start": Position { 4365 | "column": 13, 4366 | "line": 6, 4367 | }, 4368 | }, 4369 | "start": 209, 4370 | "type": TokenType { 4371 | "beforeExpr": true, 4372 | "binop": null, 4373 | "isAssign": false, 4374 | "isLoop": false, 4375 | "keyword": undefined, 4376 | "label": "{", 4377 | "postfix": false, 4378 | "prefix": false, 4379 | "rightAssociative": false, 4380 | "startsExpr": true, 4381 | "updateContext": [Function], 4382 | }, 4383 | "value": undefined, 4384 | }, 4385 | Token { 4386 | "end": 214, 4387 | "loc": SourceLocation { 4388 | "end": Position { 4389 | "column": 18, 4390 | "line": 6, 4391 | }, 4392 | "start": Position { 4393 | "column": 15, 4394 | "line": 6, 4395 | }, 4396 | }, 4397 | "start": 211, 4398 | "type": TokenType { 4399 | "beforeExpr": true, 4400 | "binop": null, 4401 | "isAssign": false, 4402 | "isLoop": false, 4403 | "keyword": undefined, 4404 | "label": "...", 4405 | "postfix": false, 4406 | "prefix": false, 4407 | "rightAssociative": false, 4408 | "startsExpr": false, 4409 | "updateContext": null, 4410 | }, 4411 | "value": undefined, 4412 | }, 4413 | Token { 4414 | "end": 219, 4415 | "loc": SourceLocation { 4416 | "end": Position { 4417 | "column": 23, 4418 | "line": 6, 4419 | }, 4420 | "start": Position { 4421 | "column": 18, 4422 | "line": 6, 4423 | }, 4424 | }, 4425 | "start": 214, 4426 | "type": TokenType { 4427 | "beforeExpr": false, 4428 | "binop": null, 4429 | "isAssign": false, 4430 | "isLoop": false, 4431 | "keyword": undefined, 4432 | "label": "name", 4433 | "postfix": false, 4434 | "prefix": false, 4435 | "rightAssociative": false, 4436 | "startsExpr": true, 4437 | "updateContext": [Function], 4438 | }, 4439 | "value": "state", 4440 | }, 4441 | Token { 4442 | "end": 220, 4443 | "loc": SourceLocation { 4444 | "end": Position { 4445 | "column": 24, 4446 | "line": 6, 4447 | }, 4448 | "start": Position { 4449 | "column": 23, 4450 | "line": 6, 4451 | }, 4452 | }, 4453 | "start": 219, 4454 | "type": TokenType { 4455 | "beforeExpr": true, 4456 | "binop": null, 4457 | "isAssign": false, 4458 | "isLoop": false, 4459 | "keyword": undefined, 4460 | "label": ",", 4461 | "postfix": false, 4462 | "prefix": false, 4463 | "rightAssociative": false, 4464 | "startsExpr": false, 4465 | "updateContext": null, 4466 | }, 4467 | "value": undefined, 4468 | }, 4469 | Token { 4470 | "end": 224, 4471 | "loc": SourceLocation { 4472 | "end": Position { 4473 | "column": 28, 4474 | "line": 6, 4475 | }, 4476 | "start": Position { 4477 | "column": 25, 4478 | "line": 6, 4479 | }, 4480 | }, 4481 | "start": 221, 4482 | "type": TokenType { 4483 | "beforeExpr": false, 4484 | "binop": null, 4485 | "isAssign": false, 4486 | "isLoop": false, 4487 | "keyword": undefined, 4488 | "label": "name", 4489 | "postfix": false, 4490 | "prefix": false, 4491 | "rightAssociative": false, 4492 | "startsExpr": true, 4493 | "updateContext": [Function], 4494 | }, 4495 | "value": "one", 4496 | }, 4497 | Token { 4498 | "end": 225, 4499 | "loc": SourceLocation { 4500 | "end": Position { 4501 | "column": 29, 4502 | "line": 6, 4503 | }, 4504 | "start": Position { 4505 | "column": 28, 4506 | "line": 6, 4507 | }, 4508 | }, 4509 | "start": 224, 4510 | "type": TokenType { 4511 | "beforeExpr": true, 4512 | "binop": null, 4513 | "isAssign": false, 4514 | "isLoop": false, 4515 | "keyword": undefined, 4516 | "label": ":", 4517 | "postfix": false, 4518 | "prefix": false, 4519 | "rightAssociative": false, 4520 | "startsExpr": false, 4521 | "updateContext": null, 4522 | }, 4523 | "value": undefined, 4524 | }, 4525 | Token { 4526 | "end": 232, 4527 | "loc": SourceLocation { 4528 | "end": Position { 4529 | "column": 36, 4530 | "line": 6, 4531 | }, 4532 | "start": Position { 4533 | "column": 30, 4534 | "line": 6, 4535 | }, 4536 | }, 4537 | "start": 226, 4538 | "type": TokenType { 4539 | "beforeExpr": false, 4540 | "binop": null, 4541 | "isAssign": false, 4542 | "isLoop": false, 4543 | "keyword": undefined, 4544 | "label": "name", 4545 | "postfix": false, 4546 | "prefix": false, 4547 | "rightAssociative": false, 4548 | "startsExpr": true, 4549 | "updateContext": [Function], 4550 | }, 4551 | "value": "action", 4552 | }, 4553 | Token { 4554 | "end": 233, 4555 | "loc": SourceLocation { 4556 | "end": Position { 4557 | "column": 37, 4558 | "line": 6, 4559 | }, 4560 | "start": Position { 4561 | "column": 36, 4562 | "line": 6, 4563 | }, 4564 | }, 4565 | "start": 232, 4566 | "type": TokenType { 4567 | "beforeExpr": false, 4568 | "binop": null, 4569 | "isAssign": false, 4570 | "isLoop": false, 4571 | "keyword": undefined, 4572 | "label": ".", 4573 | "postfix": false, 4574 | "prefix": false, 4575 | "rightAssociative": false, 4576 | "startsExpr": false, 4577 | "updateContext": null, 4578 | }, 4579 | "value": undefined, 4580 | }, 4581 | Token { 4582 | "end": 240, 4583 | "loc": SourceLocation { 4584 | "end": Position { 4585 | "column": 44, 4586 | "line": 6, 4587 | }, 4588 | "start": Position { 4589 | "column": 37, 4590 | "line": 6, 4591 | }, 4592 | }, 4593 | "start": 233, 4594 | "type": TokenType { 4595 | "beforeExpr": false, 4596 | "binop": null, 4597 | "isAssign": false, 4598 | "isLoop": false, 4599 | "keyword": undefined, 4600 | "label": "name", 4601 | "postfix": false, 4602 | "prefix": false, 4603 | "rightAssociative": false, 4604 | "startsExpr": true, 4605 | "updateContext": [Function], 4606 | }, 4607 | "value": "payload", 4608 | }, 4609 | Token { 4610 | "end": 242, 4611 | "loc": SourceLocation { 4612 | "end": Position { 4613 | "column": 46, 4614 | "line": 6, 4615 | }, 4616 | "start": Position { 4617 | "column": 45, 4618 | "line": 6, 4619 | }, 4620 | }, 4621 | "start": 241, 4622 | "type": TokenType { 4623 | "beforeExpr": false, 4624 | "binop": null, 4625 | "isAssign": false, 4626 | "isLoop": false, 4627 | "keyword": undefined, 4628 | "label": "}", 4629 | "postfix": false, 4630 | "prefix": false, 4631 | "rightAssociative": false, 4632 | "startsExpr": false, 4633 | "updateContext": [Function], 4634 | }, 4635 | "value": undefined, 4636 | }, 4637 | Token { 4638 | "end": 243, 4639 | "loc": SourceLocation { 4640 | "end": Position { 4641 | "column": 47, 4642 | "line": 6, 4643 | }, 4644 | "start": Position { 4645 | "column": 46, 4646 | "line": 6, 4647 | }, 4648 | }, 4649 | "start": 242, 4650 | "type": TokenType { 4651 | "beforeExpr": true, 4652 | "binop": null, 4653 | "isAssign": false, 4654 | "isLoop": false, 4655 | "keyword": undefined, 4656 | "label": ";", 4657 | "postfix": false, 4658 | "prefix": false, 4659 | "rightAssociative": false, 4660 | "startsExpr": false, 4661 | "updateContext": null, 4662 | }, 4663 | "value": undefined, 4664 | }, 4665 | Token { 4666 | "end": 247, 4667 | "loc": SourceLocation { 4668 | "end": Position { 4669 | "column": 3, 4670 | "line": 7, 4671 | }, 4672 | "start": Position { 4673 | "column": 2, 4674 | "line": 7, 4675 | }, 4676 | }, 4677 | "start": 246, 4678 | "type": TokenType { 4679 | "beforeExpr": false, 4680 | "binop": null, 4681 | "isAssign": false, 4682 | "isLoop": false, 4683 | "keyword": undefined, 4684 | "label": "}", 4685 | "postfix": false, 4686 | "prefix": false, 4687 | "rightAssociative": false, 4688 | "startsExpr": false, 4689 | "updateContext": [Function], 4690 | }, 4691 | "value": undefined, 4692 | }, 4693 | Token { 4694 | "end": 249, 4695 | "loc": SourceLocation { 4696 | "end": Position { 4697 | "column": 1, 4698 | "line": 8, 4699 | }, 4700 | "start": Position { 4701 | "column": 0, 4702 | "line": 8, 4703 | }, 4704 | }, 4705 | "start": 248, 4706 | "type": TokenType { 4707 | "beforeExpr": false, 4708 | "binop": null, 4709 | "isAssign": false, 4710 | "isLoop": false, 4711 | "keyword": undefined, 4712 | "label": "}", 4713 | "postfix": false, 4714 | "prefix": false, 4715 | "rightAssociative": false, 4716 | "startsExpr": false, 4717 | "updateContext": [Function], 4718 | }, 4719 | "value": undefined, 4720 | }, 4721 | Token { 4722 | "end": 256, 4723 | "loc": SourceLocation { 4724 | "end": Position { 4725 | "column": 6, 4726 | "line": 9, 4727 | }, 4728 | "start": Position { 4729 | "column": 0, 4730 | "line": 9, 4731 | }, 4732 | }, 4733 | "start": 250, 4734 | "type": KeywordTokenType { 4735 | "beforeExpr": false, 4736 | "binop": null, 4737 | "isAssign": false, 4738 | "isLoop": false, 4739 | "keyword": "export", 4740 | "label": "export", 4741 | "postfix": false, 4742 | "prefix": false, 4743 | "rightAssociative": false, 4744 | "startsExpr": false, 4745 | "updateContext": null, 4746 | }, 4747 | "value": "export", 4748 | }, 4749 | Token { 4750 | "end": 264, 4751 | "loc": SourceLocation { 4752 | "end": Position { 4753 | "column": 14, 4754 | "line": 9, 4755 | }, 4756 | "start": Position { 4757 | "column": 7, 4758 | "line": 9, 4759 | }, 4760 | }, 4761 | "start": 257, 4762 | "type": KeywordTokenType { 4763 | "beforeExpr": true, 4764 | "binop": null, 4765 | "isAssign": false, 4766 | "isLoop": false, 4767 | "keyword": "default", 4768 | "label": "default", 4769 | "postfix": false, 4770 | "prefix": false, 4771 | "rightAssociative": false, 4772 | "startsExpr": false, 4773 | "updateContext": null, 4774 | }, 4775 | "value": "default", 4776 | }, 4777 | Token { 4778 | "end": 276, 4779 | "loc": SourceLocation { 4780 | "end": Position { 4781 | "column": 26, 4782 | "line": 9, 4783 | }, 4784 | "start": Position { 4785 | "column": 15, 4786 | "line": 9, 4787 | }, 4788 | }, 4789 | "start": 265, 4790 | "type": TokenType { 4791 | "beforeExpr": false, 4792 | "binop": null, 4793 | "isAssign": false, 4794 | "isLoop": false, 4795 | "keyword": undefined, 4796 | "label": "name", 4797 | "postfix": false, 4798 | "prefix": false, 4799 | "rightAssociative": false, 4800 | "startsExpr": true, 4801 | "updateContext": [Function], 4802 | }, 4803 | "value": "testReducer", 4804 | }, 4805 | Token { 4806 | "end": 276, 4807 | "loc": SourceLocation { 4808 | "end": Position { 4809 | "column": 26, 4810 | "line": 9, 4811 | }, 4812 | "start": Position { 4813 | "column": 26, 4814 | "line": 9, 4815 | }, 4816 | }, 4817 | "start": 276, 4818 | "type": TokenType { 4819 | "beforeExpr": false, 4820 | "binop": null, 4821 | "isAssign": false, 4822 | "isLoop": false, 4823 | "keyword": undefined, 4824 | "label": "eof", 4825 | "postfix": false, 4826 | "prefix": false, 4827 | "rightAssociative": false, 4828 | "startsExpr": false, 4829 | "updateContext": null, 4830 | }, 4831 | "value": undefined, 4832 | }, 4833 | ], 4834 | "type": "File", 4835 | } 4836 | `; 4837 | -------------------------------------------------------------------------------- /src/__tests__/__snapshots__/fileOperations.test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`File Operations adds an action to the files 1`] = `Array []`; 4 | 5 | exports[`File Operations adds an action to the files 2`] = `Array []`; 6 | 7 | exports[`File Operations adds an action to the files 3`] = `Array []`; 8 | 9 | exports[`File Operations adds an action to the files 4`] = `Array []`; 10 | 11 | exports[`File Operations adds an action to the files 5`] = ` 12 | Array [ 13 | Array [ 14 | "/tmp", 15 | "", 16 | ], 17 | Array [ 18 | "/tmp", 19 | "", 20 | ], 21 | Array [ 22 | "/tmp", 23 | "", 24 | ], 25 | ] 26 | `; 27 | 28 | exports[`File Operations adds an action to the files 6`] = ` 29 | Array [ 30 | Array [ 31 | "/tmp", 32 | "utf8", 33 | ], 34 | Array [ 35 | "/tmp", 36 | "utf8", 37 | ], 38 | Array [ 39 | "/tmp", 40 | "utf8", 41 | ], 42 | ] 43 | `; 44 | 45 | exports[`File Operations adds an action to the files 7`] = ` 46 | Array [ 47 | Array [ 48 | "/tmp", 49 | ], 50 | ] 51 | `; 52 | 53 | exports[`File Operations adds multiple actions to the files 1`] = ` 54 | Array [ 55 | Array [ 56 | Object { 57 | "comments": null, 58 | "loc": Object { 59 | "end": Object { 60 | "column": 0, 61 | "line": 1, 62 | }, 63 | "indent": 0, 64 | "lines": Lines {}, 65 | "start": Object { 66 | "column": 0, 67 | "line": 1, 68 | }, 69 | }, 70 | "name": null, 71 | "program": Program { 72 | "body": Array [], 73 | "errors": Array [], 74 | "loc": Object { 75 | "end": Object { 76 | "column": 0, 77 | "line": 1, 78 | }, 79 | "indent": 0, 80 | "lines": Lines {}, 81 | "start": Object { 82 | "column": 0, 83 | "line": 1, 84 | }, 85 | }, 86 | "sourceType": "module", 87 | "type": "Program", 88 | }, 89 | "type": "File", 90 | }, 91 | Object { 92 | "camel": "testOne", 93 | "constant": "TEST_ONE", 94 | }, 95 | Object { 96 | "insertHelper": true, 97 | }, 98 | ], 99 | Array [ 100 | Object { 101 | "comments": null, 102 | "loc": Object { 103 | "end": Object { 104 | "column": 0, 105 | "line": 1, 106 | }, 107 | "indent": 0, 108 | "lines": Lines {}, 109 | "start": Object { 110 | "column": 0, 111 | "line": 1, 112 | }, 113 | }, 114 | "name": null, 115 | "program": Program { 116 | "body": Array [], 117 | "errors": Array [], 118 | "loc": Object { 119 | "end": Object { 120 | "column": 0, 121 | "line": 1, 122 | }, 123 | "indent": 0, 124 | "lines": Lines {}, 125 | "start": Object { 126 | "column": 0, 127 | "line": 1, 128 | }, 129 | }, 130 | "sourceType": "module", 131 | "type": "Program", 132 | }, 133 | "type": "File", 134 | }, 135 | Object { 136 | "camel": "testOne", 137 | "constant": "TEST_ONE", 138 | }, 139 | ], 140 | Array [ 141 | Object { 142 | "comments": null, 143 | "loc": Object { 144 | "end": Object { 145 | "column": 0, 146 | "line": 1, 147 | }, 148 | "indent": 0, 149 | "lines": Lines {}, 150 | "start": Object { 151 | "column": 0, 152 | "line": 1, 153 | }, 154 | }, 155 | "name": null, 156 | "program": Program { 157 | "body": Array [], 158 | "errors": Array [], 159 | "loc": Object { 160 | "end": Object { 161 | "column": 0, 162 | "line": 1, 163 | }, 164 | "indent": 0, 165 | "lines": Lines {}, 166 | "start": Object { 167 | "column": 0, 168 | "line": 1, 169 | }, 170 | }, 171 | "sourceType": "module", 172 | "type": "Program", 173 | }, 174 | "type": "File", 175 | }, 176 | Object { 177 | "camel": "testName", 178 | "constant": "TEST_NAME", 179 | }, 180 | Object { 181 | "insertHelper": true, 182 | }, 183 | ], 184 | Array [ 185 | Object { 186 | "comments": null, 187 | "loc": Object { 188 | "end": Object { 189 | "column": 0, 190 | "line": 1, 191 | }, 192 | "indent": 0, 193 | "lines": Lines {}, 194 | "start": Object { 195 | "column": 0, 196 | "line": 1, 197 | }, 198 | }, 199 | "name": null, 200 | "program": Program { 201 | "body": Array [], 202 | "errors": Array [], 203 | "loc": Object { 204 | "end": Object { 205 | "column": 0, 206 | "line": 1, 207 | }, 208 | "indent": 0, 209 | "lines": Lines {}, 210 | "start": Object { 211 | "column": 0, 212 | "line": 1, 213 | }, 214 | }, 215 | "sourceType": "module", 216 | "type": "Program", 217 | }, 218 | "type": "File", 219 | }, 220 | Object { 221 | "camel": "testName", 222 | "constant": "TEST_NAME", 223 | }, 224 | ], 225 | Array [ 226 | Object { 227 | "comments": null, 228 | "loc": Object { 229 | "end": Object { 230 | "column": 0, 231 | "line": 1, 232 | }, 233 | "indent": 0, 234 | "lines": Lines {}, 235 | "start": Object { 236 | "column": 0, 237 | "line": 1, 238 | }, 239 | }, 240 | "name": null, 241 | "program": Program { 242 | "body": Array [], 243 | "errors": Array [], 244 | "loc": Object { 245 | "end": Object { 246 | "column": 0, 247 | "line": 1, 248 | }, 249 | "indent": 0, 250 | "lines": Lines {}, 251 | "start": Object { 252 | "column": 0, 253 | "line": 1, 254 | }, 255 | }, 256 | "sourceType": "module", 257 | "type": "Program", 258 | }, 259 | "type": "File", 260 | }, 261 | Object { 262 | "camel": "testName", 263 | "constant": "TEST_NAME", 264 | }, 265 | Object { 266 | "insertHelper": true, 267 | }, 268 | ], 269 | Array [ 270 | Object { 271 | "comments": null, 272 | "loc": Object { 273 | "end": Object { 274 | "column": 0, 275 | "line": 1, 276 | }, 277 | "indent": 0, 278 | "lines": Lines {}, 279 | "start": Object { 280 | "column": 0, 281 | "line": 1, 282 | }, 283 | }, 284 | "name": null, 285 | "program": Program { 286 | "body": Array [], 287 | "errors": Array [], 288 | "loc": Object { 289 | "end": Object { 290 | "column": 0, 291 | "line": 1, 292 | }, 293 | "indent": 0, 294 | "lines": Lines {}, 295 | "start": Object { 296 | "column": 0, 297 | "line": 1, 298 | }, 299 | }, 300 | "sourceType": "module", 301 | "type": "Program", 302 | }, 303 | "type": "File", 304 | }, 305 | Object { 306 | "camel": "testName", 307 | "constant": "TEST_NAME", 308 | }, 309 | ], 310 | ] 311 | `; 312 | 313 | exports[`File Operations adds multiple actions to the files 2`] = ` 314 | Array [ 315 | Array [ 316 | Object { 317 | "comments": null, 318 | "loc": Object { 319 | "end": Object { 320 | "column": 0, 321 | "line": 1, 322 | }, 323 | "indent": 0, 324 | "lines": Lines {}, 325 | "start": Object { 326 | "column": 0, 327 | "line": 1, 328 | }, 329 | }, 330 | "name": null, 331 | "program": Program { 332 | "body": Array [], 333 | "errors": Array [], 334 | "loc": Object { 335 | "end": Object { 336 | "column": 0, 337 | "line": 1, 338 | }, 339 | "indent": 0, 340 | "lines": Lines {}, 341 | "start": Object { 342 | "column": 0, 343 | "line": 1, 344 | }, 345 | }, 346 | "sourceType": "module", 347 | "type": "Program", 348 | }, 349 | "type": "File", 350 | }, 351 | Object { 352 | "camel": "testOne", 353 | "constant": "TEST_ONE", 354 | }, 355 | "/tm", 356 | ], 357 | Array [ 358 | Object { 359 | "comments": null, 360 | "loc": Object { 361 | "end": Object { 362 | "column": 0, 363 | "line": 1, 364 | }, 365 | "indent": 0, 366 | "lines": Lines {}, 367 | "start": Object { 368 | "column": 0, 369 | "line": 1, 370 | }, 371 | }, 372 | "name": null, 373 | "program": Program { 374 | "body": Array [], 375 | "errors": Array [], 376 | "loc": Object { 377 | "end": Object { 378 | "column": 0, 379 | "line": 1, 380 | }, 381 | "indent": 0, 382 | "lines": Lines {}, 383 | "start": Object { 384 | "column": 0, 385 | "line": 1, 386 | }, 387 | }, 388 | "sourceType": "module", 389 | "type": "Program", 390 | }, 391 | "type": "File", 392 | }, 393 | Object { 394 | "camel": "testName", 395 | "constant": "TEST_NAME", 396 | }, 397 | "/tm", 398 | ], 399 | Array [ 400 | Object { 401 | "comments": null, 402 | "loc": Object { 403 | "end": Object { 404 | "column": 0, 405 | "line": 1, 406 | }, 407 | "indent": 0, 408 | "lines": Lines {}, 409 | "start": Object { 410 | "column": 0, 411 | "line": 1, 412 | }, 413 | }, 414 | "name": null, 415 | "program": Program { 416 | "body": Array [], 417 | "errors": Array [], 418 | "loc": Object { 419 | "end": Object { 420 | "column": 0, 421 | "line": 1, 422 | }, 423 | "indent": 0, 424 | "lines": Lines {}, 425 | "start": Object { 426 | "column": 0, 427 | "line": 1, 428 | }, 429 | }, 430 | "sourceType": "module", 431 | "type": "Program", 432 | }, 433 | "type": "File", 434 | }, 435 | Object { 436 | "camel": "testName", 437 | "constant": "TEST_NAME", 438 | }, 439 | "/tm", 440 | ], 441 | ] 442 | `; 443 | 444 | exports[`File Operations adds multiple actions to the files 3`] = ` 445 | Array [ 446 | Array [ 447 | Object { 448 | "comments": null, 449 | "loc": Object { 450 | "end": Object { 451 | "column": 0, 452 | "line": 1, 453 | }, 454 | "indent": 0, 455 | "lines": Lines {}, 456 | "start": Object { 457 | "column": 0, 458 | "line": 1, 459 | }, 460 | }, 461 | "name": null, 462 | "program": Program { 463 | "body": Array [], 464 | "errors": Array [], 465 | "loc": Object { 466 | "end": Object { 467 | "column": 0, 468 | "line": 1, 469 | }, 470 | "indent": 0, 471 | "lines": Lines {}, 472 | "start": Object { 473 | "column": 0, 474 | "line": 1, 475 | }, 476 | }, 477 | "sourceType": "module", 478 | "type": "Program", 479 | }, 480 | "type": "File", 481 | }, 482 | Object { 483 | "camel": "testOne", 484 | "constant": "TEST_ONE", 485 | }, 486 | ], 487 | Array [ 488 | Object { 489 | "comments": null, 490 | "loc": Object { 491 | "end": Object { 492 | "column": 0, 493 | "line": 1, 494 | }, 495 | "indent": 0, 496 | "lines": Lines {}, 497 | "start": Object { 498 | "column": 0, 499 | "line": 1, 500 | }, 501 | }, 502 | "name": null, 503 | "program": Program { 504 | "body": Array [], 505 | "errors": Array [], 506 | "loc": Object { 507 | "end": Object { 508 | "column": 0, 509 | "line": 1, 510 | }, 511 | "indent": 0, 512 | "lines": Lines {}, 513 | "start": Object { 514 | "column": 0, 515 | "line": 1, 516 | }, 517 | }, 518 | "sourceType": "module", 519 | "type": "Program", 520 | }, 521 | "type": "File", 522 | }, 523 | Object { 524 | "camel": "testName", 525 | "constant": "TEST_NAME", 526 | }, 527 | ], 528 | Array [ 529 | Object { 530 | "comments": null, 531 | "loc": Object { 532 | "end": Object { 533 | "column": 0, 534 | "line": 1, 535 | }, 536 | "indent": 0, 537 | "lines": Lines {}, 538 | "start": Object { 539 | "column": 0, 540 | "line": 1, 541 | }, 542 | }, 543 | "name": null, 544 | "program": Program { 545 | "body": Array [], 546 | "errors": Array [], 547 | "loc": Object { 548 | "end": Object { 549 | "column": 0, 550 | "line": 1, 551 | }, 552 | "indent": 0, 553 | "lines": Lines {}, 554 | "start": Object { 555 | "column": 0, 556 | "line": 1, 557 | }, 558 | }, 559 | "sourceType": "module", 560 | "type": "Program", 561 | }, 562 | "type": "File", 563 | }, 564 | Object { 565 | "camel": "testName", 566 | "constant": "TEST_NAME", 567 | }, 568 | ], 569 | ] 570 | `; 571 | 572 | exports[`File Operations adds multiple actions to the files 4`] = ` 573 | Array [ 574 | Array [ 575 | Object { 576 | "comments": null, 577 | "loc": Object { 578 | "end": Object { 579 | "column": 0, 580 | "line": 1, 581 | }, 582 | "indent": 0, 583 | "lines": Lines {}, 584 | "start": Object { 585 | "column": 0, 586 | "line": 1, 587 | }, 588 | }, 589 | "name": null, 590 | "program": Program { 591 | "body": Array [], 592 | "errors": Array [], 593 | "loc": Object { 594 | "end": Object { 595 | "column": 0, 596 | "line": 1, 597 | }, 598 | "indent": 0, 599 | "lines": Lines {}, 600 | "start": Object { 601 | "column": 0, 602 | "line": 1, 603 | }, 604 | }, 605 | "sourceType": "module", 606 | "type": "Program", 607 | }, 608 | "type": "File", 609 | }, 610 | Object { 611 | "camel": "testOne", 612 | "constant": "TEST_ONE", 613 | }, 614 | ], 615 | Array [ 616 | Object { 617 | "comments": null, 618 | "loc": Object { 619 | "end": Object { 620 | "column": 0, 621 | "line": 1, 622 | }, 623 | "indent": 0, 624 | "lines": Lines {}, 625 | "start": Object { 626 | "column": 0, 627 | "line": 1, 628 | }, 629 | }, 630 | "name": null, 631 | "program": Program { 632 | "body": Array [], 633 | "errors": Array [], 634 | "loc": Object { 635 | "end": Object { 636 | "column": 0, 637 | "line": 1, 638 | }, 639 | "indent": 0, 640 | "lines": Lines {}, 641 | "start": Object { 642 | "column": 0, 643 | "line": 1, 644 | }, 645 | }, 646 | "sourceType": "module", 647 | "type": "Program", 648 | }, 649 | "type": "File", 650 | }, 651 | Object { 652 | "camel": "testName", 653 | "constant": "TEST_NAME", 654 | }, 655 | ], 656 | Array [ 657 | Object { 658 | "comments": null, 659 | "loc": Object { 660 | "end": Object { 661 | "column": 0, 662 | "line": 1, 663 | }, 664 | "indent": 0, 665 | "lines": Lines {}, 666 | "start": Object { 667 | "column": 0, 668 | "line": 1, 669 | }, 670 | }, 671 | "name": null, 672 | "program": Program { 673 | "body": Array [], 674 | "errors": Array [], 675 | "loc": Object { 676 | "end": Object { 677 | "column": 0, 678 | "line": 1, 679 | }, 680 | "indent": 0, 681 | "lines": Lines {}, 682 | "start": Object { 683 | "column": 0, 684 | "line": 1, 685 | }, 686 | }, 687 | "sourceType": "module", 688 | "type": "Program", 689 | }, 690 | "type": "File", 691 | }, 692 | Object { 693 | "camel": "testName", 694 | "constant": "TEST_NAME", 695 | }, 696 | ], 697 | ] 698 | `; 699 | 700 | exports[`File Operations adds multiple actions to the files 5`] = ` 701 | Array [ 702 | Array [ 703 | "/tmp", 704 | "", 705 | ], 706 | Array [ 707 | "/tmp", 708 | "", 709 | ], 710 | Array [ 711 | "/tmp", 712 | "", 713 | ], 714 | ] 715 | `; 716 | 717 | exports[`File Operations adds multiple actions to the files 6`] = ` 718 | Array [ 719 | Array [ 720 | "/tmp", 721 | "utf8", 722 | ], 723 | Array [ 724 | "/tmp", 725 | "utf8", 726 | ], 727 | Array [ 728 | "/tmp", 729 | "utf8", 730 | ], 731 | ] 732 | `; 733 | 734 | exports[`File Operations adds multiple actions to the files 7`] = ` 735 | Array [ 736 | Array [ 737 | "/tmp", 738 | ], 739 | ] 740 | `; 741 | 742 | exports[`File Operations creates files that are not preset 1`] = `Array []`; 743 | 744 | exports[`File Operations creates files that are not preset 2`] = `Array []`; 745 | 746 | exports[`File Operations creates files that are not preset 3`] = `Array []`; 747 | 748 | exports[`File Operations creates files that are not preset 4`] = `Array []`; 749 | 750 | exports[`File Operations creates files that are not preset 5`] = ` 751 | Array [ 752 | Array [ 753 | "/tmp", 754 | "", 755 | ], 756 | Array [ 757 | "/tmp", 758 | "", 759 | ], 760 | Array [ 761 | "/tmp", 762 | "", 763 | ], 764 | Array [ 765 | "/tmp", 766 | "", 767 | ], 768 | Array [ 769 | "/tmp", 770 | "", 771 | ], 772 | Array [ 773 | "/tmp", 774 | "", 775 | ], 776 | ] 777 | `; 778 | 779 | exports[`File Operations creates files that are not preset 6`] = ` 780 | Array [ 781 | Array [ 782 | "/tmp", 783 | "utf8", 784 | ], 785 | Array [ 786 | "/tmp", 787 | "utf8", 788 | ], 789 | Array [ 790 | "/tmp", 791 | "utf8", 792 | ], 793 | Array [ 794 | "/tmp", 795 | "utf8", 796 | ], 797 | ] 798 | `; 799 | 800 | exports[`File Operations creates files that are not preset 7`] = ` 801 | Array [ 802 | Array [ 803 | "/tmp", 804 | ], 805 | ] 806 | `; 807 | -------------------------------------------------------------------------------- /src/__tests__/cli.test.js: -------------------------------------------------------------------------------- 1 | /* eslint-env jest */ 2 | 3 | import webpack from 'webpack'; 4 | import fs from 'fs'; 5 | import { join } from 'path'; 6 | import mkdirp from 'mkdirp'; 7 | import del from 'del'; 8 | import run from '../testUtils'; 9 | import webpackConfig from '../../webpack.config.babel'; 10 | 11 | describe('cli', () => { 12 | beforeAll(done => { 13 | webpack(webpackConfig[1], done); 14 | }); 15 | 16 | it('adds actions to existing files in dry run', () => { 17 | const cmd = run(join(__dirname, '../__testfixtures__'), [ 18 | '--dir', 19 | './addToExisting', 20 | 'oneAction', 21 | 'twoAction', 22 | '--dry', 23 | '--single-quote', 24 | '--trailing-comma', 25 | 'all', 26 | ]); 27 | expect(cmd.stderr).toEqual(''); 28 | expect(cmd.stdout).toMatchSnapshot(); 29 | }); 30 | 31 | it('creates files if they are not present', () => { 32 | const dir = join(__dirname, '../__testfixtures__/blank'); 33 | mkdirp.sync(dir); 34 | const cmd = run(join(__dirname, '../__testfixtures__'), [ 35 | '--dir', 36 | './blank', 37 | 'oneAction', 38 | 'twoAction', 39 | '--single-quote', 40 | '--trailing-comma', 41 | 'all', 42 | ]); 43 | const constResult = fs.readFileSync(join(dir, 'constants.js'), 'utf8'); 44 | const actionsResult = fs.readFileSync(join(dir, 'actions.js'), 'utf8'); 45 | const reducerResult = fs.readFileSync(join(dir, 'reducer.js'), 'utf8'); 46 | expect(cmd.stderr).toEqual(''); 47 | expect(constResult).toMatchSnapshot(); 48 | expect(actionsResult).toMatchSnapshot(); 49 | expect(reducerResult).toMatchSnapshot(); 50 | del.sync([join(__dirname, '../__testfixtures__/blank/**')]); 51 | }); 52 | }); 53 | -------------------------------------------------------------------------------- /src/__tests__/createAction.test.js: -------------------------------------------------------------------------------- 1 | /* eslint-env jest */ 2 | import recast from 'recast'; 3 | import { 4 | generateNames, 5 | setImports, 6 | createAction, 7 | parseOptions, 8 | createReducerCase, 9 | createConst, 10 | } from '../createAction'; 11 | 12 | describe('createAction', () => { 13 | const name = generateNames('TEST_ENTRY'); 14 | 15 | describe('Imports', () => { 16 | const bodycode = [ 17 | 'function something() {', 18 | ' console.log("test");', 19 | '}', 20 | 'const x = 10;', 21 | 'export default something', 22 | ]; 23 | it('creats a new import statement if it does not exist', () => { 24 | const header = [ 25 | 'import { ONE, TWO, THREE } from "othermodule";', 26 | 'import module from "./something";', 27 | ]; 28 | const input = [...header, ...bodycode].join('\n'); 29 | const ast = recast.parse(input, parseOptions); 30 | 31 | setImports(ast, name); 32 | const result = recast.print(ast).code; 33 | expect(result).toEqual( 34 | [...header, `import { ${name.constant} } from "./constants";`, ...bodycode].join('\n'), 35 | ); 36 | }); 37 | 38 | it('adds the action to an existing import statment', () => { 39 | const header = [ 40 | "import { ONE, TWO, THREE } from './constants';", 41 | 'import module from "./something";', 42 | ]; 43 | const input = [...header, ...bodycode].join('\n'); 44 | const ast = recast.parse(input, parseOptions); 45 | 46 | setImports(ast, name); 47 | const result = recast.print(ast).code; 48 | expect(result).toEqual( 49 | [ 50 | `import { ONE, TWO, THREE, ${name.constant} } from './constants';`, 51 | header[1], 52 | ...bodycode, 53 | ].join('\n'), 54 | ); 55 | }); 56 | 57 | it('does not modify imports if it exists already', () => { 58 | const input = [ 59 | `import { ONE, TWO, THREE, ${name.constant} } from './constants';`, 60 | 'import module from "./something";', 61 | ...bodycode, 62 | ].join('\n'); 63 | const ast = recast.parse(input, parseOptions); 64 | 65 | setImports(ast, name); 66 | const result = recast.print(ast).code; 67 | expect(result).toEqual(input); 68 | }); 69 | 70 | it('imports the helper function if it is not there', () => { 71 | const header = [ 72 | "import { ONE, TWO, THREE } from './constants';", 73 | 'import module from "./something";', 74 | ]; 75 | const input = [...header, ...bodycode].join('\n'); 76 | const ast = recast.parse(input, parseOptions); 77 | 78 | setImports(ast, name, { insertHelper: true }); 79 | const result = recast.print(ast).code; 80 | expect(result).toEqual( 81 | [ 82 | 'import { createAction } from "redux-boilerplate-helpers";', 83 | `import { ONE, TWO, THREE, ${name.constant} } from './constants';`, 84 | header[1], 85 | ...bodycode, 86 | ].join('\n'), 87 | ); 88 | }); 89 | 90 | it('does not add helper function if it is already there', () => { 91 | const header = [ 92 | 'import { createAction } from "redux-boilerplate-helpers";', 93 | "import { ONE, TWO, THREE } from './constants';", 94 | 'import module from "./something";', 95 | ]; 96 | const input = [...header, ...bodycode].join('\n'); 97 | const ast = recast.parse(input, parseOptions); 98 | 99 | setImports(ast, name, { insertHelper: true }); 100 | const result = recast.print(ast).code; 101 | expect(result).toEqual( 102 | [ 103 | header[0], 104 | `import { ONE, TWO, THREE, ${name.constant} } from './constants';`, 105 | header[2], 106 | ...bodycode, 107 | ].join('\n'), 108 | ); 109 | }); 110 | }); 111 | 112 | describe('Action Creator', () => { 113 | it('creates an action creator for the action', () => { 114 | const input = [ 115 | 'import { createAction } from "redux-boilerplate-helpers";', 116 | `import { ONE, ${name.constant} } from './constants';`, 117 | 'export const one = createAction(ONE);', 118 | ].join('\n'); 119 | 120 | const ast = recast.parse(input, parseOptions); 121 | 122 | createAction(ast, name); 123 | const result = recast.print(ast).code; 124 | expect(result).toEqual( 125 | [input, `export const ${name.camel} = createAction(${name.constant});`].join('\n'), 126 | ); 127 | }); 128 | 129 | it('does not create an action creator if one already exists', () => {}); 130 | const input = [ 131 | 'import { createAction } from "redux-boilerplate-helpers";', 132 | `import { ONE, ${name.constant} } from './constants';`, 133 | 'export const one = createAction(ONE);', 134 | `export const ${name.camel} = createAction(${name.constant});`, 135 | ].join('\n'); 136 | 137 | const ast = recast.parse(input, parseOptions); 138 | 139 | createAction(ast, name); 140 | const result = recast.print(ast).code; 141 | expect(result).toEqual(input); 142 | }); 143 | 144 | describe('Reducer Case', () => { 145 | it('creates an entry for the action handler above default', () => { 146 | const input = [ 147 | 'import { createAction } from "redux-boilerplate-helpers";', 148 | `import { ONE, ${name.constant} } from './constants';`, 149 | 'function testReducer(state = initialState, action) {', 150 | ' switch(action.type) {', 151 | ' case ONE:', 152 | ' return { ...state, one: action.payload };', 153 | ' default:', 154 | ' return state;', 155 | ' }', 156 | '}', 157 | 'export default testReducer', 158 | ].join('\n'); 159 | 160 | const ast = recast.parse(input, parseOptions); 161 | createReducerCase(ast, name); 162 | expect(ast).toMatchSnapshot(); 163 | }); 164 | 165 | it('creates an entry for the action handler at the end', () => { 166 | const input = [ 167 | 'import { createAction } from "redux-boilerplate-helpers";', 168 | `import { ONE, ${name.constant} } from './constants';`, 169 | 'function testReducer(state = initialState, action) {', 170 | ' switch(action.type) {', 171 | ' case ONE:', 172 | ' return { ...state, one: action.payload };', 173 | ' }', 174 | '}', 175 | 'export default testReducer', 176 | ].join('\n'); 177 | 178 | const ast = recast.parse(input, parseOptions); 179 | createReducerCase(ast, name); 180 | expect(ast).toMatchSnapshot(); 181 | }); 182 | 183 | it('does not make any changes if the action is already handled', () => { 184 | const input = [ 185 | 'import { createAction } from "redux-boilerplate-helpers";', 186 | `import { ONE, ${name.constant} } from './constants';`, 187 | 'function testReducer(state = initialState, action) {', 188 | ' switch(action.type) {', 189 | ` case ${name.constant}:`, 190 | ' return { ...state, result: action.payload };', 191 | ' case ONE:', 192 | ' return { ...state, one: action.payload };', 193 | ' default:', 194 | ' return state;', 195 | ' }', 196 | '}', 197 | 'export default testReducer', 198 | ].join('\n'); 199 | const ast = recast.parse(input, parseOptions); 200 | createReducerCase(ast, name); 201 | const result = recast.print(ast).code; 202 | expect(result).toEqual(input); 203 | }); 204 | }); 205 | 206 | describe('Constant', () => { 207 | it('adds a constant to the constants file', () => { 208 | const input = ['export const ONE = "/test/ONE";', 'export const TWO = "/test/TWO";'].join( 209 | '\n', 210 | ); 211 | const ast = recast.parse(input, parseOptions); 212 | createConst(ast, name, '/test'); 213 | const result = recast.print(ast).code; 214 | expect(result).toEqual( 215 | [input, `export const ${name.constant} = "/test/${name.constant}";`].join('\n'), 216 | ); 217 | }); 218 | 219 | it('will not add a constant if it is already there', () => { 220 | const input = [ 221 | 'export const ONE = "/test/ONE";', 222 | `export const ${name.constant} = "/test/${name.constant}";`, 223 | 'export const TWO = "/test/TWO";', 224 | ].join('\n'); 225 | const ast = recast.parse(input, parseOptions); 226 | createConst(ast, name, '/test'); 227 | const result = recast.print(ast).code; 228 | expect(result).toEqual(result); 229 | }); 230 | }); 231 | }); 232 | -------------------------------------------------------------------------------- /src/__tests__/fileOperations.test.js: -------------------------------------------------------------------------------- 1 | /* eslint-env jest */ 2 | 3 | import fs from 'fs'; 4 | import addReduxActions from '../fileOperations'; 5 | import { 6 | generateNames, 7 | setImports, 8 | createAction, 9 | createReducerCase, 10 | createConst, 11 | } from '../createAction'; 12 | 13 | jest.mock('../createAction.js', () => ({ 14 | generateNames: jest.fn(() => ({ camel: 'testName', constant: 'TEST_NAME' })), 15 | setImports: jest.fn(), 16 | createAction: jest.fn(), 17 | createReducerCase: jest.fn(), 18 | createConst: jest.fn(), 19 | })); 20 | 21 | jest.mock('fs', () => ({ 22 | readdirSync: jest.fn(() => ['constants.js', 'actions.js', 'reducer.js']), 23 | readFileSync: jest.fn(() => ''), 24 | writeFileSync: jest.fn(), 25 | })); 26 | 27 | jest.mock('path', () => ({ 28 | join: jest.fn(() => '/tmp'), 29 | isAbsolute: jest.fn(() => false), 30 | })); 31 | 32 | describe('File Operations', () => { 33 | afterEach(() => { 34 | generateNames.mockClear(); 35 | setImports.mockClear(); 36 | createAction.mockClear(); 37 | createReducerCase.mockClear(); 38 | createConst.mockClear(); 39 | fs.readFileSync.mockClear(); 40 | fs.writeFileSync.mockClear(); 41 | fs.readdirSync.mockClear(); 42 | }); 43 | 44 | it('adds an action to the files', () => { 45 | addReduxActions('./', []); 46 | 47 | expect(setImports.mock.calls).toMatchSnapshot(); 48 | expect(createConst.mock.calls).toMatchSnapshot(); 49 | expect(createAction.mock.calls).toMatchSnapshot(); 50 | expect(createReducerCase.mock.calls).toMatchSnapshot(); 51 | expect(fs.writeFileSync.mock.calls).toMatchSnapshot(); 52 | expect(fs.readFileSync.mock.calls).toMatchSnapshot(); 53 | expect(fs.readdirSync.mock.calls).toMatchSnapshot(); 54 | }); 55 | 56 | it('adds multiple actions to the files', () => { 57 | const generateNamesOrig = require.requireActual('../createAction').generateNames; 58 | generateNames.mockImplementationOnce(generateNamesOrig); 59 | addReduxActions('./', ['testOne', 'testTwo', 'testThree']); 60 | 61 | expect(setImports.mock.calls).toMatchSnapshot(); 62 | expect(createConst.mock.calls).toMatchSnapshot(); 63 | expect(createAction.mock.calls).toMatchSnapshot(); 64 | expect(createReducerCase.mock.calls).toMatchSnapshot(); 65 | expect(fs.writeFileSync.mock.calls).toMatchSnapshot(); 66 | expect(fs.readFileSync.mock.calls).toMatchSnapshot(); 67 | expect(fs.readdirSync.mock.calls).toMatchSnapshot(); 68 | }); 69 | 70 | it('creates files that are not preset', () => { 71 | setImports.mockReset(); 72 | fs.readdirSync.mockImplementationOnce(() => []); 73 | addReduxActions('./', []); 74 | 75 | expect(setImports.mock.calls).toMatchSnapshot(); 76 | expect(createConst.mock.calls).toMatchSnapshot(); 77 | expect(createAction.mock.calls).toMatchSnapshot(); 78 | expect(createReducerCase.mock.calls).toMatchSnapshot(); 79 | expect(fs.writeFileSync.mock.calls).toMatchSnapshot(); 80 | expect(fs.readFileSync.mock.calls).toMatchSnapshot(); 81 | expect(fs.readdirSync.mock.calls).toMatchSnapshot(); 82 | }); 83 | 84 | it('does a dry run', () => { 85 | const log = console.log; 86 | console.log = jest.fn(); 87 | 88 | addReduxActions('./', [], { dry: true }); 89 | console.log = log; 90 | }); 91 | }); 92 | -------------------------------------------------------------------------------- /src/__tests__/helper.test.js: -------------------------------------------------------------------------------- 1 | /* eslint-env jest */ 2 | import { createAction } from '../helper'; 3 | 4 | describe('helper function', () => { 5 | it('creates an action with a given payloadCreator', () => { 6 | const TEST_ACTION = 'test/TEST_ACTION'; 7 | const testAction = createAction(TEST_ACTION, (input1, input2) => input1 + input2); 8 | 9 | const result = testAction(3, 4); 10 | expect(result).toEqual({ type: TEST_ACTION, payload: 7 }); 11 | }); 12 | 13 | it('uses an identity function when no function is passed in', () => { 14 | const TEST_ACTION = 'test/TEST_ACTION'; 15 | const testAction = createAction(TEST_ACTION); 16 | 17 | const result = testAction('test'); 18 | expect(result).toEqual({ type: TEST_ACTION, payload: 'test' }); 19 | }); 20 | 21 | it('allows the name of the payload field to be renamed', () => { 22 | const TEST_ACTION = 'test/TEST_ACTION'; 23 | const testAction = createAction(TEST_ACTION, null, { name: 'error' }); 24 | 25 | const result = testAction(new Error('test')); 26 | expect(result).toEqual({ type: TEST_ACTION, error: new Error('test') }); 27 | }); 28 | 29 | it('allows a meta field to be added', () => { 30 | const TEST_ACTION = 'test/TEST_ACTION'; 31 | const testAction = createAction(TEST_ACTION, null, { meta: (_, m) => m }); 32 | 33 | const result = testAction(3, 'meta'); 34 | expect(result).toEqual({ type: TEST_ACTION, payload: 3, meta: 'meta' }); 35 | }); 36 | }); 37 | -------------------------------------------------------------------------------- /src/cli.js: -------------------------------------------------------------------------------- 1 | import parseArgs from 'minimist'; 2 | import addReduxActions from './fileOperations'; 3 | 4 | const argv = parseArgs(process.argv.slice(2), { 5 | boolean: ['dry', 'semi', 'use-tabs', 'single0quote', 'bracket-spacing', 'verbose'], 6 | number: ['print-width', 'tab-width'], 7 | string: ['dir', 'trailing-comma'], 8 | default: { 9 | dir: './', 10 | semi: true, 11 | 'bracket-spacing': true, 12 | }, 13 | }); 14 | 15 | // eslint-disable-next-line no-shadow 16 | const getOptions = argv => ({ 17 | dry: argv.dry, 18 | prettier: { 19 | printWidth: argv['print-width'], 20 | tabWidth: argv['tab-width'], 21 | useTabs: argv['use-tabs'], 22 | semi: argv.semi, 23 | singleQuote: argv['single-quote'], 24 | trailingComma: argv['trailing-comma'], 25 | bracketSpacing: argv['bracket-spacing'], 26 | }, 27 | }); 28 | 29 | addReduxActions(argv.dir, argv._, getOptions(argv)); 30 | -------------------------------------------------------------------------------- /src/createAction.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | import recast, { types } from 'recast'; 3 | import { constant, camel } from 'change-case'; 4 | import assert from 'assert'; 5 | 6 | const n = types.namedTypes; 7 | const b = types.builders; 8 | 9 | export const parseOptions = { 10 | parser: { 11 | parse(source: Object) { 12 | // eslint-disable-next-line global-require 13 | return require('babylon').parse(source, { 14 | sourceType: 'module', 15 | plugins: ['flow', 'jsx', 'objectRestSpread'], 16 | }); 17 | }, 18 | }, 19 | }; 20 | 21 | type Names = { 22 | constant: string, 23 | camel: string, 24 | }; 25 | export const generateNames = (varName: string): Names => ({ 26 | constant: constant(varName), 27 | camel: camel(varName), 28 | }); 29 | 30 | export const setImports = ( 31 | ast: Object, 32 | name: Names, 33 | { 34 | insertHelper, 35 | moduleName = 'redux-boilerplate-helpers', 36 | }: { insertHelper?: boolean, moduleName?: string } = {}, 37 | ) => { 38 | // get all the import declarations in file 39 | const importStatements = ast.program.body.filter(node => n.ImportDeclaration.check(node)); 40 | 41 | // check if file is importing from adjacent constants.js file 42 | const constImport = importStatements.filter( 43 | node => n.Literal.check(node.source) && node.source.value === './constants', 44 | ); 45 | 46 | if (constImport.length > 0) { 47 | const specifiers = constImport[0].specifiers; 48 | const importExists = specifiers 49 | .map(specifier => specifier && specifier.local && specifier.local.name) 50 | .includes(name.constant); 51 | 52 | if (!importExists) { 53 | const newImport = b.importSpecifier(b.identifier(name.constant)); 54 | specifiers.push(newImport); 55 | } 56 | } else { 57 | const importStatement = b.importDeclaration( 58 | [b.importSpecifier(b.identifier(name.constant))], 59 | b.literal('./constants'), 60 | ); 61 | ast.program.body.splice(importStatements.length, 0, importStatement); 62 | } 63 | 64 | if (insertHelper) { 65 | const checkForHelper = node => { 66 | const hasLiteral = n.Literal.check(node.source); 67 | const hasIdentifier = node.specifiers.map(n.ImportSpecifier.check).every(val => val === true); 68 | const correctLiteral = node.source.value === moduleName; 69 | 70 | // make sure the other conditions are true before checking this one 71 | const containsSpecifier = () => 72 | node.specifiers 73 | .map(specifier => specifier.imported) 74 | .map(imported => imported.name) 75 | .includes('createAction'); 76 | return hasLiteral && hasIdentifier && correctLiteral && containsSpecifier(); 77 | }; 78 | const helperImports = importStatements.filter(checkForHelper); 79 | 80 | if (helperImports.length <= 0) { 81 | const newHelperImport = b.importDeclaration( 82 | [b.importSpecifier(b.identifier('createAction'))], 83 | b.literal(moduleName), 84 | ); 85 | ast.program.body.unshift(newHelperImport); 86 | } 87 | } 88 | }; 89 | 90 | export const tokenUsed = (ast: Object, name: Names) => { 91 | let exists = false; 92 | recast.visit(ast, { 93 | visitIdentifier(path) { 94 | const node = path.node; 95 | if (node.name === name.constant && !n.ImportSpecifier.check(path.parent.node)) { 96 | exists = true; 97 | this.abort(); 98 | } 99 | this.traverse(path); 100 | }, 101 | }); 102 | return exists; 103 | }; 104 | 105 | export const createAction = (ast: Object, name: Names) => { 106 | const exists = tokenUsed(ast, name); 107 | 108 | if (!exists) { 109 | const newActionCreator = b.exportNamedDeclaration( 110 | b.variableDeclaration('const', [ 111 | b.variableDeclarator( 112 | b.identifier(name.camel), 113 | b.callExpression(b.identifier('createAction'), [b.identifier(name.constant)]), 114 | ), 115 | ]), 116 | ); 117 | ast.program.body.push(newActionCreator); 118 | } 119 | }; 120 | 121 | export const createReducerCase = (ast: Object, name: Names) => { 122 | const exists = tokenUsed(ast, name); 123 | 124 | const insertIntoSwitch = (switchStatement, caseStatement) => { 125 | assert(n.SwitchStatement.check(switchStatement)); 126 | assert(n.SwitchCase.check(caseStatement)); 127 | const numCases = switchStatement.cases.length; 128 | const defaultPresent = switchStatement.cases[numCases - 1].test === null; 129 | if (defaultPresent) { 130 | switchStatement.cases.splice(numCases - 1, 0, caseStatement); 131 | } else { 132 | switchStatement.cases.push(caseStatement); 133 | } 134 | }; 135 | 136 | if (!exists) { 137 | recast.visit(ast, { 138 | visitSwitchStatement(path) { 139 | const node = path.node; 140 | assert(n.SwitchStatement.check(node)); 141 | if ( 142 | node.discriminant.object.name === 'action' && 143 | node.discriminant.property.name === 'type' 144 | ) { 145 | const newCase = b.switchCase(b.identifier(name.constant), [ 146 | b.returnStatement(b.objectExpression([b.spreadProperty(b.identifier('state'))])), 147 | ]); 148 | insertIntoSwitch(node, newCase); 149 | this.abort(); 150 | } 151 | this.traverse(path); 152 | }, 153 | }); 154 | } 155 | }; 156 | 157 | export const createConst = (ast: Object, name: Names, prefix: string) => { 158 | const exists = tokenUsed(ast, name); 159 | if (!exists) { 160 | const newExport = b.exportNamedDeclaration( 161 | b.variableDeclaration('const', [ 162 | b.variableDeclarator(b.identifier(name.constant), b.literal(`${prefix}/${name.constant}`)), 163 | ]), 164 | ); 165 | ast.program.body.push(newExport); 166 | } 167 | }; 168 | -------------------------------------------------------------------------------- /src/fileOperations.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | import fs from 'fs'; 3 | import { join, isAbsolute, sep } from 'path'; 4 | import recast from 'recast'; 5 | import prettier from 'prettier'; 6 | 7 | import { 8 | generateNames, 9 | setImports, 10 | createAction, 11 | parseOptions, 12 | createReducerCase, 13 | createConst, 14 | } from './createAction'; 15 | 16 | const addReduxActions = (dir: string, actions: Array, options: Object = {}) => { 17 | const names = actions.map(generateNames); 18 | const prefixDir = dir[dir.length - 1] !== sep ? `${dir}${sep}` : dir; 19 | const workingDir = isAbsolute(prefixDir) ? prefixDir : join(process.cwd(), prefixDir); 20 | const prefix = workingDir.split(sep).slice(-2).join('/').slice(0, -1); 21 | const files = fs.readdirSync(workingDir); 22 | 23 | if (!files.includes('constants.js')) { 24 | fs.writeFileSync(join(workingDir, 'constants.js'), ''); 25 | } 26 | 27 | if (!files.includes('actions.js')) { 28 | fs.writeFileSync(join(workingDir, 'actions.js'), ''); 29 | } 30 | 31 | if (!files.includes('reducer.js')) { 32 | const reducerTemplate = fs.readFileSync(join(__dirname, '../assets/reducer.js'), 'utf8'); 33 | fs.writeFileSync( 34 | join(workingDir, 'reducer.js'), 35 | prettier.format(reducerTemplate, options.prettier), 36 | ); 37 | } 38 | 39 | const constantsFile = fs.readFileSync(join(workingDir, 'constants.js'), 'utf8'); 40 | const constantsAst = recast.parse(constantsFile, parseOptions); 41 | 42 | const actionsFile = fs.readFileSync(join(workingDir, 'actions.js'), 'utf8'); 43 | const actionsAst = recast.parse(actionsFile, parseOptions); 44 | 45 | const reducerFile = fs.readFileSync(join(workingDir, 'reducer.js'), 'utf8'); 46 | const reducerAst = recast.parse(reducerFile, parseOptions); 47 | 48 | names.forEach(name => { 49 | createConst(constantsAst, name, prefix); 50 | 51 | setImports(actionsAst, name, { insertHelper: true }); 52 | createAction(actionsAst, name); 53 | 54 | setImports(reducerAst, name); 55 | createReducerCase(reducerAst, name); 56 | }); 57 | 58 | // const constantsResult = prettier.__debug.formatAST(constantsAst, options.prettier).formatted; 59 | // const actionsResult = prettier.__debug.formatAST(actionsAst, options.prettier).formatted; 60 | // const reducerResult = prettier.__debug.formatAST(reducerAst, options.prettier).formatted; 61 | 62 | const constantsResult = prettier.format(recast.print(constantsAst).code, options.prettier); 63 | const actionsResult = prettier.format(recast.print(actionsAst).code, options.prettier); 64 | const reducerResult = prettier.format(recast.print(reducerAst).code, options.prettier); 65 | 66 | if (options.dry) { 67 | console.log(`==== ${join(dir, 'constants.js')} ====`); 68 | console.log(constantsResult); 69 | console.log(`==== ${join(dir, 'actions.js')} ====`); 70 | console.log(actionsResult); 71 | console.log(`==== ${join(dir, 'reducer.js')} ====`); 72 | console.log(reducerResult); 73 | } else { 74 | fs.writeFileSync(join(workingDir, 'constants.js'), constantsResult); 75 | fs.writeFileSync(join(workingDir, 'actions.js'), actionsResult); 76 | fs.writeFileSync(join(workingDir, 'reducer.js'), reducerResult); 77 | } 78 | }; 79 | 80 | export default addReduxActions; 81 | -------------------------------------------------------------------------------- /src/helper.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | import invariant from 'invariant'; 3 | 4 | export const identity = (payload: I): I => payload; 5 | const defaultName = 'payload'; 6 | 7 | type Action = {| 8 | type: string, 9 | [key: string]: A, 10 | meta?: mixed, 11 | |}; 12 | 13 | const createAction = >( 14 | type: string, 15 | payloadCreator: null | (...args: P) => A = identity, 16 | { name = defaultName, meta }: { name: string, meta?: Function } = {}, 17 | ): ((...args: P) => Action) => { 18 | invariant( 19 | payloadCreator instanceof Function || payloadCreator === null, 20 | 'payloadCreator should be a function', 21 | ); 22 | return (...args) => { 23 | const payload = payloadCreator === null ? identity(...args) : payloadCreator(...args); 24 | const action: Action<*> = { 25 | type, 26 | [name]: payload, 27 | }; 28 | 29 | if (meta instanceof Function) { 30 | action.meta = meta(...args); 31 | } 32 | 33 | return action; 34 | }; 35 | }; 36 | 37 | export { createAction }; 38 | export default createAction; 39 | -------------------------------------------------------------------------------- /src/testUtils.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | import path from 'path'; 4 | // eslint-disable-next-line import/no-extraneous-dependencies 5 | import { sync as spawnSync } from 'cross-spawn'; 6 | 7 | export const RDXH_PATH = path.resolve(__dirname, '../bin/index.js'); 8 | 9 | export default (dir: string, args?: Array, options: Object = {}) => { 10 | const isRelative = dir[0] !== '/'; 11 | const cwd = isRelative ? path.resolve(__dirname, dir) : dir; 12 | 13 | const env = options.nodePath ? { ...process.env, NODE_PATH: options.nodedPath } : process.env; 14 | spawnSync('chmod', ['+x', RDXH_PATH]); 15 | const result = spawnSync(RDXH_PATH, args || [], { 16 | cwd, 17 | env, 18 | }); 19 | 20 | result.stdout = result.stdout && result.stdout.toString(); 21 | result.stderr = result.stderr && result.stderr.toString(); 22 | 23 | return result; 24 | }; 25 | -------------------------------------------------------------------------------- /webpack.config.babel.js: -------------------------------------------------------------------------------- 1 | import { join } from 'path'; 2 | import { readFileSync } from 'fs'; 3 | import webpack from 'webpack'; 4 | import nodeExternals from 'webpack-node-externals'; 5 | 6 | const babelrc = JSON.parse(readFileSync(join(__dirname, '.babelrc'))); 7 | 8 | const base = { 9 | module: { 10 | loaders: [ 11 | { 12 | test: /\.js$/, 13 | exclude: /node_modules/, 14 | loader: 'babel-loader', 15 | query: babelrc, 16 | }, 17 | ], 18 | }, 19 | }; 20 | 21 | export const webConfig = { 22 | entry: [join(__dirname, 'src/helper.js')], 23 | ...base, 24 | plugins: [ 25 | new webpack.optimize.UglifyJsPlugin({ 26 | compressor: { 27 | pure_getters: true, 28 | unsafe: true, 29 | unsafe_comps: true, 30 | screw_ie8: true, 31 | warnings: false, 32 | }, 33 | }), 34 | ], 35 | output: { 36 | path: join(__dirname, 'dist'), 37 | filename: 'index.js', 38 | publicPath: '/', 39 | library: 'CreateAction', 40 | libraryTarget: 'umd', 41 | }, 42 | devtool: 'source-map', 43 | }; 44 | 45 | export const toolConfig = { 46 | entry: [join(__dirname, 'src/cli.js')], 47 | plugins: [new webpack.BannerPlugin({ banner: '#!/usr/bin/env node', raw: true })], 48 | ...base, 49 | output: { 50 | path: join(__dirname, 'bin'), 51 | filename: 'index.js', 52 | publicPath: '/', 53 | }, 54 | target: 'node', 55 | node: { 56 | __dirname: false, 57 | }, 58 | externals: [nodeExternals()], 59 | }; 60 | 61 | export default [webConfig, toolConfig]; 62 | --------------------------------------------------------------------------------