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

Support TypeScript 5.0 and update dependencies #232

Open
wants to merge 5 commits into
base: v5
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,24 @@
},
"license": "Apache-2.0",
"dependencies": {
"@babel/generator": "7.17.7",
"@babel/parser": "^7.20.5",
"@babel/traverse": "7.17.3",
"@babel/types": "7.17.0",
"@babel/generator": "7.21.5",
"@babel/parser": "^7.21.8",
"@babel/traverse": "7.21.5",
"@babel/types": "7.21.5",
"javascript-natural-sort": "0.7.1",
"lodash": "^4.17.21"
},
"devDependencies": {
"@babel/core": "^7.20.7",
"@babel/core": "^7.21.8",
"@types/chai": "4.2.15",
"@types/jest": "26.0.20",
"@types/lodash": "4.14.168",
"@types/node": "14.14.34",
"@types/node": "20.2.1",
"@vue/compiler-sfc": "^3.2.41",
"jest": "26.6.3",
"prettier": "2.8",
"ts-jest": "26.5.3",
"typescript": "4.9.4"
"jest": "29.5.0",
"prettier": "2.8.8",
"ts-jest": "29.1.0",
"typescript": "5.0.4"
},
"peerDependencies": {
"@vue/compiler-sfc": "3.x",
Expand Down
6 changes: 6 additions & 0 deletions src/utils/get-sorted-nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export const getSortedNodes: GetSortedNodes = (nodes, options) => {
const finalNodesClone = finalNodes.map(clone);

const firstNodesComments = nodes[0].leadingComments;
const firstNodeStartLine = nodes[0].loc?.start.line;

// Remove all comments from sorted nodes
finalNodes.forEach(removeComments);
Expand All @@ -99,6 +100,11 @@ export const getSortedNodes: GetSortedNodes = (nodes, options) => {
});

if (firstNodesComments) {
const loc = finalNodes[0].loc;
if (loc && firstNodeStartLine !== undefined) {
// in order to maintain number of new lines after comments
loc.start.line = firstNodeStartLine;
}
addComments(finalNodes[0], 'leading', firstNodesComments);
}

Expand Down
1 change: 1 addition & 0 deletions tests/Flow/__snapshots__/ppsi.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export function givesAFoo3Obj(): AliasFoo3 {
/**
* @flow
*/

// I am top level comment in this file.
import thirdParty from "third-party";

Expand Down
1 change: 1 addition & 0 deletions tests/ImportsNotSeparated/__snapshots__/ppsi.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ import './commands';
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import "./commands";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ import './commands';
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import "./commands";

Expand Down
1 change: 1 addition & 0 deletions tests/ImportsSeparated/__snapshots__/ppsi.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ import './commands';
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import "./commands";

Expand Down
1 change: 1 addition & 0 deletions tests/ImportsSeparatedRest/__snapshots__/ppsi.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ import './commands';
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import "./commands";

Expand Down
42 changes: 42 additions & 0 deletions tests/Typescript/__snapshots__/ppsi.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,48 @@ export class AppComponent extends BaseComponent {

`;

exports[`imports-with-const-type-param.ts - typescript-verify: imports-with-const-type-param.ts 1`] = `
import z from 'z';
import { isEmpty } from "lodash-es";
import threeLevelRelativePath from "../../../threeLevelRelativePath";
import sameLevelRelativePath from "./sameLevelRelativePath";
import thirdParty from "third-party";
import oneLevelRelativePath from "../oneLevelRelativePath";
import otherthing from "@core/otherthing";
import abc from "@core/abc";
import twoLevelRelativePath from "../../twoLevelRelativePath";
import component from "@ui/hello";
import fourLevelRelativePath from "../../../../fourLevelRelativePath";
import something from "@server/something";
import xyz from "@ui/xyz";

import { Component } from "@angular/core";

function f<const T >(value: T) {}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import { Component } from "@angular/core";
import { isEmpty } from "lodash-es";
import thirdParty from "third-party";
import z from "z";

import abc from "@core/abc";
import otherthing from "@core/otherthing";

import something from "@server/something";

import component from "@ui/hello";
import xyz from "@ui/xyz";

import fourLevelRelativePath from "../../../../fourLevelRelativePath";
import threeLevelRelativePath from "../../../threeLevelRelativePath";
import twoLevelRelativePath from "../../twoLevelRelativePath";
import oneLevelRelativePath from "../oneLevelRelativePath";
import sameLevelRelativePath from "./sameLevelRelativePath";

function f<const T>(value: T) {}

`;

exports[`imports-with-satisfies.ts - typescript-verify: imports-with-satisfies.ts 1`] = `
import z from 'z';
import { isEmpty } from "lodash-es";
Expand Down
17 changes: 17 additions & 0 deletions tests/Typescript/imports-with-const-type-param.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import z from 'z';
import { isEmpty } from "lodash-es";
import threeLevelRelativePath from "../../../threeLevelRelativePath";
import sameLevelRelativePath from "./sameLevelRelativePath";
import thirdParty from "third-party";
import oneLevelRelativePath from "../oneLevelRelativePath";
import otherthing from "@core/otherthing";
import abc from "@core/abc";
import twoLevelRelativePath from "../../twoLevelRelativePath";
import component from "@ui/hello";
import fourLevelRelativePath from "../../../../fourLevelRelativePath";
import something from "@server/something";
import xyz from "@ui/xyz";

import { Component } from "@angular/core";

function f<const T >(value: T) {}