Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
tlog.overwrite(' ^G\u2713^: minify');
}
} else {
tlog.overwrite();
}
if (isStaticSite) {
tlog.info(' ^G\u2713^: static-site content').br();
postProcessed = true;
}
if (zuixConfig.build.esLint) {
// run ESlint
if (page.file.endsWith('.js')) {
tlog.info(' ^r*^: lint');
const issues = linter.verify(page.content, lintConfig, page.file);
issues.forEach(function(m) {
if (m.fatal || m.severity > 1) {
tlog.error(' ^RError^: %s ^R(^Y%s^w:^Y%s^R)', m.message, m.line, m.column);
} else {
tlog.warn(' ^YWarning^: %s ^R(^Y%s^w:^Y%s^R)', m.message, m.line, m.column);
}
});
if (issues.length === 0) {
tlog.overwrite(' ^G\u2713^: lint');
}
tlog.info();
postProcessed = true;
}
}
if (zuixConfig.build.less) {
it('esnext.verify should be proxy as eslint.verify', function () {
var esnextResult = esnext.verify('class Foo {}', config);
var eslintResult = eslint.verify('class Foo {}', config);
expect(esnextResult).toEqual(eslintResult);
});
if (item.filename) {
filename = item.filename;
}
if (item.options) {
const options = item.options.concat();
options.unshift(1);
config.rules[ruleName] = options;
} else {
config.rules[ruleName] = 1;
}
return {
messages: linter.verify(code, config, filename, true),
};
}
})
}else{
setQueueAsset(conf, state, fileInfo, {},debugMode);
}
}
}
if (isScripts) {
if (/#=/g.test(fileInfo.content.asset.content)) {
isScriptsLintUse = false;
}
if (isScriptsLintUse) {
var messages = esLinter.verify(fileInfo.content.asset.content, options.tools.esLint.config, { filename: fileInfo.path });
if (messages.length > 0) {
var isError = false;
_.forEach(messages, function (message) {
if (message.fatal) {
isError = true;
}
eventEmitter.emit('js:error', {
warn: `${message.message}\n`,
message: `${message.source}\n\nСтрока: ${message.line}\nФайл: ${fileInfo.path}`
});
});
if (!isError) {
setQueueAsset(conf, state, fileInfo, {}, debugMode);
}else{
function taskLint (str) {
const config = {
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "script",
"ecmaFeatures": {
"jsx": false,
"experimentalObjectRestSpread": true
}
},
"rules": {
"semi": 2
}
};
const messages = ESLint.verify(str, config);
if (messages.length) {
const lines = str.split('\n');
const err = messages.map(err => {
return `${err.message} in line ${err.line}\n${lines[err.line-1]}`;
}).join('\n\n');
throw new Error(err);
}
}
const check = function (checkGroup, checkId, checkLabel, fileContents, lines, next) {
let messages = {};
let errors = [];
markbotMain.send('check-group:item-computing', checkGroup, checkId);
messages = linter.verify(fileContents, linterConfig);
if (messages) {
messages.forEach(function (item) {
errors.push(util.format('Line %d: %s', item.line, item.message.replace(/\.$/, '')));
});
}
markbotMain.send('check-group:item-complete', checkGroup, checkId, checkLabel, errors);
next();
};
recursive(sourceFolder).map((f, i) => {
if (f.endsWith('.js')) {
tlog.info('^B%s^R', f);
const code = fs.readFileSync(sourceFolder + f, 'utf8');
const issues = linter.verify(code, lintConfig, sourceFolder + f);
issues.map((m, i)=>{
if (m.fatal || m.severity > 1) {
stats.error++;
tlog.error(' ^RError^: %s ^R(^Y%s^w:^Y%s^R)', m.message, m.line, m.column);
} else {
stats.warning++;
tlog.warn(' ^YWarning^: %s ^R(^Y%s^w:^Y%s^R)', m.message, m.line, m.column);
}
});
if (issues.length === 0) tlog.info(' ^G\u2713^: OK');
tlog.br();
}
});
tlog.info('Linting completed ^G-^: Errors ^R%s^: ^G-^: Warnings ^Y%s^:\n\n', stats.error, stats.warning);
static run(content: string, filename: string): { code: string, map: Object } {
let log = logger(this.name);
log(content);
let editor = new MagicString(content);
let messages = linter.verify(content, {
rules: { 'semi': 2, 'no-extra-semi': 2 },
env: { es6: true }
});
messages.forEach(message => {
switch (message.ruleId) {
case 'semi':
editor.insert(message.fix.range[1], message.fix.text);
break;
case 'no-extra-semi':
editor.overwrite(...message.fix.range, message.fix.text);
break;
}
});
const check = function (checkGroup, checkId, checkLabel, fileContents, lines, next) {
let messages = {};
let errors = [];
markbotMain.send('check-group:item-computing', checkGroup, checkId);
messages = linter.verify(fileContents, linterConfig);
if (messages) {
messages.forEach(function (item) {
errors.push(util.format('Line %d: %s', item.line, item.message.replace(/\.$/, '')));
});
}
markbotMain.send('check-group:item-complete', checkGroup, checkId, checkLabel, errors);
next(errors);
};