Skip to content

Commit 58966be

Browse files
fix(.eslintrc,hotModuleReplacement.js): Update linting rules, no arrows (faceyspacey#85)
* fix(.eslintrc,hotModuleReplacement.js): Update linting rules, remove arrow functions Arrow functions break IE11 (whats new), updated eslint so it wont autofix it fix faceyspacey#83 * style: Updated linting rules No destructuring for IE * fix: ES6 strings not TL Dont use template literals
1 parent 87334cf commit 58966be

File tree

3 files changed

+35
-34
lines changed

3 files changed

+35
-34
lines changed

.eslintrc.js

+22-19
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
module.exports = {
2-
parser: 'babel-eslint',
3-
parserOptions: {
4-
ecmaFeatures: {
5-
generators: true,
6-
experimentalObjectRestSpread: true
7-
},
8-
sourceType: 'module',
9-
allowImportExportEverywhere: false
10-
},
11-
extends: ['airbnb'],
12-
env: {
13-
'browser': true,
14-
},
15-
rules: {
16-
'no-param-reassign': 0,
17-
'func-names': 0,
18-
'no-underscore-dangle': 0,
19-
'no-restricted-syntax': 0,
20-
}
2+
parser: 'babel-eslint',
3+
parserOptions: {
4+
ecmaFeatures: {
5+
generators: true,
6+
experimentalObjectRestSpread: true
7+
},
8+
sourceType: 'module',
9+
allowImportExportEverywhere: false
10+
},
11+
extends: ['airbnb'],
12+
env: {
13+
'browser': true,
14+
},
15+
rules: {
16+
'no-param-reassign': 0,
17+
'func-names': 0,
18+
'no-underscore-dangle': 0,
19+
'no-restricted-syntax': 0,
20+
'prefer-arrow-callback': 0,
21+
'prefer-destructuring': 0,
22+
'prefer-template': 0
23+
}
2124
};

README.md

-2
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ NOTE: We have aligned out loader implementation to be the same as `mini-css-extr
6363

6464
**If you already use `mini-css-extract-plugin`, then you can just change the `require` statement - it's that easy**
6565

66-
67-
**DONT USE THIS INSTALL CMD IF YOU ARE BETA TESTING:**
6866
```
6967
yarn add --dev extract-css-chunks-webpack-plugin
7068
```

src/hotModuleReplacement.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const srcByModuleId = Object.create(null);
44
const debounce = require('lodash/debounce');
55

66
const noDocument = typeof document === 'undefined';
7-
const { forEach } = Array.prototype;
7+
const forEach = Array.prototype.forEach;
88

99
const noop = function () {};
1010

@@ -13,13 +13,13 @@ const getCurrentScriptUrl = function (moduleId) {
1313

1414
if (!src) {
1515
if (document.currentScript) {
16-
src = document.currentScript.src; // eslint-disable-line prefer-destructuring
16+
src = document.currentScript.src;
1717
} else {
1818
const scripts = document.getElementsByTagName('script');
1919
const lastScriptTag = scripts[scripts.length - 1];
2020

2121
if (lastScriptTag) {
22-
src = lastScriptTag.src; // eslint-disable-line prefer-destructuring
22+
src = lastScriptTag.src;
2323
}
2424
}
2525
srcByModuleId[moduleId] = src;
@@ -31,10 +31,10 @@ const getCurrentScriptUrl = function (moduleId) {
3131
if (!filename) {
3232
return [src.replace('.js', '.css')];
3333
}
34-
return fileMap.split(',').map((mapRule) => {
35-
const reg = new RegExp(`${filename}\\.js$`, 'g');
34+
return fileMap.split(',').map(function (mapRule) {
35+
const reg = new RegExp(filename + '\\.js$', 'g');
3636
return normalizeUrl(
37-
src.replace(reg, `${mapRule.replace(/{fileName}/g, filename)}.css`),
37+
src.replace(reg, mapRule.replace(/{fileName}/g, filename) + '.css'),
3838
{ stripWWW: false },
3939
);
4040
});
@@ -43,7 +43,7 @@ const getCurrentScriptUrl = function (moduleId) {
4343

4444
function updateCss(el, url) {
4545
if (!url) {
46-
[url] = el.href.split('?');
46+
url = el.href.split('?')[0];
4747
}
4848
if (el.isLoaded === false) {
4949
// We seem to be about to replace a css link that hasn't loaded yet.
@@ -56,23 +56,23 @@ function updateCss(el, url) {
5656
const newEl = el.cloneNode();
5757

5858
newEl.isLoaded = false;
59-
newEl.addEventListener('load', () => {
59+
newEl.addEventListener('load', function () {
6060
newEl.isLoaded = true;
6161
el.remove();
6262
});
63-
newEl.addEventListener('error', () => {
63+
newEl.addEventListener('error', function () {
6464
newEl.isLoaded = true;
6565
el.remove();
6666
});
6767

68-
newEl.href = `${url}?${Date.now()}`;
68+
newEl.href = url + '?' + Date.now();
6969
el.parentNode.appendChild(newEl);
7070
}
7171

7272
function getReloadUrl(href, src) {
7373
href = normalizeUrl(href, { stripWWW: false });
7474
let ret;
75-
src.some((url) => { // eslint-disable-line array-callback-return
75+
src.some(function (url) { // eslint-disable-line array-callback-return
7676
if (href.indexOf(src) > -1) {
7777
ret = url;
7878
}
@@ -84,7 +84,7 @@ function reloadStyle(src) { // eslint-disable-line no-unused-vars
8484
const elements = document.querySelectorAll('link');
8585
let loaded = false;
8686

87-
forEach.call(elements, (el) => {
87+
forEach.call(elements, function (el) {
8888
if (el.visited === true) return;
8989

9090
const url = getReloadUrl(el.href, src);
@@ -99,7 +99,7 @@ function reloadStyle(src) { // eslint-disable-line no-unused-vars
9999

100100
function reloadAll() {
101101
const elements = document.querySelectorAll('link');
102-
forEach.call(elements, (el) => {
102+
forEach.call(elements, function (el) {
103103
if (el.visited === true) return;
104104
updateCss(el);
105105
});

0 commit comments

Comments
 (0)