diff --git a/.eslintrc.js b/.eslintrc.js index 987af7e..b9e9bd1 100755 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,28 +1,31 @@ module.exports = { root: true, - parser: 'babel-eslint', + // parser: 'babel-eslint', parserOptions: { sourceType: 'module' }, env: { browser: true, - node: true + node: true, + jest: true }, extends: 'standard', - // required to lint *.vue files plugins: [ - 'html' + 'jest', + 'vue' ], - // add your custom rules here rules: { - // allow paren-less arrow functions + // Allow paren-less arrow functions 'arrow-parens': 0, - // allow async-await + // Allow async-await 'generator-star-spacing': 0, - // allow debugger during development + // Allow debugger during development 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0, - // do not allow console.logs etc... + // Do not allow console.logs etc... 'no-console': 2 }, - globals: {} + globals: { + 'jest/globals': true, + jasmine: true + } } diff --git a/src/index.js b/lib/index.js similarity index 97% rename from src/index.js rename to lib/index.js index 7c6c1d1..ac31950 100755 --- a/src/index.js +++ b/lib/index.js @@ -41,7 +41,7 @@ module.exports = function nuxtAxios (moduleOptions) { // Register plugin addPlugin.call(this, { - src: path.resolve(__dirname, 'plugin.js'), + src: path.resolve(__dirname, 'plugin.template.js'), fileName: 'axios.js', options }) diff --git a/src/plugin.js b/lib/plugin.template.js similarity index 100% rename from src/plugin.js rename to lib/plugin.template.js diff --git a/package.json b/package.json index 142f817..1a46acf 100755 --- a/package.json +++ b/package.json @@ -3,16 +3,26 @@ "version": "3.1.1", "description": "Secure and easy axios integration with Nuxt.js", "license": "MIT", - "main": "src/index.js", + "main": "lib/index.js", "repository": "https://github.com/nuxt-community/axios-module", "publishConfig": { "access": "public" }, "scripts": { - "test": "jest", + "coverage": "codecov", + "lint": "eslint lib src test", + "test": "npm run lint && jest", "release": "standard-version", "prepublish": "npm run test" }, + "eslintIgnore": [ + "*.template.*" + ], + "files": [ + "lib", + "src", + "dist" + ], "jest": { "testEnvironment": "node", "coverageDirectory": "./coverage/", @@ -28,9 +38,11 @@ "eslint": "^4.4.1", "eslint-config-standard": "^10.2.1", "eslint-plugin-import": "^2.7.0", + "eslint-plugin-jest": "^20.0.3", "eslint-plugin-node": "^5.1.1", "eslint-plugin-promise": "^3.5.0", "eslint-plugin-standard": "^3.0.1", + "eslint-plugin-vue": "^2.1.0", "jest": "^20.0.4", "standard-version": "^4.2.0" } diff --git a/test/axios.test.js b/test/axios.test.js index c07c3b0..7a7e247 100644 --- a/test/axios.test.js +++ b/test/axios.test.js @@ -1,18 +1,19 @@ const { Nuxt, Builder } = require('nuxt') +const { resolve } = require('path') process.env.NODE_ENV = 'production' describe('axios module', () => { - let nuxt + let nuxt - beforeAll(async () => { - jasmine.DEFAULT_TIMEOUT_INTERVAL = 20000 - nuxt = new Nuxt({ srcDir: __dirname + '/fixture', dev: false }) - let builder = new Builder(nuxt) - await builder.build() - }) + beforeAll(async () => { + jasmine.DEFAULT_TIMEOUT_INTERVAL = 20000 + nuxt = new Nuxt({ srcDir: resolve(__dirname, 'fixture'), dev: false }) + let builder = new Builder(nuxt) + await builder.build() + }) - test('test', () => { - expect(nuxt.options.dev).toBe(false) - }) + test('test', () => { + expect(nuxt.options.dev).toBe(false) + }) }) diff --git a/yarn.lock b/yarn.lock index fdcd2a0..e776b6c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -188,6 +188,13 @@ array-ify@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/array-ify/-/array-ify-1.0.0.tgz#9e528762b4a9066ad163a6962a364418e9626ece" +array-includes@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/array-includes/-/array-includes-3.0.3.tgz#184b48f62d92d7452bb31b323165c7f8bd02266d" + dependencies: + define-properties "^1.1.2" + es-abstract "^1.7.0" + array-union@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/array-union/-/array-union-1.0.2.tgz#9a34410e4f4e3da23dea375be5be70f24778ec39" @@ -1894,7 +1901,7 @@ domain-browser@^1.1.1: version "1.1.7" resolved "https://registry.yarnpkg.com/domain-browser/-/domain-browser-1.1.7.tgz#867aa4b093faa05f1de08c06f4d7b21fdf8698bc" -domelementtype@1: +domelementtype@1, domelementtype@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-1.3.0.tgz#b17aed82e8ab59e52dd9c19b1756e0fc187204c2" @@ -1908,6 +1915,12 @@ domhandler@2.1: dependencies: domelementtype "1" +domhandler@^2.3.0: + version "2.4.1" + resolved "https://registry.yarnpkg.com/domhandler/-/domhandler-2.4.1.tgz#892e47000a99be55bbf3774ffea0561d8879c259" + dependencies: + domelementtype "1" + domutils@1.1: version "1.1.6" resolved "https://registry.yarnpkg.com/domutils/-/domutils-1.1.6.tgz#bddc3de099b9a2efacc51c623f28f416ecc57485" @@ -1921,6 +1934,13 @@ domutils@1.5.1: dom-serializer "0" domelementtype "1" +domutils@^1.5.1: + version "1.6.2" + resolved "https://registry.yarnpkg.com/domutils/-/domutils-1.6.2.tgz#1958cc0b4c9426e9ed367fb1c8e854891b0fa3ff" + dependencies: + dom-serializer "0" + domelementtype "1" + dot-prop@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-3.0.0.tgz#1b708af094a49c9a0e7dbcad790aba539dac1177" @@ -1993,7 +2013,7 @@ enhanced-resolve@^3.4.0: object-assign "^4.0.1" tapable "^0.2.7" -entities@~1.1.1: +entities@^1.1.1, entities@~1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/entities/-/entities-1.1.1.tgz#6e5c2d0a5621b5dadaecef80b90edfb5cd7772f0" @@ -2015,6 +2035,24 @@ error-stack-parser@^2.0.0: dependencies: stackframe "^1.0.3" +es-abstract@^1.7.0: + version "1.8.0" + resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.8.0.tgz#3b00385e85729932beffa9163bbea1234e932914" + dependencies: + es-to-primitive "^1.1.1" + function-bind "^1.1.0" + has "^1.0.1" + is-callable "^1.1.3" + is-regex "^1.0.4" + +es-to-primitive@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.1.1.tgz#45355248a88979034b6792e19bb81f2b7975dd0d" + dependencies: + is-callable "^1.1.1" + is-date-object "^1.0.1" + is-symbol "^1.0.1" + es5-ext@^0.10.14, es5-ext@^0.10.9, es5-ext@~0.10.14: version "0.10.24" resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.24.tgz#a55877c9924bc0c8d9bd3c2cbe17495ac1709b14" @@ -2117,6 +2155,12 @@ eslint-module-utils@^2.1.1: debug "^2.6.8" pkg-dir "^1.0.0" +eslint-plugin-html@^3.0.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-html/-/eslint-plugin-html-3.2.0.tgz#fb64c2789e9582b97f580a38814a57966f91a7b2" + dependencies: + htmlparser2 "^3.8.2" + eslint-plugin-import@^2.7.0: version "2.7.0" resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.7.0.tgz#21de33380b9efb55f5ef6d2e210ec0e07e7fa69f" @@ -2132,6 +2176,10 @@ eslint-plugin-import@^2.7.0: minimatch "^3.0.3" read-pkg-up "^2.0.0" +eslint-plugin-jest@^20.0.3: + version "20.0.3" + resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-20.0.3.tgz#ec15eba6ac0ab44a67ebf6e02672ca9d7e7cba29" + eslint-plugin-node@^5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/eslint-plugin-node/-/eslint-plugin-node-5.1.1.tgz#a7ed956e780c22aef6afd1116005acd82f26eac6" @@ -2145,10 +2193,25 @@ eslint-plugin-promise@^3.5.0: version "3.5.0" resolved "https://registry.yarnpkg.com/eslint-plugin-promise/-/eslint-plugin-promise-3.5.0.tgz#78fbb6ffe047201627569e85a6c5373af2a68fca" +eslint-plugin-react@^7.0.0: + version "7.2.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.2.0.tgz#25c77a4ec307e3eebb248ea3350960e372ab6406" + dependencies: + doctrine "^2.0.0" + has "^1.0.1" + jsx-ast-utils "^2.0.0" + eslint-plugin-standard@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/eslint-plugin-standard/-/eslint-plugin-standard-3.0.1.tgz#34d0c915b45edc6f010393c7eef3823b08565cf2" +eslint-plugin-vue@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-vue/-/eslint-plugin-vue-2.1.0.tgz#50ed0b7e9a2389d90e689743a3cc26b502441b69" + dependencies: + eslint-plugin-html "^3.0.0" + eslint-plugin-react "^7.0.0" + eslint-scope@^3.7.1: version "3.7.1" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-3.7.1.tgz#3d63c3edfda02e06e01a452ad88caacc7cdcb6e8" @@ -2854,6 +2917,17 @@ html-webpack-plugin@^2.30.1: pretty-error "^2.0.2" toposort "^1.0.0" +htmlparser2@^3.8.2: + version "3.9.2" + resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-3.9.2.tgz#1bdf87acca0f3f9e53fa4fcceb0f4b4cbb00b338" + dependencies: + domelementtype "^1.3.0" + domhandler "^2.3.0" + domutils "^1.5.1" + entities "^1.1.1" + inherits "^2.0.1" + readable-stream "^2.0.2" + htmlparser2@~3.3.0: version "3.3.0" resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-3.3.0.tgz#cc70d05a59f6542e43f0e685c982e14c924a9efe" @@ -3035,12 +3109,20 @@ is-builtin-module@^1.0.0: dependencies: builtin-modules "^1.0.0" +is-callable@^1.1.1, is-callable@^1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.3.tgz#86eb75392805ddc33af71c92a0eedf74ee7604b2" + is-ci@^1.0.10: version "1.0.10" resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-1.0.10.tgz#f739336b2632365061a9d48270cd56ae3369318e" dependencies: ci-info "^1.0.0" +is-date-object@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.1.tgz#9aa20eb6aeebbff77fbd33e74ca01b33581d3a16" + is-directory@^0.3.1: version "0.3.1" resolved "https://registry.yarnpkg.com/is-directory/-/is-directory-0.3.1.tgz#61339b6f2475fc772fd9c9d83f5c8575dc154ae1" @@ -3133,6 +3215,12 @@ is-promise@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/is-promise/-/is-promise-2.1.0.tgz#79a2a9ece7f096e80f36d2b2f3bc16c1ff4bf3fa" +is-regex@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.4.tgz#5517489b547091b0930e095654ced25ee97e9491" + dependencies: + has "^1.0.1" + is-resolvable@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-resolvable/-/is-resolvable-1.0.0.tgz#8df57c61ea2e3c501408d100fb013cf8d6e0cc62" @@ -3153,6 +3241,10 @@ is-svg@^2.0.0: dependencies: html-comment-regex "^1.1.0" +is-symbol@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.1.tgz#3cc59f00025194b6ab2e38dbae6689256b660572" + is-text-path@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/is-text-path/-/is-text-path-1.0.1.tgz#4e1aa0fb51bfbcb3e92688001397202c1775b66e" @@ -3583,6 +3675,12 @@ jsprim@^1.2.2: json-schema "0.2.3" verror "1.3.6" +jsx-ast-utils@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-2.0.0.tgz#ec06a3d60cf307e5e119dac7bad81e89f096f0f8" + dependencies: + array-includes "^3.0.3" + kind-of@^3.0.2: version "3.2.2" resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64"