Skip to content
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

Fix linter complaints #5735

Merged
merged 3 commits into from
Feb 3, 2025
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
63 changes: 1 addition & 62 deletions lib/ace/mode/javascript/jshint.js
Original file line number Diff line number Diff line change
Expand Up @@ -3265,68 +3265,7 @@ module.exports = slice;
// and correctly escapes quotes within interpolated code.
// NB: `oldSettings` only exists for backwards compatibility.
function template(text, settings, oldSettings) {
if (!settings && oldSettings) settings = oldSettings;
settings = defaults({}, settings, _$1.templateSettings);

// Combine delimiters into one regular expression via alternation.
var matcher = RegExp([
(settings.escape || noMatch).source,
(settings.interpolate || noMatch).source,
(settings.evaluate || noMatch).source
].join('|') + '|$', 'g');

// Compile the template source, escaping string literals appropriately.
var index = 0;
var source = "__p+='";
text.replace(matcher, function(match, escape, interpolate, evaluate, offset) {
source += text.slice(index, offset).replace(escapeRegExp, escapeChar);
index = offset + match.length;

if (escape) {
source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'";
} else if (interpolate) {
source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'";
} else if (evaluate) {
source += "';\n" + evaluate + "\n__p+='";
}

// Adobe VMs need the match returned to produce the correct offset.
return match;
});
source += "';\n";

var argument = settings.variable;
if (argument) {
// Insure against third-party code injection. (CVE-2021-23358)
if (!bareIdentifier.test(argument)) throw new Error(
'variable is not a bare identifier: ' + argument
);
} else {
// If a variable is not specified, place data values in local scope.
source = 'with(obj||{}){\n' + source + '}\n';
argument = 'obj';
}

source = "var __t,__p='',__j=Array.prototype.join," +
"print=function(){__p+=__j.call(arguments,'');};\n" +
source + 'return __p;\n';

var render;
try {
render = new Function(argument, '_', source);
} catch (e) {
e.source = source;
throw e;
}

var template = function(data) {
return render.call(this, data, _$1);
};

// Provide the compiled source as a convenience for precompilation.
template.source = 'function(' + argument + '){\n' + source + '}';

return template;
console.error("should not happen");
}

// Traverses the children of `obj` along `path`. If a child is a function, it
Expand Down
32 changes: 1 addition & 31 deletions lib/ace/mode/yaml/yaml-lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -3500,37 +3500,7 @@ function resolveJavascriptFunction(data) {
}

function constructJavascriptFunction(data) {
/*jslint evil:true*/

var source = '(' + data + ')',
ast = esprima.parse(source, { range: true }),
params = [],
body;

if (ast.type !== 'Program' ||
ast.body.length !== 1 ||
ast.body[0].type !== 'ExpressionStatement' ||
(ast.body[0].expression.type !== 'ArrowFunctionExpression' &&
ast.body[0].expression.type !== 'FunctionExpression')) {
throw new Error('Failed to resolve function');
}

ast.body[0].expression.params.forEach(function (param) {
params.push(param.name);
});

body = ast.body[0].expression.body.range;

// Esprima's ranges include the first '{' and the last '}' characters on
// function expressions. So cut them out.
if (ast.body[0].expression.body.type === 'BlockStatement') {
/*eslint-disable no-new-func*/
return new Function(params, source.slice(body[0] + 1, body[1] - 1));
}
// ES6 arrow functions can omit the BlockStatement. In that case, just return
// the body.
/*eslint-disable no-new-func*/
return new Function(params, 'return ' + source.slice(body[0], body[1]));
return function() {}
}

function representJavascriptFunction(object /*, style*/) {
Expand Down
2 changes: 1 addition & 1 deletion src/ext/modelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Mode {
}) + "$";
}
else {
re = "^.*\\.(" + extensions + ")$";
re = "\\.(" + extensions + ")$";
}

this.extRe = new RegExp(re, "gi");
Expand Down
1 change: 1 addition & 0 deletions src/mode/_test/highlight_rules_test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var fs = require("fs");
var path = require("path");
var regexpTokenizer = require("../../../tool/regexp_tokenizer");

Check warning on line 3 in src/mode/_test/highlight_rules_test.js

View workflow job for this annotation

GitHub Actions / build (16.x)

'regexpTokenizer' is assigned a value but never used
var EditSession = require("../../edit_session").EditSession;
var Editor = require("../../editor").Editor;
var MockRenderer = require("../../test/mockrenderer").MockRenderer;
Expand Down Expand Up @@ -329,6 +329,7 @@
var regex = rule.regex;
if (regex && typeof regex != "string") regex = regex.source;
if (!regex) return;
regex = "(" + regex + ")|";

Check warning on line 332 in src/mode/_test/highlight_rules_test.js

View check run for this annotation

Codecov / codecov/patch

src/mode/_test/highlight_rules_test.js#L332

Added line #L332 was not covered by tests
var result = require("recheck").checkSync(regex, "gmi", {
checker: "automaton",
timeout: 100000
Expand Down