diff --git a/package.json b/package.json index 415f69f6..7f53c1ea 100644 --- a/package.json +++ b/package.json @@ -33,11 +33,11 @@ }, "license": "Apache-2.0", "dependencies": { - "@babel/generator": "7.17.7", + "@babel/generator": "^7.17.7", "@babel/parser": "^7.20.5", - "@babel/traverse": "7.23.2", - "@babel/types": "7.17.0", - "javascript-natural-sort": "0.7.1", + "@babel/traverse": "^7.23.2", + "@babel/types": "^7.17.0", + "javascript-natural-sort": "^0.7.1", "lodash": "^4.17.21" }, "devDependencies": { diff --git a/src/utils/__tests__/get-code-from-ast.spec.ts b/src/utils/__tests__/get-code-from-ast.spec.ts index da58c041..e264e16f 100644 --- a/src/utils/__tests__/get-code-from-ast.spec.ts +++ b/src/utils/__tests__/get-code-from-ast.spec.ts @@ -30,6 +30,7 @@ import a from 'a'; expect(format(formatted, { parser: 'babel' })).toEqual( `// first comment // second comment + import a from "a"; import c from "c"; import g from "g"; diff --git a/tests/Babel/__snapshots__/ppsi.spec.js.snap b/tests/Babel/__snapshots__/ppsi.spec.js.snap index 84c62858..fddaf997 100644 --- a/tests/Babel/__snapshots__/ppsi.spec.js.snap +++ b/tests/Babel/__snapshots__/ppsi.spec.js.snap @@ -20,6 +20,7 @@ function add(a,b) { } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // I am top level comment in this file. + import thirdParty from "third-party"; import z from "z"; diff --git a/tests/Flow/__snapshots__/ppsi.spec.js.snap b/tests/Flow/__snapshots__/ppsi.spec.js.snap index 0703b7dc..b5581e4e 100644 --- a/tests/Flow/__snapshots__/ppsi.spec.js.snap +++ b/tests/Flow/__snapshots__/ppsi.spec.js.snap @@ -33,7 +33,9 @@ export function givesAFoo3Obj(): AliasFoo3 { /** * @flow */ + // I am top level comment in this file. + import thirdParty from "third-party"; import abc from "@core/abc"; diff --git a/tests/ImportsNotSeparated/__snapshots__/ppsi.spec.js.snap b/tests/ImportsNotSeparated/__snapshots__/ppsi.spec.js.snap index 79565021..4dd3c460 100644 --- a/tests/ImportsNotSeparated/__snapshots__/ppsi.spec.js.snap +++ b/tests/ImportsNotSeparated/__snapshots__/ppsi.spec.js.snap @@ -96,6 +96,7 @@ function add(a:number,b:number) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // I am top level comment in this file. // I am second line of top level comment in this file. + import React from "react"; import "./commands"; @@ -131,6 +132,7 @@ function add(a:number,b:number) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // I am top level comment in this file. // I am second line of top level comment in this file. + import thirdParty from "third-party"; import z from "z"; import abc from "@core/abc"; @@ -245,6 +247,7 @@ function add(a:number,b:number) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //@ts-ignore // I am file top level comments + import a from "a"; import c from "c"; // I am stick to third party comment @@ -323,6 +326,7 @@ import fourLevelRelativePath from "../../../../fourLevelRelativePath"; import something from "@server/something"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // I am top level comment + import abc from "@core/abc"; import otherthing from "@core/otherthing"; import something from "@server/something"; @@ -378,6 +382,7 @@ import './commands'; // You can read more here: // https://on.cypress.io/configuration // *********************************************************** + // Import commands.js using ES2015 syntax: import "./commands"; diff --git a/tests/ImportsNotSeparatedRest/__snapshots__/ppsi.spec.js.snap b/tests/ImportsNotSeparatedRest/__snapshots__/ppsi.spec.js.snap index ecc8d513..e66cc504 100644 --- a/tests/ImportsNotSeparatedRest/__snapshots__/ppsi.spec.js.snap +++ b/tests/ImportsNotSeparatedRest/__snapshots__/ppsi.spec.js.snap @@ -96,6 +96,7 @@ function add(a:number,b:number) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // I am top level comment in this file. // I am second line of top level comment in this file. + import React from "react"; import "./commands"; @@ -131,6 +132,7 @@ function add(a:number,b:number) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // I am top level comment in this file. // I am second line of top level comment in this file. + import abc from "@core/abc"; import otherthing from "@core/otherthing"; import qwerty from "@server/qwerty"; @@ -188,6 +190,7 @@ function add(a:number,b:number) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //@ts-ignore // I am file top level comments + import otherthing from "@core/otherthing"; import something from "@server/something"; import component from "@ui/hello"; @@ -266,6 +269,7 @@ import fourLevelRelativePath from "../../../../fourLevelRelativePath"; import something from "@server/something"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // I am top level comment + import abc from "@core/abc"; import otherthing from "@core/otherthing"; import something from "@server/something"; @@ -321,6 +325,7 @@ import './commands'; // You can read more here: // https://on.cypress.io/configuration // *********************************************************** + // Import commands.js using ES2015 syntax: import "./commands"; diff --git a/tests/ImportsSeparated/__snapshots__/ppsi.spec.js.snap b/tests/ImportsSeparated/__snapshots__/ppsi.spec.js.snap index 4dc55697..4819f7ef 100644 --- a/tests/ImportsSeparated/__snapshots__/ppsi.spec.js.snap +++ b/tests/ImportsSeparated/__snapshots__/ppsi.spec.js.snap @@ -100,6 +100,7 @@ function add(a:number,b:number) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // I am top level comment in this file. // I am second line of top level comment in this file. + import React from "react"; import "./commands"; @@ -136,6 +137,7 @@ function add(a:number,b:number) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // I am top level comment in this file. // I am second line of top level comment in this file. + import thirdParty from "third-party"; import z from "z"; @@ -196,6 +198,7 @@ const workletAdd = (a:number,b:number) => { "use client"; // comment after directives + import abc from "@core/abc"; import otherthing from "@core/otherthing"; @@ -262,6 +265,7 @@ function add(a:number,b:number) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //@ts-ignore // I am file top level comments + import a from "a"; import c from "c"; // I am stick to third party comment @@ -347,6 +351,7 @@ import fourLevelRelativePath from "../../../../fourLevelRelativePath"; import something from "@server/something"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // I am top level comment + import abc from "@core/abc"; import otherthing from "@core/otherthing"; @@ -405,6 +410,7 @@ import './commands'; // You can read more here: // https://on.cypress.io/configuration // *********************************************************** + // Import commands.js using ES2015 syntax: import "./commands"; diff --git a/tests/ImportsSeparatedRest/__snapshots__/ppsi.spec.js.snap b/tests/ImportsSeparatedRest/__snapshots__/ppsi.spec.js.snap index b9a6b680..efb75cdd 100644 --- a/tests/ImportsSeparatedRest/__snapshots__/ppsi.spec.js.snap +++ b/tests/ImportsSeparatedRest/__snapshots__/ppsi.spec.js.snap @@ -100,6 +100,7 @@ function add(a:number,b:number) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // I am top level comment in this file. // I am second line of top level comment in this file. + import React from "react"; import "./commands"; @@ -136,6 +137,7 @@ function add(a:number,b:number) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // I am top level comment in this file. // I am second line of top level comment in this file. + import abc from "@core/abc"; import otherthing from "@core/otherthing"; @@ -197,6 +199,7 @@ function add(a:number,b:number) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //@ts-ignore // I am file top level comments + import otherthing from "@core/otherthing"; import something from "@server/something"; @@ -282,6 +285,7 @@ import fourLevelRelativePath from "../../../../fourLevelRelativePath"; import something from "@server/something"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // I am top level comment + import abc from "@core/abc"; import otherthing from "@core/otherthing"; @@ -340,6 +344,7 @@ import './commands'; // You can read more here: // https://on.cypress.io/configuration // *********************************************************** + // Import commands.js using ES2015 syntax: import "./commands"; diff --git a/tests/Vue/__snapshots__/ppsi.spec.js.snap b/tests/Vue/__snapshots__/ppsi.spec.js.snap index 065c444f..25e027a0 100644 --- a/tests/Vue/__snapshots__/ppsi.spec.js.snap +++ b/tests/Vue/__snapshots__/ppsi.spec.js.snap @@ -28,6 +28,7 @@ function add(a,b) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~