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

JS-85 Update usages of old apis #4821

Merged
merged 3 commits into from
Sep 18, 2024
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
14 changes: 1 addition & 13 deletions its/ruling/src/test/expected/jsts/ace/javascript-S2189.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
{
"ace:lib/ace/mode/css/csslint.js": [
4691
],
"ace:lib/ace/mode/javascript/jshint.js": [
6549
],
"ace:lib/ace/mode/json/json_parse.js": [
117,
117,
123,
123,
134,
134,
194,
194,
242,
270
Comment on lines -11 to -18
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have mixed feelings about this. We stopped raising more issues as we probably aren't as thorough as the previous rule was, when it was getting the context.getScope() -> called on Program:exit. However, I've checked the issues we stopped triggering on and it was only on the same variables, so maybe it's alright.

Copy link
Contributor

@vdiez vdiez Sep 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

context.sourceCode.getScope(node) now returns a different scope as it depends on the node we give as argument.

In the decorator, we only have the node that is raising the issue. Before, calling context.getScope() returned the scope of node in selector, but from the decorator we don't know what node that is.

194
],
"ace:lib/ace/mode/yaml/yaml-lint.js": [
1826
Expand Down
4 changes: 3 additions & 1 deletion packages/jsts/src/rules/S2189/rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ export const rule: Rule.RuleModule = {
function (context: Rule.RuleContext, descriptor: Rule.ReportDescriptor) {
const node = (descriptor as any).node as estree.Node;

const symbol = context.getScope().references.find(v => v.identifier === node)?.resolved;
const symbol = context.sourceCode
.getScope(node)
.references.find(v => v.identifier === node)?.resolved;
/** Ignoring symbols that have already been reported */
if (isUndefined(node) || (symbol && alreadyRaisedSymbols.has(symbol))) {
return;
Expand Down
6 changes: 3 additions & 3 deletions packages/jsts/src/rules/S2301/rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const S2301: Rule.RuleModule = {
true,
),
create: context => {
if (!isRequiredParserServices(context.parserServices)) {
if (!isRequiredParserServices(context.sourceCode.parserServices)) {
return {};
}

Expand Down Expand Up @@ -104,13 +104,13 @@ export const S2301: Rule.RuleModule = {
return;
}

const variable = getVariableFromIdentifier(node, context.getScope());
const variable = getVariableFromIdentifier(node, context.sourceCode.getScope(node));

if (variable) {
const definition = variable.defs[variable.defs.length - 1];

if (definition?.type === 'Parameter') {
const type = getTypeFromTreeNode(definition.name, context.parserServices);
const type = getTypeFromTreeNode(definition.name, context.sourceCode.parserServices);

if (isBooleanType(type)) {
report(
Expand Down