Skip to content

fix(.eslintrc,hotModuleReplacement.js): Update linting rules, no arrows #85

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 16, 2018
Merged
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
41 changes: 22 additions & 19 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
module.exports = {
parser: 'babel-eslint',
parserOptions: {
ecmaFeatures: {
generators: true,
experimentalObjectRestSpread: true
},
sourceType: 'module',
allowImportExportEverywhere: false
},
extends: ['airbnb'],
env: {
'browser': true,
},
rules: {
'no-param-reassign': 0,
'func-names': 0,
'no-underscore-dangle': 0,
'no-restricted-syntax': 0,
}
parser: 'babel-eslint',
parserOptions: {
ecmaFeatures: {
generators: true,
experimentalObjectRestSpread: true
},
sourceType: 'module',
allowImportExportEverywhere: false
},
extends: ['airbnb'],
env: {
'browser': true,
},
rules: {
'no-param-reassign': 0,
'func-names': 0,
'no-underscore-dangle': 0,
'no-restricted-syntax': 0,
'prefer-arrow-callback': 0,
'prefer-destructuring': 0,
'prefer-template': 0
}
};
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ NOTE: We have aligned out loader implementation to be the same as `mini-css-extr

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


**DONT USE THIS INSTALL CMD IF YOU ARE BETA TESTING:**
```
yarn add --dev extract-css-chunks-webpack-plugin
```
Expand Down
26 changes: 13 additions & 13 deletions src/hotModuleReplacement.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const srcByModuleId = Object.create(null);
const debounce = require('lodash/debounce');

const noDocument = typeof document === 'undefined';
const { forEach } = Array.prototype;
const forEach = Array.prototype.forEach;

const noop = function () {};

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

if (!src) {
if (document.currentScript) {
src = document.currentScript.src; // eslint-disable-line prefer-destructuring
src = document.currentScript.src;
} else {
const scripts = document.getElementsByTagName('script');
const lastScriptTag = scripts[scripts.length - 1];

if (lastScriptTag) {
src = lastScriptTag.src; // eslint-disable-line prefer-destructuring
src = lastScriptTag.src;
}
}
srcByModuleId[moduleId] = src;
Expand All @@ -31,10 +31,10 @@ const getCurrentScriptUrl = function (moduleId) {
if (!filename) {
return [src.replace('.js', '.css')];
}
return fileMap.split(',').map((mapRule) => {
const reg = new RegExp(`${filename}\\.js$`, 'g');
return fileMap.split(',').map(function (mapRule) {
const reg = new RegExp(filename + '\\.js$', 'g');
return normalizeUrl(
src.replace(reg, `${mapRule.replace(/{fileName}/g, filename)}.css`),
src.replace(reg, mapRule.replace(/{fileName}/g, filename) + '.css'),
{ stripWWW: false },
);
});
Expand All @@ -43,7 +43,7 @@ const getCurrentScriptUrl = function (moduleId) {

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

newEl.isLoaded = false;
newEl.addEventListener('load', () => {
newEl.addEventListener('load', function () {
newEl.isLoaded = true;
el.remove();
});
newEl.addEventListener('error', () => {
newEl.addEventListener('error', function () {
newEl.isLoaded = true;
el.remove();
});

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

function getReloadUrl(href, src) {
href = normalizeUrl(href, { stripWWW: false });
let ret;
src.some((url) => { // eslint-disable-line array-callback-return
src.some(function (url) { // eslint-disable-line array-callback-return
if (href.indexOf(src) > -1) {
ret = url;
}
Expand All @@ -84,7 +84,7 @@ function reloadStyle(src) { // eslint-disable-line no-unused-vars
const elements = document.querySelectorAll('link');
let loaded = false;

forEach.call(elements, (el) => {
forEach.call(elements, function (el) {
if (el.visited === true) return;

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

function reloadAll() {
const elements = document.querySelectorAll('link');
forEach.call(elements, (el) => {
forEach.call(elements, function (el) {
if (el.visited === true) return;
updateCss(el);
});
Expand Down