Skip to content

Commit

Permalink
Merge 606614d into 93f30a9
Browse files Browse the repository at this point in the history
  • Loading branch information
Milovanova Natalia committed Dec 17, 2017
2 parents 93f30a9 + 606614d commit 6f64f08
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 46 deletions.
34 changes: 16 additions & 18 deletions src/rules/html/warn-on-inline.js
Expand Up @@ -2,23 +2,21 @@ import { VALIDATION_WARNING } from 'const';
import * as messages from 'messages';


export function warnOnInline($, filename) {
return new Promise((resolve) => {
const linterMessages = [];
$('script').each((i, element) => {
if ($(element).attr('src') === undefined &&
($(element).attr('type') === undefined ||
$(element).attr('type') === 'text/javascript')) {
linterMessages.push(
Object.assign({}, messages.INLINE_SCRIPT, {
/* This could occur in any HTML file, so let's make it
* a warning in case they've included any other file.
*/
type: VALIDATION_WARNING,
file: filename,
}));
}
});
resolve(linterMessages);
export async function warnOnInline($, filename) {
const linterMessages = [];
$('script').each((i, element) => {
if ($(element).attr('src') === undefined &&
($(element).attr('type') === undefined ||
$(element).attr('type') === 'text/javascript')) {
linterMessages.push(
Object.assign({}, messages.INLINE_SCRIPT, {
/* This could occur in any HTML file, so let's make it
* a warning in case they've included any other file.
*/
type: VALIDATION_WARNING,
file: filename,
}));
}
});
return linterMessages;
}
30 changes: 14 additions & 16 deletions src/rules/html/warn-on-remote-script.js
Expand Up @@ -3,23 +3,21 @@ import { isStrictRelativeUrl } from 'schema/formats';
import * as messages from 'messages';


export function warnOnRemoteScript($, filename) {
return new Promise((resolve) => {
const linterMessages = [];
export async function warnOnRemoteScript($, filename) {
const linterMessages = [];

$('script').each((i, element) => {
const src = $(element).attr('src');
$('script').each((i, element) => {
const src = $(element).attr('src');

if (src !== undefined && !isStrictRelativeUrl(src)) {
linterMessages.push(
Object.assign({}, messages.REMOTE_SCRIPT, {
type: VALIDATION_WARNING,
file: filename,
})
);
}
});

resolve(linterMessages);
if (src !== undefined && !isStrictRelativeUrl(src)) {
linterMessages.push(
Object.assign({}, messages.REMOTE_SCRIPT, {
type: VALIDATION_WARNING,
file: filename,
})
);
}
});

return linterMessages;
}
19 changes: 7 additions & 12 deletions src/utils.js
Expand Up @@ -134,20 +134,15 @@ export const { sprintf } = jed;
/*
* Check the minimum node version is met
*/
export function checkMinNodeVersion(minVersion, _process = process) {
return new Promise((resolve) => {
// eslint-disable-next-line no-param-reassign
minVersion = minVersion || '0.12.0';
if (!semver.gte(_process.version, minVersion)) {
throw new Error(oneLine`Node version must be ${minVersion} or
greater. You are using ${_process.version}.`);
} else {
resolve();
}
});
export async function checkMinNodeVersion(minVersion, _process = process) {
// eslint-disable-next-line no-param-reassign
minVersion = minVersion || '0.12.0';
if (!semver.gte(_process.version, minVersion)) {
throw new Error(oneLine`Node version must be ${minVersion} or
greater. You are using ${_process.version}.`);
}
}


export function getPackageTypeAsString(numericPackageType) {
const packageKeys = Object.keys(PACKAGE_TYPES);
for (let i = 0; i < packageKeys.length; i++) {
Expand Down

0 comments on commit 6f64f08

Please sign in to comment.