Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .babelrc

This file was deleted.

15 changes: 0 additions & 15 deletions .babelrc.js

This file was deleted.

25 changes: 16 additions & 9 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,28 @@
"class-methods-use-this": "off",
"default-case": "off",
"import/no-extraneous-dependencies": ["error", { "devDependencies": true }],
"no-underscore-dangle": ["error", {
"allow": ["__REDUX_DEVTOOLS_EXTENSION__"],
}],
"prettier/prettier": ["error", {
"semi": false,
"singleQuote": true,
"trailingComma": "es5"
}],
"no-underscore-dangle": [
"error",
{
"allow": ["__REDUX_DEVTOOLS_EXTENSION__"]
}
],
"prettier/prettier": [
"error",
{
"semi": false,
"singleQuote": true,
"trailingComma": "es5"
}
],
"react/destructuring-assignment": "off",
"react/forbid-prop-types": ["error", { "forbid": "any" }],
"react/jsx-filename-extension": ["error", { "extensions": [".js"] }],
"react/no-multi-comp": "off",
"react/prefer-stateless-function": "off",
"react/prop-types": ["error", { "skipUndeclared": true }],
"react/require-default-props": "off",
"react/sort-comp": "off",
"semi": ["error", "never"],
"semi": ["error", "never"]
}
}
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"semi": false,
"singleQuote": true,
"trailingComma": "es5"
}
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.12.3
- export PATH="$HOME/.yarn/bin:$PATH"

language: node_js

node_js:
- "lts/*"
- 'lts/*'
18 changes: 18 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const { BABEL_ENV, NODE_ENV } = process.env
const cjs = BABEL_ENV === 'cjs' || NODE_ENV === 'test'

module.exports = {
presets: [['@babel/env', { modules: false, loose: true }], '@babel/react'],

plugins: [
cjs && '@babel/plugin-transform-modules-commonjs',
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-object-rest-spread',
'babel-plugin-idx',
'annotate-pure-calls',
NODE_ENV !== 'test' && [
Copy link
Author

@ctrlplusb ctrlplusb Nov 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This plugin was breaking my tests. I don't think it is critical to remove prop-types in tests so I have inserted this condition to avoid the issue.

'transform-react-remove-prop-types',
{ mode: 'unsafe-wrap' },
],
].filter(Boolean),
}
6 changes: 6 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"npmClient": "yarn",
"packages": ["packages/*"],
"version": "4.0.4",
Copy link
Author

@ctrlplusb ctrlplusb Nov 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can change the value for version to "independent" in order to move towards independent version numbers.

