diff --git a/.prettierrc b/.prettierrc deleted file mode 100644 index 6589f7c77bbdb..0000000000000 --- a/.prettierrc +++ /dev/null @@ -1,9 +0,0 @@ -{ - "arrowParens": "avoid", - "printWidth": 80, - "bracketSpacing": true, - "semi": true, - "singleQuote": true, - "tabWidth": 2, - "trailingComma": "es5" -} diff --git a/.prettierrc.js b/.prettierrc.js new file mode 100644 index 0000000000000..02b8b0ba9a1a4 --- /dev/null +++ b/.prettierrc.js @@ -0,0 +1,39 @@ +const tsConfigBase = require('./tsconfig.json'); + +const ourPackages = new Set( + Object.keys(tsConfigBase.compilerOptions.paths).map( + // Remove extra '/*' if present in the package name. + packageName => packageName.split('/')[0] + ) +); +const appPackages = ['teleport', 'e-teleport', 'teleterm'].flatMap(pkg => [ + pkg, + `@gravitational/${pkg}`, +]); +const libraryPackages = [...ourPackages] + .filter(pkg => !appPackages.includes(pkg)) + .flatMap(pkg => [pkg, `@gravitational/${pkg}`]); + +module.exports = { + arrowParens: 'avoid', + printWidth: 80, + bracketSpacing: true, + plugins: [require('@ianvs/prettier-plugin-sort-imports')], + importOrder: [ + '', + '', + '', + '', + `^(${libraryPackages.join('|')})`, + '', + `^(${appPackages.join('|')})`, + '', + '^[./]', + ], + importOrderParserPlugins: ['typescript', 'jsx', 'decorators-legacy'], + importOrderTypeScriptVersion: '5.0.0', + semi: true, + singleQuote: true, + tabWidth: 2, + trailingComma: 'es5', +}; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d9a3561b44de4..6f79816aa81bc 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -202,6 +202,9 @@ importers: '@babel/preset-typescript': specifier: ^7.24.7 version: 7.24.7(@babel/core@7.25.2) + '@ianvs/prettier-plugin-sort-imports': + specifier: ^4.4.0 + version: 4.4.0(prettier@3.3.3) '@swc/core': specifier: ^1.7.26 version: 1.7.26 @@ -226,9 +229,6 @@ importers: eslint-plugin-babel: specifier: ^5.3.1 version: 5.3.1(eslint@8.57.0) - eslint-plugin-import: - specifier: 2.30.0 - version: 2.30.0(@typescript-eslint/parser@7.14.1(eslint@8.57.0)(typescript@5.7.2))(eslint-import-resolver-typescript@3.6.3)(eslint@8.57.0) eslint-plugin-jest: specifier: ^28.8.3 version: 28.8.3(@typescript-eslint/eslint-plugin@7.14.1(@typescript-eslint/parser@7.14.1(eslint@8.57.0)(typescript@5.7.2))(eslint@8.57.0)(typescript@5.7.2))(eslint@8.57.0)(jest@29.7.0(@types/node@22.7.4)(babel-plugin-macros@3.1.0))(typescript@5.7.2) @@ -517,6 +517,10 @@ packages: resolution: {integrity: sha512-BcYH1CVJBO9tvyIZ2jVeXgSIMvGZ2FDRvDdOIVQyuklNKSsx+eppDEBq/g47Ayw+RqNFE+URvOShmf+f/qwAlA==} engines: {node: '>=6.9.0'} + '@babel/code-frame@7.26.2': + resolution: {integrity: sha512-RJlIHRueQgwWitWgF8OdFYGZX328Ax5BCemNGlqHfplnRT9ESi8JkFlvaVYbS+UubVY6dpv87Fs2u5M29iNFVQ==} + engines: {node: '>=6.9.0'} + '@babel/compat-data@7.25.4': resolution: {integrity: sha512-+LGRog6RAsCJrrrg/IO6LGmpphNe5DiK30dGjCoxxeGv49B10/3XYGxPsAwrDlMFcFEvdAUavDT8r9k/hSyQqQ==} engines: {node: '>=6.9.0'} @@ -533,6 +537,10 @@ packages: resolution: {integrity: sha512-VPC82gr1seXOpkjAAKoLhP50vx4vGNlF4msF64dSFq1P8RfB+QAuJWGHPXXPc8QyfVWwwB/TNNU4+ayZmHNbZw==} engines: {node: '>=6.9.0'} + '@babel/generator@7.26.3': + resolution: {integrity: sha512-6FF/urZvD0sTeO7k6/B15pMLC4CHUv1426lzr3N01aHJTl046uCAh9LXW/fzeXXjPNCJ6iABW5XaWOsIZB93aQ==} + engines: {node: '>=6.9.0'} + '@babel/helper-annotate-as-pure@7.24.7': resolution: {integrity: sha512-BaDeOonYvhdKw+JoMVkAixAAJzG2jVPIwWoKBPdYuY9b452e2rPuI9QPYh3KpofZ3pW2akOmwZLOiOsHMiqRAg==} engines: {node: '>=6.9.0'} @@ -608,10 +616,18 @@ packages: resolution: {integrity: sha512-pO9KhhRcuUyGnJWwyEgnRJTSIZHiT+vMD0kPeD+so0l7mxkMT19g3pjY9GTnHySck/hDzq+dtW/4VgnMkippsQ==} engines: {node: '>=6.9.0'} + '@babel/helper-string-parser@7.25.9': + resolution: {integrity: sha512-4A/SCr/2KLd5jrtOMFzaKjVtAei3+2r/NChoBNoZ3EyP/+GlhoaEGoWOZUmFmoITP7zOJyHIMm+DYRd8o3PvHA==} + engines: {node: '>=6.9.0'} + '@babel/helper-validator-identifier@7.24.7': resolution: {integrity: sha512-rR+PBcQ1SMQDDyF6X0wxtG8QyLCgUB0eRAGguqRLfkCA87l7yAP7ehq8SNj96OOGTO8OBV70KhuFYcIkHXOg0w==} engines: {node: '>=6.9.0'} + '@babel/helper-validator-identifier@7.25.9': + resolution: {integrity: sha512-Ed61U6XJc3CVRfkERJWDz4dJwKe7iLmmJsbOGu9wSloNSFttHV0I8g6UAgb7qnK5ly5bGLPd4oXZlxCdANBOWQ==} + engines: {node: '>=6.9.0'} + '@babel/helper-validator-option@7.24.8': resolution: {integrity: sha512-xb8t9tD1MHLungh/AIoWYN+gVHaB9kwlu8gffXGSt3FFEIT7RjS+xWbc2vUD1UTZdIpKj/ab3rdqJ7ufngyi2Q==} engines: {node: '>=6.9.0'} @@ -638,6 +654,11 @@ packages: engines: {node: '>=6.0.0'} hasBin: true + '@babel/parser@7.26.3': + resolution: {integrity: sha512-WJ/CvmY8Mea8iDXo6a7RK2wbmJITT5fN3BEkRuFlxVyNx8jOKIIhmC4fSkTcPcf8JyavbBwIe6OpiCOBXt/IcA==} + engines: {node: '>=6.0.0'} + hasBin: true + '@babel/plugin-bugfix-firefox-class-in-computed-class-key@7.25.3': resolution: {integrity: sha512-wUrcsxZg6rqBXG05HG1FPYgsP6EvwF4WpBbxIpWIIYnH8wG0gzx3yZY3dtEHas4sTAOGkbTsc9EGPxwff8lRoA==} engines: {node: '>=6.9.0'} @@ -1149,6 +1170,10 @@ packages: resolution: {integrity: sha512-aOOgh1/5XzKvg1jvVz7AVrx2piJ2XBi227DHmbY6y+bM9H2FlN+IfecYu4Xl0cNiiVejlsCri89LUsbj8vJD9Q==} engines: {node: '>=6.9.0'} + '@babel/template@7.25.9': + resolution: {integrity: sha512-9DGttpmPvIxBb/2uwpVo3dqJ+O6RooAFOS+lB+xDqoE2PVCE8nfoHMdZLpfCQRLwvohzXISPZcgxt80xLfsuwg==} + engines: {node: '>=6.9.0'} + '@babel/traverse@7.25.4': resolution: {integrity: sha512-VJ4XsrD+nOvlXyLzmLzUs/0qjFS4sK30te5yEFlvbbUNEgKaVb2BHZUpAL+ttLPQAHNrsI3zZisbfha5Cvr8vg==} engines: {node: '>=6.9.0'} @@ -1157,6 +1182,10 @@ packages: resolution: {integrity: sha512-9Vrcx5ZW6UwK5tvqsj0nGpp/XzqthkT0dqIc9g1AdtygFToNtTF67XzYS//dm+SAK9cp3B9R4ZO/46p63SCjlQ==} engines: {node: '>=6.9.0'} + '@babel/traverse@7.26.4': + resolution: {integrity: sha512-fH+b7Y4p3yqvApJALCPJcwb0/XaOSgtK4pzV6WVjPR5GLFQBRI7pfoX2V2iM48NXvX07NUxxm1Vw98YjqTcU5w==} + engines: {node: '>=6.9.0'} + '@babel/types@7.25.4': resolution: {integrity: sha512-zQ1ijeeCXVEh+aNL0RlmkPkG8HUiDcU2pzQQFjtbntgAczRASFzj4H+6+bV+dy1ntKR14I/DypeuRG1uma98iQ==} engines: {node: '>=6.9.0'} @@ -1165,6 +1194,10 @@ packages: resolution: {integrity: sha512-/l42B1qxpG6RdfYf343Uw1vmDjeNhneUXtzhojE7pDgfpEypmRhI6j1kr17XCVv4Cgl9HdAiQY2x0GwKm7rWCw==} engines: {node: '>=6.9.0'} + '@babel/types@7.26.3': + resolution: {integrity: sha512-vN5p+1kl59GVKMvTHt55NzzmYVxprfJD+ql7U9NFIfKCBkYE55LYtS+WtPlaYOyzydrKI8Nezd+aZextrd+FMA==} + engines: {node: '>=6.9.0'} + '@base2/pretty-print-object@1.0.1': resolution: {integrity: sha512-4iri8i1AqYHJE2DstZYkyEprg6Pq6sKx3xn5FpySk9sNhH7qN2LLlHJCfDTZRILNwQNPD7mATWM0TBui7uC1pA==} @@ -1646,6 +1679,15 @@ packages: resolution: {integrity: sha512-6EwiSjwWYP7pTckG6I5eyFANjPhmPjUX9JRLUSfNPC7FX7zK9gyZAfUEaECL6ALTpGX5AjnBq3C9XmVWPitNpw==} deprecated: Use @eslint/object-schema instead + '@ianvs/prettier-plugin-sort-imports@4.4.0': + resolution: {integrity: sha512-f4/e+/ANGk3tHuwRW0uh2YuBR50I4h1ZjGQ+5uD8sWfinHTivQsnieR5cz24t8M6Vx4rYvZ5v/IEKZhYpzQm9Q==} + peerDependencies: + '@vue/compiler-sfc': 2.7.x || 3.x + prettier: 2 || 3 + peerDependenciesMeta: + '@vue/compiler-sfc': + optional: true + '@inquirer/confirm@3.2.0': resolution: {integrity: sha512-oOIwPs0Dvq5220Z8lGL/6LHRTEr9TgLHmiI99Rj1PJ1p1czTys+olrgBqZk4E2qC0YTzeHprxSQmoHioVdJ7Lw==} engines: {node: '>=18'} @@ -5087,6 +5129,11 @@ packages: engines: {node: '>=4'} hasBin: true + jsesc@3.1.0: + resolution: {integrity: sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==} + engines: {node: '>=6'} + hasBin: true + json-buffer@3.0.1: resolution: {integrity: sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==} @@ -6975,6 +7022,12 @@ snapshots: '@babel/highlight': 7.24.7 picocolors: 1.0.1 + '@babel/code-frame@7.26.2': + dependencies: + '@babel/helper-validator-identifier': 7.25.9 + js-tokens: 4.0.0 + picocolors: 1.1.0 + '@babel/compat-data@7.25.4': {} '@babel/core@7.25.2': @@ -6999,7 +7052,7 @@ snapshots: '@babel/generator@7.25.5': dependencies: - '@babel/types': 7.25.4 + '@babel/types': 7.25.6 '@jridgewell/gen-mapping': 0.3.5 '@jridgewell/trace-mapping': 0.3.25 jsesc: 2.5.2 @@ -7011,9 +7064,17 @@ snapshots: '@jridgewell/trace-mapping': 0.3.25 jsesc: 2.5.2 + '@babel/generator@7.26.3': + dependencies: + '@babel/parser': 7.26.3 + '@babel/types': 7.26.3 + '@jridgewell/gen-mapping': 0.3.5 + '@jridgewell/trace-mapping': 0.3.25 + jsesc: 3.1.0 + '@babel/helper-annotate-as-pure@7.24.7': dependencies: - '@babel/types': 7.25.4 + '@babel/types': 7.25.6 '@babel/helper-builder-binary-assignment-operator-visitor@7.24.7': dependencies: @@ -7070,8 +7131,8 @@ snapshots: '@babel/helper-module-imports@7.24.7': dependencies: - '@babel/traverse': 7.25.4 - '@babel/types': 7.25.4 + '@babel/traverse': 7.25.6 + '@babel/types': 7.25.6 transitivePeerDependencies: - supports-color @@ -7081,7 +7142,7 @@ snapshots: '@babel/helper-module-imports': 7.24.7 '@babel/helper-simple-access': 7.24.7 '@babel/helper-validator-identifier': 7.24.7 - '@babel/traverse': 7.25.4 + '@babel/traverse': 7.25.6 transitivePeerDependencies: - supports-color @@ -7096,7 +7157,7 @@ snapshots: '@babel/core': 7.25.2 '@babel/helper-annotate-as-pure': 7.24.7 '@babel/helper-wrap-function': 7.25.0 - '@babel/traverse': 7.25.4 + '@babel/traverse': 7.25.6 transitivePeerDependencies: - supports-color @@ -7105,14 +7166,14 @@ snapshots: '@babel/core': 7.25.2 '@babel/helper-member-expression-to-functions': 7.24.8 '@babel/helper-optimise-call-expression': 7.24.7 - '@babel/traverse': 7.25.4 + '@babel/traverse': 7.25.6 transitivePeerDependencies: - supports-color '@babel/helper-simple-access@7.24.7': dependencies: - '@babel/traverse': 7.25.4 - '@babel/types': 7.25.4 + '@babel/traverse': 7.25.6 + '@babel/types': 7.25.6 transitivePeerDependencies: - supports-color @@ -7125,14 +7186,18 @@ snapshots: '@babel/helper-string-parser@7.24.8': {} + '@babel/helper-string-parser@7.25.9': {} + '@babel/helper-validator-identifier@7.24.7': {} + '@babel/helper-validator-identifier@7.25.9': {} + '@babel/helper-validator-option@7.24.8': {} '@babel/helper-wrap-function@7.25.0': dependencies: '@babel/template': 7.25.0 - '@babel/traverse': 7.25.4 + '@babel/traverse': 7.25.6 '@babel/types': 7.25.6 transitivePeerDependencies: - supports-color @@ -7140,7 +7205,7 @@ snapshots: '@babel/helpers@7.25.0': dependencies: '@babel/template': 7.25.0 - '@babel/types': 7.25.4 + '@babel/types': 7.25.6 '@babel/highlight@7.24.7': dependencies: @@ -7151,17 +7216,21 @@ snapshots: '@babel/parser@7.25.4': dependencies: - '@babel/types': 7.25.4 + '@babel/types': 7.25.6 '@babel/parser@7.25.6': dependencies: '@babel/types': 7.25.6 + '@babel/parser@7.26.3': + dependencies: + '@babel/types': 7.26.3 + '@babel/plugin-bugfix-firefox-class-in-computed-class-key@7.25.3(@babel/core@7.25.2)': dependencies: '@babel/core': 7.25.2 '@babel/helper-plugin-utils': 7.24.8 - '@babel/traverse': 7.25.4 + '@babel/traverse': 7.25.6 transitivePeerDependencies: - supports-color @@ -7188,7 +7257,7 @@ snapshots: dependencies: '@babel/core': 7.25.2 '@babel/helper-plugin-utils': 7.24.8 - '@babel/traverse': 7.25.4 + '@babel/traverse': 7.25.6 transitivePeerDependencies: - supports-color @@ -7313,7 +7382,7 @@ snapshots: '@babel/helper-plugin-utils': 7.24.8 '@babel/helper-remap-async-to-generator': 7.25.0(@babel/core@7.25.2) '@babel/plugin-syntax-async-generators': 7.8.4(@babel/core@7.25.2) - '@babel/traverse': 7.25.4 + '@babel/traverse': 7.25.6 transitivePeerDependencies: - supports-color @@ -7360,7 +7429,7 @@ snapshots: '@babel/helper-compilation-targets': 7.25.2 '@babel/helper-plugin-utils': 7.24.8 '@babel/helper-replace-supers': 7.25.0(@babel/core@7.25.2) - '@babel/traverse': 7.25.4 + '@babel/traverse': 7.25.6 globals: 11.12.0 transitivePeerDependencies: - supports-color @@ -7426,7 +7495,7 @@ snapshots: '@babel/core': 7.25.2 '@babel/helper-compilation-targets': 7.25.2 '@babel/helper-plugin-utils': 7.24.8 - '@babel/traverse': 7.25.4 + '@babel/traverse': 7.25.6 transitivePeerDependencies: - supports-color @@ -7475,7 +7544,7 @@ snapshots: '@babel/helper-module-transforms': 7.25.2(@babel/core@7.25.2) '@babel/helper-plugin-utils': 7.24.8 '@babel/helper-validator-identifier': 7.24.7 - '@babel/traverse': 7.25.4 + '@babel/traverse': 7.25.6 transitivePeerDependencies: - supports-color @@ -7588,7 +7657,7 @@ snapshots: '@babel/helper-module-imports': 7.24.7 '@babel/helper-plugin-utils': 7.24.8 '@babel/plugin-syntax-jsx': 7.24.7(@babel/core@7.25.2) - '@babel/types': 7.25.4 + '@babel/types': 7.25.6 transitivePeerDependencies: - supports-color @@ -7763,7 +7832,7 @@ snapshots: dependencies: '@babel/core': 7.25.2 '@babel/helper-plugin-utils': 7.24.8 - '@babel/types': 7.25.4 + '@babel/types': 7.25.6 esutils: 2.0.3 '@babel/preset-react@7.24.7(@babel/core@7.25.2)': @@ -7802,16 +7871,22 @@ snapshots: '@babel/template@7.25.0': dependencies: '@babel/code-frame': 7.24.7 - '@babel/parser': 7.25.4 - '@babel/types': 7.25.4 + '@babel/parser': 7.25.6 + '@babel/types': 7.25.6 + + '@babel/template@7.25.9': + dependencies: + '@babel/code-frame': 7.26.2 + '@babel/parser': 7.26.3 + '@babel/types': 7.26.3 '@babel/traverse@7.25.4': dependencies: '@babel/code-frame': 7.24.7 - '@babel/generator': 7.25.5 - '@babel/parser': 7.25.4 + '@babel/generator': 7.25.6 + '@babel/parser': 7.25.6 '@babel/template': 7.25.0 - '@babel/types': 7.25.4 + '@babel/types': 7.25.6 debug: 4.3.7 globals: 11.12.0 transitivePeerDependencies: @@ -7829,6 +7904,18 @@ snapshots: transitivePeerDependencies: - supports-color + '@babel/traverse@7.26.4': + dependencies: + '@babel/code-frame': 7.26.2 + '@babel/generator': 7.26.3 + '@babel/parser': 7.26.3 + '@babel/template': 7.25.9 + '@babel/types': 7.26.3 + debug: 4.3.7 + globals: 11.12.0 + transitivePeerDependencies: + - supports-color + '@babel/types@7.25.4': dependencies: '@babel/helper-string-parser': 7.24.8 @@ -7841,6 +7928,11 @@ snapshots: '@babel/helper-validator-identifier': 7.24.7 to-fast-properties: 2.0.0 + '@babel/types@7.26.3': + dependencies: + '@babel/helper-string-parser': 7.25.9 + '@babel/helper-validator-identifier': 7.25.9 + '@base2/pretty-print-object@1.0.1': {} '@bcoe/v8-coverage@0.2.3': {} @@ -8302,6 +8394,17 @@ snapshots: '@humanwhocodes/object-schema@2.0.2': {} + '@ianvs/prettier-plugin-sort-imports@4.4.0(prettier@3.3.3)': + dependencies: + '@babel/generator': 7.26.3 + '@babel/parser': 7.26.3 + '@babel/traverse': 7.26.4 + '@babel/types': 7.26.3 + prettier: 3.3.3 + semver: 7.6.3 + transitivePeerDependencies: + - supports-color + '@inquirer/confirm@3.2.0': dependencies: '@inquirer/core': 9.2.1 @@ -8992,7 +9095,8 @@ snapshots: '@rollup/rollup-win32-x64-msvc@4.23.0': optional: true - '@rtsao/scc@1.1.0': {} + '@rtsao/scc@1.1.0': + optional: true '@sideway/address@4.1.5': dependencies: @@ -9357,20 +9461,20 @@ snapshots: '@types/babel__core@7.20.5': dependencies: - '@babel/parser': 7.25.4 - '@babel/types': 7.25.4 + '@babel/parser': 7.25.6 + '@babel/types': 7.25.6 '@types/babel__generator': 7.6.3 '@types/babel__template': 7.4.1 '@types/babel__traverse': 7.20.6 '@types/babel__generator@7.6.3': dependencies: - '@babel/types': 7.25.4 + '@babel/types': 7.25.6 '@types/babel__template@7.4.1': dependencies: - '@babel/parser': 7.25.4 - '@babel/types': 7.25.4 + '@babel/parser': 7.25.6 + '@babel/types': 7.25.6 '@types/babel__traverse@7.20.6': dependencies: @@ -9494,7 +9598,8 @@ snapshots: '@types/json-schema@7.0.13': {} - '@types/json5@0.0.29': {} + '@types/json5@0.0.29': + optional: true '@types/keyv@4.2.0': dependencies: @@ -10063,6 +10168,7 @@ snapshots: es-errors: 1.3.0 es-object-atoms: 1.0.0 es-shim-unscopables: 1.0.2 + optional: true array.prototype.flat@1.3.2: dependencies: @@ -10070,6 +10176,7 @@ snapshots: define-properties: 1.2.1 es-abstract: 1.23.3 es-shim-unscopables: 1.0.2 + optional: true array.prototype.flatmap@1.3.2: dependencies: @@ -11231,6 +11338,7 @@ snapshots: resolve: 1.22.8 transitivePeerDependencies: - supports-color + optional: true eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@7.14.1(eslint@8.57.0)(typescript@5.7.2))(eslint-plugin-import@2.30.0)(eslint@8.57.0): dependencies: @@ -11261,6 +11369,7 @@ snapshots: eslint-import-resolver-typescript: 3.6.3(@typescript-eslint/parser@7.14.1(eslint@8.57.0)(typescript@5.7.2))(eslint-plugin-import@2.30.0)(eslint@8.57.0) transitivePeerDependencies: - supports-color + optional: true eslint-module-utils@2.8.2(@typescript-eslint/parser@7.14.1(eslint@8.57.0)(typescript@5.7.2))(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@7.14.1(eslint@8.57.0)(typescript@5.7.2))(eslint-plugin-import@2.30.0)(eslint@8.57.0))(eslint@8.57.0): dependencies: @@ -11304,6 +11413,7 @@ snapshots: - eslint-import-resolver-typescript - eslint-import-resolver-webpack - supports-color + optional: true eslint-plugin-jest-dom@5.4.0(@testing-library/dom@10.1.0)(eslint@8.57.0): dependencies: @@ -12634,7 +12744,7 @@ snapshots: jest-snapshot@29.7.0: dependencies: '@babel/core': 7.25.2 - '@babel/generator': 7.25.5 + '@babel/generator': 7.25.6 '@babel/plugin-syntax-jsx': 7.24.7(@babel/core@7.25.2) '@babel/plugin-syntax-typescript': 7.24.7(@babel/core@7.25.2) '@babel/types': 7.25.6 @@ -12831,6 +12941,8 @@ snapshots: jsesc@2.5.2: {} + jsesc@3.1.0: {} + json-buffer@3.0.1: {} json-parse-even-better-errors@2.3.1: {} @@ -12845,6 +12957,7 @@ snapshots: json5@1.0.2: dependencies: minimist: 1.2.8 + optional: true json5@2.2.3: {} @@ -13266,6 +13379,7 @@ snapshots: call-bind: 1.0.7 define-properties: 1.2.1 es-abstract: 1.23.3 + optional: true object.values@1.2.0: dependencies: @@ -14406,6 +14520,7 @@ snapshots: json5: 1.0.2 minimist: 1.2.8 strip-bom: 3.0.0 + optional: true tsconfig-paths@4.2.0: dependencies: diff --git a/tsconfig.json b/tsconfig.json index 233b31f68ee13..0bee31f133753 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -21,6 +21,8 @@ "noEmit": true, "types": ["node", "@types/wicg-file-system-access"], "paths": { + "build/*": ["web/packages/build/src/*"], + "build": ["web/packages/build/src/"], "shared/*": ["web/packages/shared/*"], "design/*": ["web/packages/design/src/*"], "design": ["web/packages/design/src/"], @@ -28,7 +30,7 @@ "teleport": ["web/packages/teleport/src/"], "teleterm/*": ["web/packages/teleterm/src/*"], "e-teleport/*": ["e/web/teleport/src/*"], - "gen-proto-ts/*": ["gen/proto/ts/*"], + "gen-proto-ts/*": ["gen/proto/ts/*"] } }, "exclude": [ diff --git a/web/.storybook/preview.tsx b/web/.storybook/preview.tsx index dcf775d5c3d49..405295e381006 100644 --- a/web/.storybook/preview.tsx +++ b/web/.storybook/preview.tsx @@ -16,20 +16,21 @@ * along with this program. If not, see . */ +import { Preview } from '@storybook/react'; +import { initialize, mswLoader } from 'msw-storybook-addon'; import { ComponentType, PropsWithChildren } from 'react'; + +import Box from '../packages/design/src/Box'; import { bblpTheme, darkTheme, lightTheme } from '../packages/design/src/theme'; +import { Theme } from '../packages/design/src/theme/themes/types'; import { ConfiguredThemeProvider } from '../packages/design/src/ThemeProvider'; -import Box from '../packages/design/src/Box'; +import history from '../packages/teleport/src/services/history/history'; +import { UserContextProvider } from '../packages/teleport/src/User'; import { StaticThemeProvider as TeletermThemeProvider } from '../packages/teleterm/src/ui/ThemeProvider'; import { darkTheme as teletermDarkTheme, lightTheme as teletermLightTheme, } from '../packages/teleterm/src/ui/ThemeProvider/theme'; -import history from '../packages/teleport/src/services/history/history'; -import { UserContextProvider } from '../packages/teleport/src/User'; -import { Preview } from '@storybook/react'; -import { Theme } from '../packages/design/src/theme/themes/types'; -import { initialize, mswLoader } from 'msw-storybook-addon'; initialize(); diff --git a/web/.storybook/vite.config.mts b/web/.storybook/vite.config.mts index 7c20b2fb85432..3bd030caba261 100644 --- a/web/.storybook/vite.config.mts +++ b/web/.storybook/vite.config.mts @@ -1,6 +1,7 @@ import { defineConfig } from 'vite'; -import { tsconfigPathsPlugin } from '@gravitational/build/vite/tsconfigPaths.mjs'; + import { reactPlugin } from '@gravitational/build/vite/react.mjs'; +import { tsconfigPathsPlugin } from '@gravitational/build/vite/tsconfigPaths.mjs'; export default defineConfig(({ mode }) => ({ plugins: [tsconfigPathsPlugin(), reactPlugin(mode)], diff --git a/web/@types/styled-components.d.ts b/web/@types/styled-components.d.ts index 7d98d7fc8d0d3..62714bfd3dceb 100644 --- a/web/@types/styled-components.d.ts +++ b/web/@types/styled-components.d.ts @@ -17,6 +17,7 @@ */ import { CSSProp } from 'styled-components'; + import 'react'; import { Theme } from 'design/theme/themes/types'; diff --git a/web/README.md b/web/README.md index 2c8d892a2898c..7799ee04730bf 100644 --- a/web/README.md +++ b/web/README.md @@ -190,7 +190,7 @@ pnpm dlx browserslist 'last 2 chrome version, last 2 edge version, last 2 firefo // Set the default "editor.formatOnSave": false, // absolute config path - "prettier.configPath": ".prettierrc", + "prettier.configPath": ".prettierrc.js", // enable per-language "[html]": { "editor.formatOnSave": true, diff --git a/web/packages/build/.eslintrc.js b/web/packages/build/.eslintrc.js index 8a74e1cd0e80b..2d330b9ab1c98 100644 --- a/web/packages/build/.eslintrc.js +++ b/web/packages/build/.eslintrc.js @@ -67,25 +67,6 @@ module.exports = { }, ], rules: { - 'import/order': [ - 'error', - { - groups: [ - 'builtin', - 'external', - 'internal', - 'parent', - 'sibling', - 'index', - 'object', - 'type', - ], - 'newlines-between': 'always-and-inside-groups', - }, - ], - // typescript-eslint recommends to turn import/no-unresolved off. - // https://typescript-eslint.io/troubleshooting/typed-linting/performance/#eslint-plugin-import - 'import/no-unresolved': 0, 'no-unused-vars': 'off', // disabled to allow the typescript one to take over and avoid errors in reporting '@typescript-eslint/no-unused-vars': ['error'], diff --git a/web/packages/build/jest/jest-environment-patched-jsdom.js b/web/packages/build/jest/jest-environment-patched-jsdom.js index 642a360b9e395..cbc704768bfb8 100644 --- a/web/packages/build/jest/jest-environment-patched-jsdom.js +++ b/web/packages/build/jest/jest-environment-patched-jsdom.js @@ -1,4 +1,4 @@ -import { TextEncoder, TextDecoder } from 'node:util'; +import { TextDecoder, TextEncoder } from 'node:util'; import { TestEnvironment as JSDOMEnvironment } from 'jest-environment-jsdom'; diff --git a/web/packages/build/package.json b/web/packages/build/package.json index f02964680e2b0..4c9acc71e8fee 100644 --- a/web/packages/build/package.json +++ b/web/packages/build/package.json @@ -14,6 +14,7 @@ "@babel/preset-env": "^7.25.4", "@babel/preset-react": "^7.24.7", "@babel/preset-typescript": "^7.24.7", + "@ianvs/prettier-plugin-sort-imports": "^4.4.0", "@swc/core": "^1.7.26", "@swc/plugin-styled-components": "^3.0.2", "@types/jsdom": "^21.1.7", @@ -22,7 +23,6 @@ "eslint": "^8.56.0", "eslint-import-resolver-typescript": "^3.6.3", "eslint-plugin-babel": "^5.3.1", - "eslint-plugin-import": "2.30.0", "eslint-plugin-jest": "^28.8.3", "eslint-plugin-jest-dom": "^5.4.0", "eslint-plugin-react": "^7.37.0", diff --git a/web/packages/build/vite/config.ts b/web/packages/build/vite/config.ts index 58b23d10453e4..0d15db5fe3dbc 100644 --- a/web/packages/build/vite/config.ts +++ b/web/packages/build/vite/config.ts @@ -19,17 +19,15 @@ import { existsSync, readFileSync } from 'fs'; import { resolve } from 'path'; -import { defineConfig } from 'vite'; import { visualizer } from 'rollup-plugin-visualizer'; +import { defineConfig, type UserConfig } from 'vite'; import wasm from 'vite-plugin-wasm'; -import { htmlPlugin, transformPlugin } from './html'; import { generateAppHashFile } from './apphash'; +import { htmlPlugin, transformPlugin } from './html'; import { reactPlugin } from './react.mjs'; import { tsconfigPathsPlugin } from './tsconfigPaths.mjs'; -import type { UserConfig } from 'vite'; - const DEFAULT_PROXY_TARGET = '127.0.0.1:3080'; const ENTRY_FILE_NAME = 'app/app.js'; diff --git a/web/packages/build/vite/html.ts b/web/packages/build/vite/html.ts index eaf802aa34f56..34bfdfe124d68 100644 --- a/web/packages/build/vite/html.ts +++ b/web/packages/build/vite/html.ts @@ -17,13 +17,12 @@ */ import { readFileSync } from 'fs'; +import type { IncomingHttpHeaders } from 'http'; import { get } from 'https'; import { resolve } from 'path'; import { JSDOM } from 'jsdom'; - import type { Plugin } from 'vite'; -import type { IncomingHttpHeaders } from 'http'; function getHTML(target: string, headers: IncomingHttpHeaders) { return new Promise<{ data: string; headers: IncomingHttpHeaders }>( diff --git a/web/packages/design/src/Alert/Alert.story.tsx b/web/packages/design/src/Alert/Alert.story.tsx index 422cbec301dee..888fbafb7e9eb 100644 --- a/web/packages/design/src/Alert/Alert.story.tsx +++ b/web/packages/design/src/Alert/Alert.story.tsx @@ -19,7 +19,6 @@ import { Restore } from 'design/Icon'; import { Box } from '..'; - import { Alert, AlertProps, Banner } from './Alert'; export default { diff --git a/web/packages/design/src/Alert/Alert.tsx b/web/packages/design/src/Alert/Alert.tsx index f8ce4b7269310..bfc58e4610850 100644 --- a/web/packages/design/src/Alert/Alert.tsx +++ b/web/packages/design/src/Alert/Alert.tsx @@ -18,20 +18,19 @@ import React, { useState } from 'react'; import styled, { useTheme } from 'styled-components'; -import { style, color, ColorProps } from 'styled-system'; +import { color, ColorProps, style } from 'styled-system'; import { IconProps } from 'design/Icon/Icon'; - import { StatusIcon, StatusKind } from 'design/StatusIcon'; -import { space, SpaceProps, width, WidthProps } from '../system'; -import { Theme } from '../theme'; -import * as Icon from '../Icon'; -import Flex from '../Flex'; -import Text from '../Text'; import Box from '../Box'; -import { ButtonFill, ButtonIntent, Button } from '../Button'; +import { Button, ButtonFill, ButtonIntent } from '../Button'; import ButtonIcon from '../ButtonIcon'; +import Flex from '../Flex'; +import * as Icon from '../Icon'; +import { space, SpaceProps, width, WidthProps } from '../system'; +import Text from '../Text'; +import { Theme } from '../theme'; const linkColor = style({ prop: 'linkColor', diff --git a/web/packages/design/src/Button/Button.test.tsx b/web/packages/design/src/Button/Button.test.tsx index 8f4528e102baf..034b1f1929b07 100644 --- a/web/packages/design/src/Button/Button.test.tsx +++ b/web/packages/design/src/Button/Button.test.tsx @@ -22,14 +22,14 @@ import React, { PropsWithChildren, } from 'react'; -import { render, theme, screen } from 'design/utils/testing'; +import { render, screen, theme } from 'design/utils/testing'; import { Button, ButtonPrimary, ButtonSecondary, - ButtonWarning, ButtonSize, + ButtonWarning, } from './index'; describe('design/Button', () => { diff --git a/web/packages/design/src/Button/Button.tsx b/web/packages/design/src/Button/Button.tsx index 7aba6caa5e2aa..45d3d11b6cd3a 100644 --- a/web/packages/design/src/Button/Button.tsx +++ b/web/packages/design/src/Button/Button.tsx @@ -19,21 +19,20 @@ import React from 'react'; import styled, { CSSObject } from 'styled-components'; -import { shouldForwardProp as defaultValidatorFn } from 'design/ThemeProvider'; - import { - space, - width, - height, alignSelf, + AlignSelfProps, gap, + GapProps, + height, + HeightProps, + space, SpaceProps, + width, WidthProps, - HeightProps, - AlignSelfProps, - GapProps, } from 'design/system'; import { Theme } from 'design/theme/themes/types'; +import { shouldForwardProp as defaultValidatorFn } from 'design/ThemeProvider'; export type ButtonProps = React.ComponentPropsWithoutRef & diff --git a/web/packages/design/src/Button/buttons.story.tsx b/web/packages/design/src/Button/buttons.story.tsx index 1ad26d1a361ad..6a88df3397d51 100644 --- a/web/packages/design/src/Button/buttons.story.tsx +++ b/web/packages/design/src/Button/buttons.story.tsx @@ -17,28 +17,25 @@ */ import { Fragment } from 'react'; - import styled from 'styled-components'; import { Input, MenuItem } from 'design'; -import ButtonLink from '../ButtonLink'; -import ButtonIcon from '../ButtonIcon'; -import * as icons from '../Icon'; -import Flex from '../Flex'; - -import { ButtonWithMenu } from '../ButtonWithMenu'; - import { Button, + ButtonBorder, + ButtonFill, ButtonPrimary, + ButtonProps, ButtonSecondary, - ButtonWarning, - ButtonBorder, ButtonText, - ButtonProps, - ButtonFill, + ButtonWarning, } from '.'; +import ButtonIcon from '../ButtonIcon'; +import ButtonLink from '../ButtonLink'; +import { ButtonWithMenu } from '../ButtonWithMenu'; +import Flex from '../Flex'; +import * as icons from '../Icon'; export default { title: 'Design/Button', diff --git a/web/packages/design/src/ButtonIcon/ButtonIcon.jsx b/web/packages/design/src/ButtonIcon/ButtonIcon.jsx index 7a73900fe8e6d..1659b991719e0 100644 --- a/web/packages/design/src/ButtonIcon/ButtonIcon.jsx +++ b/web/packages/design/src/ButtonIcon/ButtonIcon.jsx @@ -18,7 +18,7 @@ import styled from 'styled-components'; -import { space, color, alignSelf } from 'design/system'; +import { alignSelf, color, space } from 'design/system'; const sizeMap = { 0: { diff --git a/web/packages/design/src/ButtonIcon/index.js b/web/packages/design/src/ButtonIcon/index.js index 45a5cceadbd6b..d15f77cbf5be3 100644 --- a/web/packages/design/src/ButtonIcon/index.js +++ b/web/packages/design/src/ButtonIcon/index.js @@ -17,4 +17,5 @@ */ import ButtonIcon from './ButtonIcon'; + export default ButtonIcon; diff --git a/web/packages/design/src/ButtonLink/index.ts b/web/packages/design/src/ButtonLink/index.ts index f439d750b20d5..df0ab3c0ab209 100644 --- a/web/packages/design/src/ButtonLink/index.ts +++ b/web/packages/design/src/ButtonLink/index.ts @@ -17,4 +17,5 @@ */ import ButtonLink from './ButtonLink'; + export default ButtonLink; diff --git a/web/packages/design/src/ButtonWithMenu/ButtonWithMenu.test.tsx b/web/packages/design/src/ButtonWithMenu/ButtonWithMenu.test.tsx index 899a69ca1f9f9..76f50094345a3 100644 --- a/web/packages/design/src/ButtonWithMenu/ButtonWithMenu.test.tsx +++ b/web/packages/design/src/ButtonWithMenu/ButtonWithMenu.test.tsx @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -import { render, screen, userEvent } from 'design/utils/testing'; import { MenuItem } from 'design'; +import { render, screen, userEvent } from 'design/utils/testing'; import { ButtonWithMenu } from './ButtonWithMenu'; diff --git a/web/packages/design/src/ButtonWithMenu/ButtonWithMenu.tsx b/web/packages/design/src/ButtonWithMenu/ButtonWithMenu.tsx index c23de5a1961bc..6d53ae18947f7 100644 --- a/web/packages/design/src/ButtonWithMenu/ButtonWithMenu.tsx +++ b/web/packages/design/src/ButtonWithMenu/ButtonWithMenu.tsx @@ -26,9 +26,9 @@ import { } from 'react'; import { ButtonBorder, Flex, Menu, MenuItem } from 'design'; +import { ButtonSize } from 'design/Button'; import * as icons from 'design/Icon'; import { IconProps } from 'design/Icon/Icon'; -import { ButtonSize } from 'design/Button'; /** * Displays a button with a menu to the right of it. Unlike with a regular