Skip to content

Commit

Permalink
review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
saberduck committed Jul 30, 2020
1 parent bce9da7 commit b0f555d
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 10 deletions.
2 changes: 1 addition & 1 deletion eslint-bridge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@types/express": "4.16.0",
"@types/jest": "23.3.2",
"@types/node": "13.1.4",
"@types/semver": "^7.3.1",
"@types/semver": "7.3.1",
"fs-extra": "7.0.0",
"jest": "24.9.0",
"jest-sonar-reporter": "1.3.0",
Expand Down
2 changes: 1 addition & 1 deletion eslint-bridge/src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import * as semver from 'semver';
// still we might consider extending this range
// if everything which we need is working on older/newer versions
const TYPESCRIPT_MINIMUM_VERSION = '3.3.1';
const TYPESCRIPT_MAXIMUM_VERSION = '3.10.0';
const TYPESCRIPT_MAXIMUM_VERSION = '4.0.0';

export const PARSER_CONFIG_MODULE: Linter.ParserOptions = {
tokens: true,
Expand Down
6 changes: 5 additions & 1 deletion eslint-bridge/src/rules/no-globals-shadowing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@ function reportBadUsage(
break;
case 'ObjectPattern':
node.properties.forEach(prop => {
reportBadUsage((prop as estree.AssignmentProperty).value, buildMessage, context);
if (prop.type === 'Property') {
reportBadUsage(prop.value, buildMessage, context);
} else {
reportBadUsage(prop.argument, buildMessage, context);
}
});
break;
case 'ArrayPattern':
Expand Down
2 changes: 1 addition & 1 deletion eslint-bridge/src/rules/no-unenclosed-multiline-block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ function raiseInlineAndIndentedIssue(
});
}

function isNestingStatement(node: estree.Node | TSESTree.Node): node is NestingStatement {
function isNestingStatement(node: estree.Node): node is NestingStatement {
return NestingStatementLike.includes(node.type);
}

Expand Down
2 changes: 1 addition & 1 deletion eslint-bridge/src/rules/os-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function containsShellOption(otherArguments: Argument[]) {
return otherArguments.some(
arg =>
arg.type === 'ObjectExpression' &&
(arg.properties as estree.Property[]).some(
(arg.properties.filter(v => v.type === 'Property') as estree.Property[]).some(
({ key, value }) =>
isIdentifier(key, 'shell') && value.type === 'Literal' && value.value === true,
),
Expand Down
2 changes: 1 addition & 1 deletion eslint-bridge/tests/parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ describe('parseTypeScriptSourceFile', () => {
resetReportedNewerTypeScriptVersion();
checkTypeScriptVersionCompatibility('5.0.0');
expect(console.log).toHaveBeenCalledWith(
'WARN You are using version of TypeScript 5.0.0 which is not officially supported; supported versions >=3.3.1 <3.10.0',
'WARN You are using version of TypeScript 5.0.0 which is not officially supported; supported versions >=3.3.1 <4.0.0',
);
console.log = jest.fn();
checkTypeScriptVersionCompatibility('5.0.0');
Expand Down
6 changes: 6 additions & 0 deletions eslint-bridge/tests/rules/no-globals-shadowing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@ ruleTester.run('Special identifiers should not be bound or assigned', rule, {
function foo(undefined) { var x = undefined; }`,
errors: 4,
},
{
code: `
const {obj, ...eval} = foo();
`,
errors: 1,
},
],
});

Expand Down
5 changes: 5 additions & 0 deletions eslint-bridge/tests/rules/os-command.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ ruleTester.run('Executing OS commands is security-sensitive', rule, {
const exec = require('child_process').fork;
exec('echo child_process.exec ' + process.argv[2] + ' >> output.txt');`,
},
{
code: `
import * as cp from 'child_process';
cp.spawn('echo child_process.exec ' + process.argv[2] + ' >> output.txt', { ...x });`,
},
],
invalid: [
{
Expand Down
2 changes: 1 addition & 1 deletion eslint-bridge/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@
resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.3.tgz#7ee330ba7caafb98090bece86a5ee44115904c2c"
integrity sha512-ewFXqrQHlFsgc09MK5jP5iR7vumV/BYayNC6PgJO2LPe8vrnNFyjQjSppfEngITi0qvfKtzFvgKymGheFM9UOA==

"@types/semver@^7.3.1":
"@types/semver@7.3.1":
version "7.3.1"
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.3.1.tgz#7a9a5d595b6d873f338c867dcef64df289468cfa"
integrity sha512-ooD/FJ8EuwlDKOI6D9HWxgIgJjMg2cuziXm/42npDC8y4NjxplBUn9loewZiBNCt44450lHAU0OSb51/UqXeag==
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public void test_new_typescript() throws Exception {
Tests.setProfile(projectKey, "eslint-based-rules-profile", "ts");
BuildResult result = orchestrator.executeBuild(build);
assertThat(result.isSuccess()).isTrue();
assertThat(result.getLogsLines(l -> l.contains("You are using version of TypeScript " + tsVersion + " which is not officially supported; supported versions >=3.3.1 <3.10.0"))).hasSize(1);
assertThat(result.getLogsLines(l -> l.contains("You are using version of TypeScript " + tsVersion + " which is not officially supported; supported versions >=3.3.1 <4.0.0"))).hasSize(1);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ public void test() throws Exception {

String projectKey = "tsproject-test-ts-version-" + tsVersion;
SonarScanner build = SonarScanner.create()
.setDebugLogs(true)
.setProjectKey(projectKey)
.setSourceEncoding("UTF-8")
.setSourceDirs(".")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Discover and update the JavaScript / TypeScript properties in: **<!-- sonarcloud

## Supported Frameworks and Versions
* ECMAScript 5 / ECMAScript 2015 (ECMAScript 6) / ECMAScript 2016-2017-2018
* TypeScript >=3.2.1 <3.8.0. If it's not possible to upgrade version of TypeScript used by the project, consider installing supported TypeScript version just for the time of analysis.
* TypeScript >=3.3.1 <4.0.0. If it's not possible to upgrade version of TypeScript used by the project, consider installing supported TypeScript version just for the time of analysis.
* React JSX
* Vue.js
* Flow
Expand Down

0 comments on commit b0f555d

Please sign in to comment.