"workspaces": true
}
77 changes: 30 additions & 47 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
{
"name": "react-automata",
"version": "4.0.4",
"description": "A state machine abstraction for React",
"main": "dist/react-automata.js",
"module": "dist/react-automata.es.js",
"repository": "[email protected]:MicheleBertoli/react-automata.git",
"private": true,
"workspaces": {
"packages": [
"packages/*"
]
},
"author": "Michele Bertoli",
"license": "MIT",
"files": [
"DISCLAIMER",
"dist"
],
"sideEffects": false,
"scripts": {
"prebuild": "rimraf dist",
"build": "rollup -c",
Expand All @@ -21,55 +16,43 @@
"test": "jest"
},
"devDependencies": {
"babel-core": "^6.26.3",
"babel-eslint": "^8.2.3",
"babel-jest": "^23.0.1",
"babel-loader": "^7.1.4",
"babel-plugin-annotate-pure-calls": "^0.3.0",
"babel-plugin-external-helpers": "^6.22.0",
"babel-plugin-idx": "^2.2.0",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-plugin-transform-react-remove-prop-types": "^0.4.13",
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1",
"eslint": "^4.19.1",
"eslint-config-airbnb": "^16.1.0",
"eslint-config-prettier": "^2.9.0",
"@babel/core": "^7.1.6",
"@babel/plugin-external-helpers": "^7.0.0",
"@babel/plugin-proposal-class-properties": "^7.1.0",
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
"@babel/plugin-transform-modules-commonjs": "^7.1.0",
"@babel/preset-env": "^7.1.6",
"@babel/preset-react": "^7.0.0",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^10.0.1 ",
"babel-jest": "^23.6.0",
"babel-loader": "^8.0.4",
"babel-plugin-annotate-pure-calls": "^0.4.0",
"babel-plugin-idx": "^2.4.0",
"babel-plugin-transform-react-remove-prop-types": "^0.4.20",
"eslint": "^5.9.0",
"eslint-config-airbnb": "^17.1.0",
"eslint-config-prettier": "^3.3.0",
"eslint-plugin-import": "^2.12.0",
"eslint-plugin-jsx-a11y": "^6.0.3",
"eslint-plugin-prettier": "^2.6.0",
"eslint-plugin-prettier": "^3.0.0",
"eslint-plugin-react": "^7.8.2",
"html-webpack-plugin": "^3.2.0",
"husky": "^0.14.3",
"idx": "^2.3.0",
"husky": "^1.1.4",
"jest": "^23.5.0",
"lint-staged": "^7.1.3",
"lerna": "^3.4.3",
"lint-staged": "^8.0.4",
"prettier": "^1.14.2",
"react": "^16.4.0",
"react-dom": "^16.4.0",
"react-hot-loader": "4.3.4",
"react-test-renderer": "^16.4.1",
"react-hot-loader": "4.3.12",
"rimraf": "^2.6.2",
"rollup": "^0.64.1",
"rollup-plugin-babel": "^3.0.4",
"rollup": "^0.67.1",
"rollup-plugin-babel": "^4.0.3",
"webpack": "^4.16.5",
"webpack-cli": "^3.0.1",
"webpack-dev-server": "^3.1.4"
},
"dependencies": {
"glob-to-regexp": "^0.4.0",
"hoist-non-react-statics": "^3.0.1",
"invariant": "^2.2.4",
"memoize-one": "^4.0.0",
"prop-types": "^15.6.1",
"xstate": "^3.3.0"
},
"peerDependencies": {
"react": ">=16.3",
"react-test-renderer": ">=16.3"
},
"lint-staged": {
"*.js": [
"eslint --fix",
Expand Down
21 changes: 21 additions & 0 deletions packages/react-automata-test-utilities/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017-present Michele Bertoli

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
29 changes: 29 additions & 0 deletions packages/react-automata-test-utilities/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "react-automata-test-utilities",
"version": "4.0.4",
"description": "Utilities for writing tests against your react-automata implementations",
"main": "dist/react-automata-test-utilities.js",
"module": "dist/react-automata-test-utilities.es.js",
"repository": "[email protected]:MicheleBertoli/react-automata.git",
"license": "MIT",
"files": [
"DISCLAIMER",
"dist"
],
"sideEffects": false,
"devDependencies": {
"react": "^16.4.0",
"react-dom": "^16.4.0",
"react-test-renderer": ">=16.3"
},
"dependencies": {
"idx": "^2.3.0",
"react-automata": "^4.0.4",
"react-automata-utilities": "^4.0.4",
"xstate": "^3.3.0"
},
"peerDependencies": {
"react": ">=16.3",
"react-test-renderer": ">=16.3"
}
}
3 changes: 3 additions & 0 deletions packages/react-automata-test-utilities/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/* eslint-disable import/prefer-default-export */

export { default as testStateMachine } from './testStateMachine'
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import idx from 'idx'
import React from 'react'
import TestRenderer from 'react-test-renderer'
import { getShortestPaths } from 'xstate/lib/graph'
import { stringify } from './utils'
import { stringify } from 'react-automata-utilities'

const testStateMachine = (Component, options = {}) => {
const paths = getShortestPaths(Component.machine, options.extendedState)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react'
import { Action, State, testStateMachine, withStateMachine } from '../src'
import { Action, State, withStateMachine } from 'react-automata'
import { testStateMachine } from '../src'

describe('conditional', () => {
const secondMachine = {
Expand Down
21 changes: 21 additions & 0 deletions packages/react-automata-utilities/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "react-automata-utilities",
"version": "4.0.4",
"description": "Internal utilities for react-automata",
"main": "dist/react-automata-test-utilities.js",
"module": "dist/react-automata-test-utilities.es.js",
"repository": "[email protected]:MicheleBertoli/react-automata.git",
"license": "MIT",
"files": [
"DISCLAIMER",
"dist"
],
"sideEffects": false,
"devDependencies": {
"react": "^16.4.0"
},
"dependencies": {
"glob-to-regexp": "^0.4.0",
"idx": "^2.3.0"
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { getPatterns, isStateless, matches, stringify } from '../src/utils'
import { getPatterns, isStateless, matches, stringify } from '../src/index'

describe('isStateless', () => {
test('true', () => {
Expand Down
21 changes: 21 additions & 0 deletions packages/react-automata/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017-present Michele Bertoli

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
32 changes: 32 additions & 0 deletions packages/react-automata/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "react-automata",
"version": "4.0.4",
"description": "A state machine abstraction for React",
"main": "dist/react-automata.js",
"module": "dist/react-automata.es.js",
"repository": "[email protected]:MicheleBertoli/react-automata.git",
"author": "Michele Bertoli",
"license": "MIT",
"files": [
"DISCLAIMER",
"dist"
],
"sideEffects": false,
"devDependencies": {
"react": "^16.4.0",
"react-dom": "^16.4.0",
"react-test-renderer": "^16.4.1"
},
"dependencies": {
"hoist-non-react-statics": "^3.0.1",
"idx": "^2.3.0",
"invariant": "^2.2.4",
"memoize-one": "^4.0.0",
"prop-types": "^15.6.1",
"react-automata-utilities": "^4.0.4",
"xstate": "^3.3.0"
},
"peerDependencies": {
"react": ">=16.3"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import idx from 'idx'
import memoize from 'memoize-one'
import PropTypes from 'prop-types'
import React from 'react'
import { DEFAULT_CHANNEL, getPatterns, matches } from 'react-automata-utilities'
import Context from './context'
import { DEFAULT_CHANNEL, getPatterns, matches } from './utils'

const createConditional = (displayName, contextField) => {
class Conditional extends React.Component {
Expand Down
1 change: 0 additions & 1 deletion src/index.js → packages/react-automata/src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export { default as Action } from './Action'
export { default as State } from './State'
export { default as testStateMachine } from './testStateMachine'
export { default as withStateMachine } from './withStateMachine'
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import PropTypes from 'prop-types'
import React from 'react'
import { Machine, State, StateNode } from 'xstate'
import hoistStatics from 'hoist-non-react-statics'
import Context from './context'
import {
DEFAULT_CHANNEL,
getComponentName,
isStateless,
stringify,
} from './utils'
} from 'react-automata-utilities'
import Context from './context'

const REDUX_DISPATCH = 'DISPATCH'
const REDUX_JUMP_TO_ACTION = 'JUMP_TO_ACTION'
Expand Down
Loading