diff --git a/.eslintrc b/.eslintrc index 412388a..ce5c2ae 100644 --- a/.eslintrc +++ b/.eslintrc @@ -4,6 +4,8 @@ "comma-dangle": [2, "never"], "no-param-reassign": 0, "prefer-rest-params": 0, - "no-underscore-dangle": 0 + "no-underscore-dangle": 0, + "no-void": 0, + "no-mixed-operators": 0 } } diff --git a/package.json b/package.json index 4ef7e23..27513e1 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "es-ajax", "description": "Ajax (fetch or xhr2) with promises - an useful JavaScript library for convenient work with ajax requests in a browser.", - "version": "1.1.5", + "version": "1.1.6", "main": "src/index.js", "files": [ "src", @@ -38,34 +38,34 @@ ], "license": "MIT", "dependencies": { - "es-middleware": "^1.1.1", - "object-hash": "^1.1.2", - "qs": "^6.2.0" + "es-middleware": "^1.1.3", + "object-hash": "^1.1.4", + "qs": "^6.2.1" }, "devDependencies": { - "babel-cli": "^6.9.0", - "babel-core": "^6.9.0", + "babel-cli": "^6.11.4", + "babel-core": "^6.13.2", "babel-loader": "^6.2.4", "babel-plugin-transform-export-extensions": "^6.8.0", "babel-plugin-transform-object-rest-spread": "^6.8.0", - "babel-polyfill": "^6.9.0", - "babel-preset-es2015": "^6.9.0", - "babel-preset-stage-2": "^6.5.0", - "eslint": "^2.10.2", - "eslint-config-airbnb": "^9.0.1", - "eslint-loader": "^1.3.0", - "eslint-plugin-import": "^1.9.0", - "eslint-plugin-jsx-a11y": "^1.2.2", - "eslint-plugin-react": "^5.1.1", - "expect": "^1.20.1", - "karma": "^0.13.22", - "karma-mocha": "^1.0.1", - "karma-phantomjs-launcher": "^1.0.0", + "babel-polyfill": "^6.13.0", + "babel-preset-es2015": "^6.13.2", + "babel-preset-stage-2": "^6.13.0", + "eslint": "^3.2.2", + "eslint-config-airbnb": "^10.0.0", + "eslint-loader": "^1.5.0", + "eslint-plugin-import": "^1.12.0", + "eslint-plugin-jsx-a11y": "^2.1.0", + "eslint-plugin-react": "^6.0.0", + "expect": "^1.20.2", + "karma": "^1.1.2", + "karma-mocha": "^1.1.1", + "karma-phantomjs-launcher": "^1.0.1", "karma-sinon": "^1.0.5", - "karma-webpack": "^1.7.0", - "mocha": "^2.5.3", - "phantomjs-prebuilt": "^2.1.7", - "sinon": "^1.17.4", + "karma-webpack": "^1.8.0", + "mocha": "^3.0.2", + "phantomjs-prebuilt": "^2.1.11", + "sinon": "^1.17.5", "webpack": "^1.13.1" }, "engines": { diff --git a/src/ajax.js b/src/ajax.js index 0654389..5145367 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -1,16 +1,17 @@ -import guid from './utils/guid'; -import factory from './utils/factory'; -import { contentTypes } from './utils/content-types'; import objectHash from 'object-hash'; -import { is } from './utils/is'; import Middleware from 'es-middleware'; +import guid from './utils/guid'; +import factory from './utils/factory'; +import contentTypes from './utils/content-types'; +import is from './utils/is'; + const _requests = new Set(); const _meta = new Map(); const mw = new Middleware(); let _timeout = 0; -export function ajax(url, parameters = {}) { +export default function ajax(url, parameters = {}) { const defaults = { isSingleton: false, api: 'xhr', // xhr || fetch diff --git a/src/driver/fetch.js b/src/driver/fetch.js index 1ff9e02..fa43030 100644 --- a/src/driver/fetch.js +++ b/src/driver/fetch.js @@ -1,7 +1,9 @@ +/* global fetch, Headers */ + import XhrAbstract from './xhr-abstract'; import internal from './utils/internal'; -import { methods } from './utils/methods'; -import { is } from '../utils/is'; +import methods from './utils/methods'; +import is from '../utils/is'; export default class FetchDriver extends XhrAbstract { constructor(url, request = {}, headers = {}) { diff --git a/src/driver/utils/methods.js b/src/driver/utils/methods.js index 271dc7b..ae11924 100644 --- a/src/driver/utils/methods.js +++ b/src/driver/utils/methods.js @@ -1,4 +1,4 @@ -export const methods = { +export default { head: 'HEAD', options: 'OPTIONS', get: 'GET', diff --git a/src/driver/xhr-abstract.js b/src/driver/xhr-abstract.js index 1273719..b8618f8 100644 --- a/src/driver/xhr-abstract.js +++ b/src/driver/xhr-abstract.js @@ -1,7 +1,7 @@ -import { methods } from './utils/methods'; +import methods from './utils/methods'; import internal from './utils/internal'; import methodsOverride from './utils/methods-override'; -import { is } from '../utils/is'; +import is from '../utils/is'; export default class XhrAbstract { constructor(/* url, request = {}, headers = {} */) { diff --git a/src/driver/xhr.js b/src/driver/xhr.js index 0420056..5390d48 100644 --- a/src/driver/xhr.js +++ b/src/driver/xhr.js @@ -1,10 +1,12 @@ +/* global XMLHttpRequest */ + import qs from 'qs'; import internal from './utils/internal'; import XhrAbstract from './xhr-abstract'; import { rejectInterface, resolveInterface } from './utils/resolve-reject-interface'; -import { methods } from './utils/methods'; +import methods from './utils/methods'; import asObject from './utils/as-object'; -import { is } from '../utils/is'; +import is from '../utils/is'; export default class XhrDriver extends XhrAbstract { constructor(url, request = {}, headers = {}) { diff --git a/src/index.js b/src/index.js index 38dd4e8..ad128c0 100644 --- a/src/index.js +++ b/src/index.js @@ -1 +1 @@ -module.exports = require('./ajax').ajax; +module.exports = require('./ajax').default; diff --git a/src/utils/content-types.js b/src/utils/content-types.js index 00b19fb..e526792 100644 --- a/src/utils/content-types.js +++ b/src/utils/content-types.js @@ -1,4 +1,4 @@ -export const contentTypes = { +export default { text: 'text/plain', html: 'text/html', json: 'application/json' diff --git a/src/utils/is.js b/src/utils/is.js index 32477b8..335dc80 100644 --- a/src/utils/is.js +++ b/src/utils/is.js @@ -1,4 +1,4 @@ -export const is = { +export default { _undefined(value) { return value === void 0; }, diff --git a/webpack.config.js b/webpack.config.js index 3fe2bb0..ba4a06b 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -25,7 +25,7 @@ if (isProduction) { } module.exports = { - devtool: !isProduction ? 'cheap-source-map' : 'eval', + devtool: isProduction ? 'cheap-source-map' : 'eval', entry: './src/index.js', watch: false, output: {