diff --git a/.npmrc b/.npmrc index 15d8a25..a57cc9e 100644 --- a/.npmrc +++ b/.npmrc @@ -1,2 +1 @@ registry=http://registry.npmjs.org/ -save-exact=true diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..ffbb8a3 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,4 @@ +node_modules/ +coverage/ +dist/ +package.json diff --git a/.travis.yml b/.travis.yml index ba01b79..08be7ec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,8 +8,6 @@ notifications: node_js: '8' install: npm install script: npm run validate -after_success: - - npx codecov - - npx -p semantic-release@7 -c "semantic-release pre && npm publish && semantic-release post" +after_success: kcd-scripts travis-after-success branches: only: master diff --git a/package.json b/package.json index 6a438a4..4d5e644 100644 --- a/package.json +++ b/package.json @@ -8,12 +8,14 @@ "build": "kcd-scripts build", "lint": "kcd-scripts lint", "test": "kcd-scripts test", - "test:update": "npm test -- --updateSnapshot --coverage", + "test:update": "npm test -- --updateSnapshot", "validate": "kcd-scripts validate", "setup": "npm install && npm run validate -s", "precommit": "kcd-scripts precommit" }, - "files": ["dist"], + "files": [ + "dist" + ], "keywords": [ "babel-plugin", "macros", @@ -24,7 +26,7 @@ "author": "Kent C. Dodds (http://kentcdodds.com/)", "license": "MIT", "dependencies": { - "cosmiconfig": "3.1.0" + "cosmiconfig": "^4.0.0" }, "devDependencies": { "ast-pretty-print": "^2.0.1", @@ -32,14 +34,20 @@ "babel-plugin-tester": "^5.0.0", "babylon": "7.0.0-beta.34", "cpy": "^6.0.0", - "kcd-scripts": "^0.30.4" + "kcd-scripts": "^0.32.1" }, "eslintConfig": { "extends": "./node_modules/kcd-scripts/eslint.js" }, - "eslintIgnore": ["node_modules", "coverage", "dist"], + "eslintIgnore": [ + "node_modules", + "coverage", + "dist" + ], "babel": { - "presets": ["./other/babel-config.js"] + "presets": [ + "./other/babel-config.js" + ] }, "repository": { "type": "git", diff --git a/src/__tests__/__snapshots__/index.js.snap b/src/__tests__/__snapshots__/index.js.snap index 9fa809a..b43d60d 100644 --- a/src/__tests__/__snapshots__/index.js.snap +++ b/src/__tests__/__snapshots__/index.js.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Supports named imports 1`] = ` +exports[`macros Supports named imports: Supports named imports 1`] = ` import {css as CSS, styled as STYLED} from './fixtures/emotion.macro' const red = CSS\` @@ -19,7 +19,7 @@ const Div = STYLED.div\`undefined\`; `; -exports[`Works as a JSXElement 1`] = ` +exports[`macros Works as a JSXElement: Works as a JSXElement 1`] = ` import MyEval from './fixtures/eval.macro' const x = 34 + 45 @@ -30,29 +30,29 @@ const x = 79; `; -exports[`appends the npm URL for errors thrown by node modules 1`] = ` +exports[`macros appends the npm URL for errors thrown by node modules with a slash: appends the npm URL for errors thrown by node modules with a slash 1`] = ` -import errorThrower from 'babel-plugin-macros-test-error-thrower.macro' +import errorThrower from 'babel-plugin-macros-test-error-thrower/macro' errorThrower('hi') ↓ ↓ ↓ ↓ ↓ ↓ -Error: babel-plugin-macros-test-error-thrower.macro: not helpful Learn more: https://www.npmjs.com/package/babel-plugin-macros-test-error-thrower.macro +Error: babel-plugin-macros-test-error-thrower/macro: not helpful Learn more: https://www.npmjs.com/package/babel-plugin-macros-test-error-thrower `; -exports[`appends the npm URL for errors thrown by node modules with a slash 1`] = ` +exports[`macros appends the npm URL for errors thrown by node modules: appends the npm URL for errors thrown by node modules 1`] = ` -import errorThrower from 'babel-plugin-macros-test-error-thrower/macro' +import errorThrower from 'babel-plugin-macros-test-error-thrower.macro' errorThrower('hi') ↓ ↓ ↓ ↓ ↓ ↓ -Error: babel-plugin-macros-test-error-thrower/macro: not helpful Learn more: https://www.npmjs.com/package/babel-plugin-macros-test-error-thrower +Error: babel-plugin-macros-test-error-thrower.macro: not helpful Learn more: https://www.npmjs.com/package/babel-plugin-macros-test-error-thrower.macro `; -exports[`does nothing but remove macros if it is unused 1`] = ` +exports[`macros does nothing but remove macros if it is unused: does nothing but remove macros if it is unused 1`] = ` import foo from './some-macros-that-doesnt-even-need-to-exist.macro' export default 'something else' @@ -63,7 +63,7 @@ export default 'something else'; `; -exports[`forwards MacroErrors thrown by the macro 1`] = ` +exports[`macros forwards MacroErrors thrown by the macro: forwards MacroErrors thrown by the macro 1`] = ` import errorThrower from './fixtures/macro-error-thrower.macro' errorThrower('hey') @@ -74,7 +74,7 @@ MacroError: very helpful `; -exports[`macros can set their configName and get their config 1`] = ` +exports[`macros macros can set their configName and get their config: macros can set their configName and get their config 1`] = ` import configured from './configurable.macro' @@ -86,13 +86,7 @@ configured\`stuff\`; `; -exports[`macros when there is an error reading the config, a helpful message is logged 1`] = ` -Array [ - There was an error trying to load the config "configurableMacro" for the macro imported from "./configurable.macro. Please see the error thrown for more information., -] -`; - -exports[`prepends the relative path for errors thrown by the macro 1`] = ` +exports[`macros prepends the relative path for errors thrown by the macro: prepends the relative path for errors thrown by the macro 1`] = ` import errorThrower from './fixtures/error-thrower.macro' errorThrower('hey') @@ -103,7 +97,7 @@ Error: ./fixtures/error-thrower.macro: very unhelpful `; -exports[`supports macros from node_modules 1`] = ` +exports[`macros supports macros from node_modules: supports macros from node_modules 1`] = ` import fakeMacro from 'babel-plugin-macros-test-fake/macro' fakeMacro('hi') @@ -114,7 +108,7 @@ fakeMacro('hi'); `; -exports[`throws an error if the macro is not properly wrapped 1`] = ` +exports[`macros throws an error if the macro is not properly wrapped: throws an error if the macro is not properly wrapped 1`] = ` import unwrapped from './fixtures/non-wrapped.macro' unwrapped('hey') @@ -125,7 +119,13 @@ Error: The macro imported from "./fixtures/non-wrapped.macro" must be wrapped in `; -exports[`when there is an error reading the config, a helpful message is logged 1`] = ` +exports[`macros when there is an error reading the config, a helpful message is logged 1`] = ` +Array [ + There was an error trying to load the config "configurableMacro" for the macro imported from "./configurable.macro. Please see the error thrown for more information., +] +`; + +exports[`macros when there is an error reading the config, a helpful message is logged: when there is an error reading the config, a helpful message is logged 1`] = ` import configured from './configurable.macro' @@ -137,7 +137,7 @@ Error: this is a cosmiconfig error `; -exports[`when there is no config to load, then no config is passed 1`] = ` +exports[`macros when there is no config to load, then no config is passed: when there is no config to load, then no config is passed 1`] = ` import configured from './configurable.macro' @@ -149,7 +149,7 @@ configured\`stuff\`; `; -exports[`works with function calls 1`] = ` +exports[`macros works with function calls: works with function calls 1`] = ` import myEval from './fixtures/eval.macro' const x = myEval('34 + 45') @@ -160,7 +160,7 @@ const x = 79; `; -exports[`works with import 1`] = ` +exports[`macros works with import: works with import 1`] = ` import myEval from './fixtures/eval.macro' const x = myEval\`34 + 45\` @@ -171,18 +171,26 @@ const x = 79; `; -exports[`works with require 1`] = ` +exports[`macros works with require destructuring and aliasing: works with require destructuring and aliasing 1`] = ` -const evaler = require('./fixtures/eval.macro') -const x = evaler\`34 + 45\` +const {css: CSS, styled: STYLED} = require('./fixtures/emotion.macro') +const red = CSS\` + background-color: red; +\` + +const Div = STYLED.div\` + composes: \${red} + color: blue; +\` ↓ ↓ ↓ ↓ ↓ ↓ -const x = 79; +const red = "background-color: red;"; +const Div = STYLED.div\`undefined\`; `; -exports[`works with require destructuring 1`] = ` +exports[`macros works with require destructuring: works with require destructuring 1`] = ` const {css, styled} = require('./fixtures/emotion.macro') const red = css\` @@ -201,21 +209,13 @@ const Div = styled.div\`undefined\`; `; -exports[`works with require destructuring and aliasing 1`] = ` - -const {css: CSS, styled: STYLED} = require('./fixtures/emotion.macro') -const red = CSS\` - background-color: red; -\` +exports[`macros works with require: works with require 1`] = ` -const Div = STYLED.div\` - composes: \${red} - color: blue; -\` +const evaler = require('./fixtures/eval.macro') +const x = evaler\`34 + 45\` ↓ ↓ ↓ ↓ ↓ ↓ -const red = "background-color: red;"; -const Div = STYLED.div\`undefined\`; +const x = 79; `;