Skip to content

Commit

Permalink
Support TypeScript 4.5 (#2991)
Browse files Browse the repository at this point in the history
  • Loading branch information
yassin-kammoun-sonarsource authored Mar 3, 2022
1 parent f10c6c9 commit 5c7f483
Show file tree
Hide file tree
Showing 25 changed files with 264 additions and 81 deletions.
14 changes: 7 additions & 7 deletions eslint-bridge/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion eslint-bridge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"run-node": "2.0.0",
"scslre": "0.1.6",
"stylelint": "13.13.1",
"typescript": "4.4.3",
"typescript": "4.5.5",
"vue-eslint-parser": "8.3.0"
},
"bundledDependencies": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
"compilerOptions": {
"target": "es2018",
},
"files": ["file.tsx"]
}
17 changes: 2 additions & 15 deletions eslint-bridge/tests/rules/arguments-order.typescript.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,10 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import { RuleTester } from 'eslint';
import * as path from 'path';
import { RuleTesterTs } from '../RuleTesterTs';
import { rule } from 'rules/arguments-order';

const tsParserPath = require.resolve('@typescript-eslint/parser');
const ruleTester = new RuleTester({
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
project: path.resolve(`${__dirname}/../fixtures/rule-tester-project/tsconfig.json`),
},
parser: tsParserPath,
});
const placeHolderFilePath = path.resolve(`${__dirname}/../fixtures/rule-tester-project/file.ts`);
const ruleTester = new RuleTesterTs();

function invalid(code: string) {
const errors: RuleTester.TestCaseError[] = [];
Expand All @@ -45,7 +36,6 @@ function invalid(code: string) {
}
}
return {
filename: placeHolderFilePath,
code: code,
errors,
};
Expand All @@ -54,7 +44,6 @@ function invalid(code: string) {
ruleTester.run('Parameters should be passed in the correct order', rule, {
valid: [
{
filename: placeHolderFilePath,
code: `
const a = 1, b = 2, c = 3, d = 4, x = "", y = 5;
Expand Down Expand Up @@ -105,7 +94,6 @@ ruleTester.run('Parameters should be passed in the correct order', rule, {
],
invalid: [
{
filename: placeHolderFilePath,
code: `
function differentTypes(x: string, y: number, z = 42) {}
function nokForSameType(z: number, y: number) {
Expand All @@ -122,7 +110,6 @@ ruleTester.run('Parameters should be passed in the correct order', rule, {
],
},
{
filename: placeHolderFilePath,
code: `
interface A {
prop1: number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ void test() {
BuildResult buildResult = runBuild(orchestrator);
assertThat(buildResult.getLogsLines(l -> l.matches(".*INFO: Deploying custom rules bundle jar:file:.*/custom-eslint-based-rules-1\\.0\\.0\\.tgz to .*"))).hasSize(1);
assertThat(buildResult.getLogsLines(l -> l.contains("Custom JavaScript rules are deprecated and API will be removed in future version."))).isEmpty();
assertThat(buildResult.getLogsLines(l -> l.contains("TS API in custom rule: TS version 4.4.3"))).hasSize(2);
assertThat(buildResult.getLogsLines(l -> l.contains("TS API in custom rule: TS version 4.5.5"))).hasSize(2);
List<Issue> issues = findIssues("eslint-custom-rules:sqKey", orchestrator);
assertThat(issues).hasSize(2);
assertThat(issues).extracting(Issue::getRule, Issue::getComponent, Issue::getLine, Issue::getMessage)
Expand Down
13 changes: 13 additions & 0 deletions its/ruling/src/test/expected/js/angular.js/javascript-S1874.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,25 @@
'angular.js:src/AngularPublic.js':[
136,
],
'angular.js:src/ng/animate.js':[
232,
],
'angular.js:src/ng/location.js':[
94,
],
'angular.js:src/ngAnimate/shared.js':[
27,
36,
],
'angular.js:src/ngMock/browserTrigger.js':[
129,
146,
160,
223,
],
'angular.js:src/ngRoute/route.js':[
235,
],
'angular.js:src/ngTouch/directive/ngSwipe.js':[
85,
143,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
'es5-shim:es5-shim.js':[
1949,
1950,
1950,
],
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
'jStorage:jstorage.js':[
359,
],
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,22 @@
'javascript-test-sources:src/ecmascript6/Ghost/core/client/app/services/media-queries.js':[
37,
],
'javascript-test-sources:src/ecmascript6/Ghost/core/client/app/utils/ghost-paths.js':[
18,
],
'javascript-test-sources:src/ecmascript6/Ghost/core/client/tests/acceptance/settings/tags-test.js':[
30,
41,
],
'javascript-test-sources:src/ecmascript6/Ghost/core/client/tests/unit/controllers/post-settings-menu-test.js':[
174,
209,
265,
],
'javascript-test-sources:src/ecmascript6/Ghost/core/server/config/url.js':[
123,
124,
],
'javascript-test-sources:src/ecmascript6/Ghost/core/server/models/post.js':[
329,
],
Expand All @@ -21,12 +33,31 @@
'javascript-test-sources:src/ecmascript6/ecmascript6-today/8-iterators.js':[
41,
],
'javascript-test-sources:src/ecmascript6/router/src/router.js':[
99,
100,
],
'javascript-test-sources:src/ecmascript6/router/third_party/brick/brick-1.0.1.byob.js':[
337,
572,
575,
877,
1412,
1637,
1931,
3917,
],
'javascript-test-sources:src/ecmascript6/sonar-web/src/main/js/components/router/router.js':[
16,
],
'javascript-test-sources:src/ecmascript6/sonar-web/src/main/js/components/source-viewer/helpers/code-with-issue-locations-helper.js':[
27,
27,
],
'javascript-test-sources:src/ecmascript6/sonar-web/src/main/js/helpers/handlebars-helpers.js':[
544,
],
'javascript-test-sources:src/ecmascript6/sonar-web/src/main/js/libs/translate.js':[
76,
],
}
8 changes: 8 additions & 0 deletions its/ruling/src/test/expected/js/jshint/javascript-S1874.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
'jshint:src/lex.js':[
394,
1019,
1045,
1640,
],
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
{
'mootools-core:Grunt/plugins/karma/syn/lib/syn.js':[
1662,
2579,
],
'mootools-core:Source/Browser/Browser.js':[
51,
121,
],
'mootools-core:Source/Request/Request.js':[
190,
],
'mootools-core:Source/Types/Function.js':[
91,
],
Expand Down
6 changes: 6 additions & 0 deletions its/ruling/src/test/expected/js/ocanvas/javascript-S1874.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
166,
167,
],
'ocanvas:src/style.js':[
740,
740,
740,
740,
],
'ocanvas:src/touch.js':[
209,
210,
Expand Down
12 changes: 12 additions & 0 deletions its/ruling/src/test/expected/js/p5.js/javascript-S1874.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{
'p5.js:docs/yuidoc-p5-theme/assets/js/reference.js':[
2433,
2433,
4316,
4316,
4503,
4503,
],
'p5.js:docs/yuidoc-p5-theme/assets/js/render.js':[
123,
],
Expand All @@ -18,4 +26,8 @@
645,
647,
],
'p5.js:src/typography/loading_displaying.js':[
120,
124,
],
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
'paper.js:src/core/PaperScript.js':[
375,
421,
],
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
'prototype:src/prototype/ajax/response.js':[
159,
],
'prototype:src/prototype/deprecated.js':[
42,
46,
Expand Down
3 changes: 0 additions & 3 deletions its/ruling/src/test/expected/ts/Joust/typescript-S4325.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
'Joust:ts/TexturePreloader.ts':[
26,
],
'Joust:ts/components/GameWrapper.tsx':[
118,
],
'Joust:ts/components/game/TwoPlayerGame.tsx':[
40,
58,
Expand Down
Loading

0 comments on commit 5c7f483

Please sign in to comment.