From 6d60196e98bb379f26295fdf689ef353f16727e8 Mon Sep 17 00:00:00 2001 From: Erick Almeida Date: Tue, 26 Nov 2024 02:47:34 -0300 Subject: [PATCH] chore: configure prettier to organize imports --- .prettierrc | 14 +- eslint.config.js | 4 +- package-lock.json | 293 +++++++++++++----- package.json | 1 + src/deaccessibilizer.ts | 7 +- .../find-mutation-target-nodes-builders.ts | 1 + .../builders/get-code-mutation-builders.ts | 1 + src/mutating/code-mutation.ts | 1 + src/mutating/mutation-operator.ts | 1 + .../accessibility-element-modifier-remover.ts | 4 +- .../accessibility-hidden-modifier-remover.ts | 4 +- .../accessibility-hint-modifier-remover.ts | 4 +- .../accessibility-label-modifier-remover.ts | 4 +- .../accessibility-modifier-remover.ts | 4 +- .../accessibility-value-modifier-remover.ts | 4 +- .../image-decorative-label-remover.ts | 4 +- .../standard-font-to-static-size-replacer.ts | 9 +- src/parsing/swift-file-tree.ts | 8 +- src/utils.ts | 1 + tests/deaccessibilizer.spec.ts | 5 +- ...ssibility-element-modifier-remover.spec.ts | 5 +- ...essibility-hidden-modifier-remover.spec.ts | 5 +- ...ccessibility-hint-modifier-remover.spec.ts | 5 +- ...cessibility-label-modifier-remover.spec.ts | 5 +- .../accessibility-modifier-remover.spec.ts | 5 +- ...cessibility-value-modifier-remover.spec.ts | 5 +- .../image-decorative-label-remover.spec.ts | 3 +- ...ndard-font-to-static-size-replacer.spec.ts | 3 +- tests/swift-file-tree.spec.ts | 3 +- ...t-is-same-file-after-applying-operators.ts | 1 + 30 files changed, 286 insertions(+), 128 deletions(-) diff --git a/.prettierrc b/.prettierrc index 937375d..cab989c 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,4 +1,16 @@ { "semi": true, - "singleQuote": true + "singleQuote": true, + "importOrder": [ + "tree-sitter", + "web-tree-sitter", + "tree-sitter-swift", + "vitest", + "^@oclif/(.*)$", + "", + "^[./]" + ], + "importOrderSeparation": true, + "importOrderSortSpecifiers": true, + "plugins": ["@trivago/prettier-plugin-sort-imports"] } diff --git a/eslint.config.js b/eslint.config.js index 97d6a8c..b6fbd31 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,7 +1,7 @@ -import globals from 'globals'; import pluginJs from '@eslint/js'; -import tseslint from 'typescript-eslint'; import eslintConfigPrettier from 'eslint-config-prettier'; +import globals from 'globals'; +import tseslint from 'typescript-eslint'; export default [ { files: ['**/*.{js,mjs,cjs,ts}'] }, diff --git a/package-lock.json b/package-lock.json index cce0f96..bcfca05 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,6 +21,7 @@ "@commitlint/cli": "^19.6.0", "@commitlint/config-conventional": "^19.6.0", "@eslint/js": "^9.15.0", + "@trivago/prettier-plugin-sort-imports": "^4.3.0", "@types/node": "^22.9.4", "@vitest/coverage-v8": "^2.1.5", "eslint": "^9.15.0", @@ -51,118 +52,116 @@ } }, "node_modules/@babel/code-frame": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.24.7.tgz", - "integrity": "sha512-BcYH1CVJBO9tvyIZ2jVeXgSIMvGZ2FDRvDdOIVQyuklNKSsx+eppDEBq/g47Ayw+RqNFE+URvOShmf+f/qwAlA==", + "version": "7.26.2", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.26.2.tgz", + "integrity": "sha512-RJlIHRueQgwWitWgF8OdFYGZX328Ax5BCemNGlqHfplnRT9ESi8JkFlvaVYbS+UubVY6dpv87Fs2u5M29iNFVQ==", "dev": true, "license": "MIT", "dependencies": { - "@babel/highlight": "^7.24.7", + "@babel/helper-validator-identifier": "^7.25.9", + "js-tokens": "^4.0.0", "picocolors": "^1.0.0" }, "engines": { "node": ">=6.9.0" } }, - "node_modules/@babel/helper-string-parser": { - "version": "7.24.8", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.24.8.tgz", - "integrity": "sha512-pO9KhhRcuUyGnJWwyEgnRJTSIZHiT+vMD0kPeD+so0l7mxkMT19g3pjY9GTnHySck/hDzq+dtW/4VgnMkippsQ==", + "node_modules/@babel/generator": { + "version": "7.17.7", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.17.7.tgz", + "integrity": "sha512-oLcVCTeIFadUoArDTwpluncplrYBmTCCZZgXCbgNGvOBBiSDDK3eWO4b/+eOTli5tKv1lg+a5/NAXg+nTcei1w==", "dev": true, "license": "MIT", + "dependencies": { + "@babel/types": "^7.17.0", + "jsesc": "^2.5.1", + "source-map": "^0.5.0" + }, "engines": { "node": ">=6.9.0" } }, - "node_modules/@babel/helper-validator-identifier": { + "node_modules/@babel/helper-environment-visitor": { "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.24.7.tgz", - "integrity": "sha512-rR+PBcQ1SMQDDyF6X0wxtG8QyLCgUB0eRAGguqRLfkCA87l7yAP7ehq8SNj96OOGTO8OBV70KhuFYcIkHXOg0w==", + "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.24.7.tgz", + "integrity": "sha512-DoiN84+4Gnd0ncbBOM9AZENV4a5ZiL39HYMyZJGZ/AZEykHYdJw0wW3kdcsh9/Kn+BRXHLkkklZ51ecPKmI1CQ==", "dev": true, "license": "MIT", + "dependencies": { + "@babel/types": "^7.24.7" + }, "engines": { "node": ">=6.9.0" } }, - "node_modules/@babel/highlight": { + "node_modules/@babel/helper-function-name": { "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.24.7.tgz", - "integrity": "sha512-EStJpq4OuY8xYfhGVXngigBJRWxftKX9ksiGDnmlY3o7B/V7KIAc9X4oiK87uPJSc/vs5L869bem5fhZa8caZw==", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.24.7.tgz", + "integrity": "sha512-FyoJTsj/PEUWu1/TYRiXTIHc8lbw+TDYkZuoE43opPS5TrI7MyONBE1oNvfguEXAD9yhQRrVBnXdXzSLQl9XnA==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-validator-identifier": "^7.24.7", - "chalk": "^2.4.2", - "js-tokens": "^4.0.0", - "picocolors": "^1.0.0" + "@babel/template": "^7.24.7", + "@babel/types": "^7.24.7" }, "engines": { "node": ">=6.9.0" } }, - "node_modules/@babel/highlight/node_modules/ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "node_modules/@babel/helper-hoist-variables": { + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.24.7.tgz", + "integrity": "sha512-MJJwhkoGy5c4ehfoRyrJ/owKeMl19U54h27YYftT0o2teQ3FJ3nQUf/I3LlJsX4l3qlw7WRXUmiyajvHXoTubQ==", "dev": true, "license": "MIT", "dependencies": { - "color-convert": "^1.9.0" + "@babel/types": "^7.24.7" }, "engines": { - "node": ">=4" + "node": ">=6.9.0" } }, - "node_modules/@babel/highlight/node_modules/chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "node_modules/@babel/helper-split-export-declaration": { + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.24.7.tgz", + "integrity": "sha512-oy5V7pD+UvfkEATUKvIjvIAH/xCzfsFVw7ygW2SI6NClZzquT+mwdTfgfdbUiceh6iQO0CHtCPsyze/MZ2YbAA==", "dev": true, "license": "MIT", "dependencies": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" + "@babel/types": "^7.24.7" }, "engines": { - "node": ">=4" + "node": ">=6.9.0" } }, - "node_modules/@babel/highlight/node_modules/color-convert": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "node_modules/@babel/helper-string-parser": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.25.9.tgz", + "integrity": "sha512-4A/SCr/2KLd5jrtOMFzaKjVtAei3+2r/NChoBNoZ3EyP/+GlhoaEGoWOZUmFmoITP7zOJyHIMm+DYRd8o3PvHA==", "dev": true, "license": "MIT", - "dependencies": { - "color-name": "1.1.3" + "engines": { + "node": ">=6.9.0" } }, - "node_modules/@babel/highlight/node_modules/color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", - "dev": true, - "license": "MIT" - }, - "node_modules/@babel/highlight/node_modules/escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", + "node_modules/@babel/helper-validator-identifier": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.25.9.tgz", + "integrity": "sha512-Ed61U6XJc3CVRfkERJWDz4dJwKe7iLmmJsbOGu9wSloNSFttHV0I8g6UAgb7qnK5ly5bGLPd4oXZlxCdANBOWQ==", "dev": true, "license": "MIT", "engines": { - "node": ">=0.8.0" + "node": ">=6.9.0" } }, "node_modules/@babel/parser": { - "version": "7.25.6", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.25.6.tgz", - "integrity": "sha512-trGdfBdbD0l1ZPmcJ83eNxB9rbEax4ALFTF7fN386TMYbeCQbyme5cOEXQhbGXKebwGaB/J52w1mrklMcbgy6Q==", + "version": "7.26.2", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.26.2.tgz", + "integrity": "sha512-DWMCZH9WA4Maitz2q21SRKHo9QXZxkDsbNZoVD62gusNtNBBqDg9i7uOhASfTfIGNzW+O+r7+jAlM8dwphcJKQ==", "dev": true, "license": "MIT", "dependencies": { - "@babel/types": "^7.25.6" + "@babel/types": "^7.26.0" }, "bin": { "parser": "bin/babel-parser.js" @@ -171,16 +170,92 @@ "node": ">=6.0.0" } }, + "node_modules/@babel/template": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.25.9.tgz", + "integrity": "sha512-9DGttpmPvIxBb/2uwpVo3dqJ+O6RooAFOS+lB+xDqoE2PVCE8nfoHMdZLpfCQRLwvohzXISPZcgxt80xLfsuwg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.25.9", + "@babel/parser": "^7.25.9", + "@babel/types": "^7.25.9" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/traverse": { + "version": "7.23.2", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.2.tgz", + "integrity": "sha512-azpe59SQ48qG6nu2CzcMLbxUudtN+dOM9kDbUqGq3HXUJRlo7i8fvPoxQUzYgLZ4cMVmuZgm8vvBpNeRhd6XSw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.22.13", + "@babel/generator": "^7.23.0", + "@babel/helper-environment-visitor": "^7.22.20", + "@babel/helper-function-name": "^7.23.0", + "@babel/helper-hoist-variables": "^7.22.5", + "@babel/helper-split-export-declaration": "^7.22.6", + "@babel/parser": "^7.23.0", + "@babel/types": "^7.23.0", + "debug": "^4.1.0", + "globals": "^11.1.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/traverse/node_modules/@babel/generator": { + "version": "7.26.2", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.26.2.tgz", + "integrity": "sha512-zevQbhbau95nkoxSq3f/DC/SC+EEOUZd3DYqfSkMhY2/wfSeaHV1Ew4vk8e+x8lja31IbyuUa2uQ3JONqKbysw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.26.2", + "@babel/types": "^7.26.0", + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.25", + "jsesc": "^3.0.2" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/traverse/node_modules/globals": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/traverse/node_modules/jsesc": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.0.2.tgz", + "integrity": "sha512-xKqzzWXDttJuOcawBt4KnKHHIf5oQ/Cxax+0PWFG+DFDgHNAdi+TXECADI+RYiFUMmx8792xsMbbgXj4CwnP4g==", + "dev": true, + "license": "MIT", + "bin": { + "jsesc": "bin/jsesc" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/@babel/types": { - "version": "7.25.6", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.25.6.tgz", - "integrity": "sha512-/l42B1qxpG6RdfYf343Uw1vmDjeNhneUXtzhojE7pDgfpEypmRhI6j1kr17XCVv4Cgl9HdAiQY2x0GwKm7rWCw==", + "version": "7.26.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.26.0.tgz", + "integrity": "sha512-Z/yiTPj+lDVnF7lWeKCIJzaIkI0vYO87dMpZ4bg4TDrFe4XXLFWL1TbXU27gBP3QccxV9mZICCrnjnYlJjXHOA==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-string-parser": "^7.24.8", - "@babel/helper-validator-identifier": "^7.24.7", - "to-fast-properties": "^2.0.0" + "@babel/helper-string-parser": "^7.25.9", + "@babel/helper-validator-identifier": "^7.25.9" }, "engines": { "node": ">=6.9.0" @@ -1628,6 +1703,44 @@ "dev": true, "license": "MIT" }, + "node_modules/@trivago/prettier-plugin-sort-imports": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@trivago/prettier-plugin-sort-imports/-/prettier-plugin-sort-imports-4.3.0.tgz", + "integrity": "sha512-r3n0onD3BTOVUNPhR4lhVK4/pABGpbA7bW3eumZnYdKaHkf1qEC+Mag6DPbGNuuh0eG8AaYj+YqmVHSiGslaTQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@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", + "lodash": "^4.17.21" + }, + "peerDependencies": { + "@vue/compiler-sfc": "3.x", + "prettier": "2.x - 3.x" + }, + "peerDependenciesMeta": { + "@vue/compiler-sfc": { + "optional": true + } + } + }, + "node_modules/@trivago/prettier-plugin-sort-imports/node_modules/@babel/types": { + "version": "7.17.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", + "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-validator-identifier": "^7.16.7", + "to-fast-properties": "^2.0.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, "node_modules/@types/conventional-commits-parser": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/@types/conventional-commits-parser/-/conventional-commits-parser-5.0.0.tgz", @@ -3505,16 +3618,6 @@ "dev": true, "license": "MIT" }, - "node_modules/has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=4" - } - }, "node_modules/html-escaper": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", @@ -3887,6 +3990,13 @@ "node": ">=8" } }, + "node_modules/javascript-natural-sort": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/javascript-natural-sort/-/javascript-natural-sort-0.7.1.tgz", + "integrity": "sha512-nO6jcEfZWQXDhOiBtG2KvKyEptz7RVbpGP4vTD2hLBdmNQSsCiicO2Ioinv6UI4y9ukqnBpy+XZ9H6uLNgJTlw==", + "dev": true, + "license": "MIT" + }, "node_modules/jiti": { "version": "1.21.6", "resolved": "https://registry.npmjs.org/jiti/-/jiti-1.21.6.tgz", @@ -3917,6 +4027,19 @@ "js-yaml": "bin/js-yaml.js" } }, + "node_modules/jsesc": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", + "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", + "dev": true, + "license": "MIT", + "bin": { + "jsesc": "bin/jsesc" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/json-buffer": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", @@ -4172,6 +4295,13 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "dev": true, + "license": "MIT" + }, "node_modules/lodash.camelcase": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz", @@ -5326,6 +5456,16 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha512-LbrmJOMUSdEVxIKvdcJzQC+nQhe8FUZQTXQy6+I75skNgn3OoQ0DZA8YnFa7gp8tqtL3KPf1kmo0R5DoApeSGQ==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/source-map-js": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", @@ -5452,19 +5592,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, - "license": "MIT", - "dependencies": { - "has-flag": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/test-exclude": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-7.0.1.tgz", diff --git a/package.json b/package.json index 9f3301a..74b16b7 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "@commitlint/cli": "^19.6.0", "@commitlint/config-conventional": "^19.6.0", "@eslint/js": "^9.15.0", + "@trivago/prettier-plugin-sort-imports": "^4.3.0", "@types/node": "^22.9.4", "@vitest/coverage-v8": "^2.1.5", "eslint": "^9.15.0", diff --git a/src/deaccessibilizer.ts b/src/deaccessibilizer.ts index 1ba5b68..a222fe4 100644 --- a/src/deaccessibilizer.ts +++ b/src/deaccessibilizer.ts @@ -1,14 +1,15 @@ import Parser, { QueryMatch } from 'web-tree-sitter'; -import { SwiftFileTree } from './parsing/swift-file-tree.js'; + import { getParser } from './configuring/get-parser.js'; +import { CodeMutation } from './mutating/code-mutation.js'; import { MutationGenerationOptions, MutationOperator, } from './mutating/mutation-operator.js'; import { OperatorsDictionary } from './mutating/operators-dictionary.js'; -import { CodeMutation } from './mutating/code-mutation.js'; -import { byNodePosition } from './utils.js'; +import { SwiftFileTree } from './parsing/swift-file-tree.js'; import { SerializableCodeMutation } from './serializing/serializables.js'; +import { byNodePosition } from './utils.js'; const allOperators = Object.values(OperatorsDictionary); diff --git a/src/mutating/builders/find-mutation-target-nodes-builders.ts b/src/mutating/builders/find-mutation-target-nodes-builders.ts index d73e7d8..c41bff1 100644 --- a/src/mutating/builders/find-mutation-target-nodes-builders.ts +++ b/src/mutating/builders/find-mutation-target-nodes-builders.ts @@ -1,4 +1,5 @@ import { QueryMatch, SyntaxNode } from 'web-tree-sitter'; + import { getModifierArgumentsNodeFromModifierNameNode } from '../../utils.js'; /** diff --git a/src/mutating/builders/get-code-mutation-builders.ts b/src/mutating/builders/get-code-mutation-builders.ts index 9b7dbeb..7110fa0 100644 --- a/src/mutating/builders/get-code-mutation-builders.ts +++ b/src/mutating/builders/get-code-mutation-builders.ts @@ -1,4 +1,5 @@ import { QueryMatch, SyntaxNode } from 'web-tree-sitter'; + import { CodeMutation, NodeChange } from '../code-mutation.js'; import { MutationGenerationOptions } from '../mutation-operator.js'; diff --git a/src/mutating/code-mutation.ts b/src/mutating/code-mutation.ts index cc7a64e..a0cfb64 100644 --- a/src/mutating/code-mutation.ts +++ b/src/mutating/code-mutation.ts @@ -1,4 +1,5 @@ import { SyntaxNode } from 'web-tree-sitter'; + import { ReplaceNodeOptions } from '../parsing/swift-file-tree.js'; /** diff --git a/src/mutating/mutation-operator.ts b/src/mutating/mutation-operator.ts index 01ec97c..0c7a592 100644 --- a/src/mutating/mutation-operator.ts +++ b/src/mutating/mutation-operator.ts @@ -1,4 +1,5 @@ import { QueryMatch, SyntaxNode } from 'web-tree-sitter'; + import { CodeMutation } from './code-mutation.js'; /** diff --git a/src/mutating/operators/accessibility-element-modifier-remover.ts b/src/mutating/operators/accessibility-element-modifier-remover.ts index 7b0c626..43810e0 100644 --- a/src/mutating/operators/accessibility-element-modifier-remover.ts +++ b/src/mutating/operators/accessibility-element-modifier-remover.ts @@ -1,7 +1,7 @@ -import { MutationOperator } from '../mutation-operator.js'; -import { buildModifierOnAnyViewQuery } from '../builders/query-builders.js'; import { buildModifierOnAnyViewFMTN } from '../builders/find-mutation-target-nodes-builders.js'; import { buildRemoveModifierGCM } from '../builders/get-code-mutation-builders.js'; +import { buildModifierOnAnyViewQuery } from '../builders/query-builders.js'; +import { MutationOperator } from '../mutation-operator.js'; /** * This operator matches a SwiftUI view with an `.accessibilityElement(...)` modifier, diff --git a/src/mutating/operators/accessibility-hidden-modifier-remover.ts b/src/mutating/operators/accessibility-hidden-modifier-remover.ts index 0bc15ec..63b4275 100644 --- a/src/mutating/operators/accessibility-hidden-modifier-remover.ts +++ b/src/mutating/operators/accessibility-hidden-modifier-remover.ts @@ -1,7 +1,7 @@ -import { MutationOperator } from '../mutation-operator.js'; -import { buildModifierOnAnyViewQuery } from '../builders/query-builders.js'; import { buildModifierOnAnyViewFMTN } from '../builders/find-mutation-target-nodes-builders.js'; import { buildRemoveModifierGCM } from '../builders/get-code-mutation-builders.js'; +import { buildModifierOnAnyViewQuery } from '../builders/query-builders.js'; +import { MutationOperator } from '../mutation-operator.js'; /** * This operator matches a SwiftUI view with an `.accessibilityHidden` modifier, which is diff --git a/src/mutating/operators/accessibility-hint-modifier-remover.ts b/src/mutating/operators/accessibility-hint-modifier-remover.ts index d797dd2..dbc2331 100644 --- a/src/mutating/operators/accessibility-hint-modifier-remover.ts +++ b/src/mutating/operators/accessibility-hint-modifier-remover.ts @@ -1,7 +1,7 @@ -import { MutationOperator } from '../mutation-operator.js'; -import { buildModifierOnAnyViewQuery } from '../builders/query-builders.js'; import { buildModifierOnAnyViewFMTN } from '../builders/find-mutation-target-nodes-builders.js'; import { buildRemoveModifierGCM } from '../builders/get-code-mutation-builders.js'; +import { buildModifierOnAnyViewQuery } from '../builders/query-builders.js'; +import { MutationOperator } from '../mutation-operator.js'; /** * This operator matches a SwiftUI view with an `.accessibilityHint` modifier, which diff --git a/src/mutating/operators/accessibility-label-modifier-remover.ts b/src/mutating/operators/accessibility-label-modifier-remover.ts index d9b4b80..d07eb2a 100644 --- a/src/mutating/operators/accessibility-label-modifier-remover.ts +++ b/src/mutating/operators/accessibility-label-modifier-remover.ts @@ -1,7 +1,7 @@ -import { MutationOperator } from '../mutation-operator.js'; -import { buildModifierOnAnyViewQuery } from '../builders/query-builders.js'; import { buildModifierOnAnyViewFMTN } from '../builders/find-mutation-target-nodes-builders.js'; import { buildRemoveModifierGCM } from '../builders/get-code-mutation-builders.js'; +import { buildModifierOnAnyViewQuery } from '../builders/query-builders.js'; +import { MutationOperator } from '../mutation-operator.js'; /** * This operator matches a SwiftUI view with an `.accessibilityLabel` modifier, which is diff --git a/src/mutating/operators/accessibility-modifier-remover.ts b/src/mutating/operators/accessibility-modifier-remover.ts index 2ce52de..42c971d 100644 --- a/src/mutating/operators/accessibility-modifier-remover.ts +++ b/src/mutating/operators/accessibility-modifier-remover.ts @@ -1,7 +1,7 @@ -import { MutationOperator } from '../mutation-operator.js'; -import { buildModifierOnAnyViewQuery } from '../builders/query-builders.js'; import { buildModifierOnAnyViewFMTN } from '../builders/find-mutation-target-nodes-builders.js'; import { buildRemoveModifierGCM } from '../builders/get-code-mutation-builders.js'; +import { buildModifierOnAnyViewQuery } from '../builders/query-builders.js'; +import { MutationOperator } from '../mutation-operator.js'; /** * This operator matches a SwiftUI view with an `.accessibility` modifier, which diff --git a/src/mutating/operators/accessibility-value-modifier-remover.ts b/src/mutating/operators/accessibility-value-modifier-remover.ts index 1034cea..edde1a7 100644 --- a/src/mutating/operators/accessibility-value-modifier-remover.ts +++ b/src/mutating/operators/accessibility-value-modifier-remover.ts @@ -1,7 +1,7 @@ -import { MutationOperator } from '../mutation-operator.js'; -import { buildModifierOnAnyViewQuery } from '../builders/query-builders.js'; import { buildModifierOnAnyViewFMTN } from '../builders/find-mutation-target-nodes-builders.js'; import { buildRemoveModifierGCM } from '../builders/get-code-mutation-builders.js'; +import { buildModifierOnAnyViewQuery } from '../builders/query-builders.js'; +import { MutationOperator } from '../mutation-operator.js'; /** * This operator matches a SwiftUI view with an `.accessibilityValue` modifier, which diff --git a/src/mutating/operators/image-decorative-label-remover.ts b/src/mutating/operators/image-decorative-label-remover.ts index 03a86f2..b9092dd 100644 --- a/src/mutating/operators/image-decorative-label-remover.ts +++ b/src/mutating/operators/image-decorative-label-remover.ts @@ -1,7 +1,7 @@ -import { MutationOperator } from '../mutation-operator.js'; -import { buildViewWithArgumentLabelQuery } from '../builders/query-builders.js'; import { buildFromCaptureNameFMTN } from '../builders/find-mutation-target-nodes-builders.js'; import { buildRemoveArgumentLabelGCM } from '../builders/get-code-mutation-builders.js'; +import { buildViewWithArgumentLabelQuery } from '../builders/query-builders.js'; +import { MutationOperator } from '../mutation-operator.js'; /** * This operator matches a SwiftUI Image element with a `decorative:` argument label, which diff --git a/src/mutating/operators/standard-font-to-static-size-replacer.ts b/src/mutating/operators/standard-font-to-static-size-replacer.ts index 5e84917..33e96ae 100644 --- a/src/mutating/operators/standard-font-to-static-size-replacer.ts +++ b/src/mutating/operators/standard-font-to-static-size-replacer.ts @@ -1,12 +1,13 @@ import { SyntaxNode } from 'web-tree-sitter'; -import { MutationOperator } from '../mutation-operator.js'; -import { buildModifierOnAnyViewQuery } from '../builders/query-builders.js'; -import { buildCallbackResultFromCaptureNameFMTN } from '../builders/find-mutation-target-nodes-builders.js'; -import { buildReplaceNodeContentWithCallbackResultGCM } from '../builders/get-code-mutation-builders.js'; + import { getModifierArgumentsNodeFromModifierNameNode, stripParentheses, } from '../../utils.js'; +import { buildCallbackResultFromCaptureNameFMTN } from '../builders/find-mutation-target-nodes-builders.js'; +import { buildReplaceNodeContentWithCallbackResultGCM } from '../builders/get-code-mutation-builders.js'; +import { buildModifierOnAnyViewQuery } from '../builders/query-builders.js'; +import { MutationOperator } from '../mutation-operator.js'; /** * This operator matches a SwiftUI view that uses a standard font modifier, like `.font(.body)`. diff --git a/src/parsing/swift-file-tree.ts b/src/parsing/swift-file-tree.ts index 72ff016..0822932 100644 --- a/src/parsing/swift-file-tree.ts +++ b/src/parsing/swift-file-tree.ts @@ -1,13 +1,13 @@ +import { Query as NTSQuery, SyntaxNode as NTSSyntaxNode } from 'tree-sitter'; import Parser, { Language, - SyntaxNode, - Tree, - QueryCapture, Point, + QueryCapture, QueryMatch, + SyntaxNode, + Tree, } from 'web-tree-sitter'; -import { Query as NTSQuery, SyntaxNode as NTSSyntaxNode } from 'tree-sitter'; import { SerializableCodeChange } from '../serializing/serializables.js'; /** diff --git a/src/utils.ts b/src/utils.ts index caa9885..04873c0 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,4 +1,5 @@ import { SyntaxNode } from 'web-tree-sitter'; + import { NodeChange } from './mutating/code-mutation.js'; /** diff --git a/tests/deaccessibilizer.spec.ts b/tests/deaccessibilizer.spec.ts index 5dd91e1..ad2bbd6 100644 --- a/tests/deaccessibilizer.spec.ts +++ b/tests/deaccessibilizer.spec.ts @@ -1,14 +1,15 @@ import { describe, expect, it } from 'vitest'; + import { Deaccessibilizer } from '../src/deaccessibilizer.js'; -import { getExpectIsSameFileAfterApplyingOperators } from './utils/expect-is-same-file-after-applying-operators.js'; import { AccessibilityHiddenModifierRemover, AccessibilityModifierRemover, ImageDecorativeLabelRemover, } from '../src/index.js'; +import { getExpectIsSameFileAfterApplyingOperators } from './utils/expect-is-same-file-after-applying-operators.js'; import { - readFileContent, SWIFT_FILE_SAMPLES_BASE_PATH, + readFileContent, } from './utils/read-file-content.js'; const deaccessibilizer = new Deaccessibilizer(); diff --git a/tests/operators/accessibility-element-modifier-remover.spec.ts b/tests/operators/accessibility-element-modifier-remover.spec.ts index 2ac4e8c..da835df 100644 --- a/tests/operators/accessibility-element-modifier-remover.spec.ts +++ b/tests/operators/accessibility-element-modifier-remover.spec.ts @@ -1,10 +1,11 @@ import { describe, it } from 'vitest'; + import { - Deaccessibilizer, AccessibilityElementModifierRemover, + Deaccessibilizer, } from '../../src/index.js'; -import { SWIFT_FILE_SAMPLES_BASE_PATH } from '../utils/read-file-content.js'; import { getExpectIsSameFileAfterApplyingOperators } from '../utils/expect-is-same-file-after-applying-operators.js'; +import { SWIFT_FILE_SAMPLES_BASE_PATH } from '../utils/read-file-content.js'; const deaccessibilizer = new Deaccessibilizer(); const expectIsSameFileAfterApplyingOperators = diff --git a/tests/operators/accessibility-hidden-modifier-remover.spec.ts b/tests/operators/accessibility-hidden-modifier-remover.spec.ts index 94c08d4..089eb3f 100644 --- a/tests/operators/accessibility-hidden-modifier-remover.spec.ts +++ b/tests/operators/accessibility-hidden-modifier-remover.spec.ts @@ -1,10 +1,11 @@ import { describe, it } from 'vitest'; + import { - Deaccessibilizer, AccessibilityHiddenModifierRemover, + Deaccessibilizer, } from '../../src/index.js'; -import { SWIFT_FILE_SAMPLES_BASE_PATH } from '../utils/read-file-content.js'; import { getExpectIsSameFileAfterApplyingOperators } from '../utils/expect-is-same-file-after-applying-operators.js'; +import { SWIFT_FILE_SAMPLES_BASE_PATH } from '../utils/read-file-content.js'; const deaccessibilizer = new Deaccessibilizer(); const expectIsSameFileAfterApplyingOperators = diff --git a/tests/operators/accessibility-hint-modifier-remover.spec.ts b/tests/operators/accessibility-hint-modifier-remover.spec.ts index a3102aa..8879940 100644 --- a/tests/operators/accessibility-hint-modifier-remover.spec.ts +++ b/tests/operators/accessibility-hint-modifier-remover.spec.ts @@ -1,10 +1,11 @@ import { describe, it } from 'vitest'; + import { - Deaccessibilizer, AccessibilityHintModifierRemover, + Deaccessibilizer, } from '../../src/index.js'; -import { SWIFT_FILE_SAMPLES_BASE_PATH } from '../utils/read-file-content.js'; import { getExpectIsSameFileAfterApplyingOperators } from '../utils/expect-is-same-file-after-applying-operators.js'; +import { SWIFT_FILE_SAMPLES_BASE_PATH } from '../utils/read-file-content.js'; const deaccessibilizer = new Deaccessibilizer(); const expectIsSameFileAfterApplyingOperators = diff --git a/tests/operators/accessibility-label-modifier-remover.spec.ts b/tests/operators/accessibility-label-modifier-remover.spec.ts index fa56099..9ec62ab 100644 --- a/tests/operators/accessibility-label-modifier-remover.spec.ts +++ b/tests/operators/accessibility-label-modifier-remover.spec.ts @@ -1,10 +1,11 @@ import { describe, it } from 'vitest'; + import { - Deaccessibilizer, AccessibilityLabelModifierRemover, + Deaccessibilizer, } from '../../src/index.js'; -import { SWIFT_FILE_SAMPLES_BASE_PATH } from '../utils/read-file-content.js'; import { getExpectIsSameFileAfterApplyingOperators } from '../utils/expect-is-same-file-after-applying-operators.js'; +import { SWIFT_FILE_SAMPLES_BASE_PATH } from '../utils/read-file-content.js'; const deaccessibilizer = new Deaccessibilizer(); const expectIsSameFileAfterApplyingOperators = diff --git a/tests/operators/accessibility-modifier-remover.spec.ts b/tests/operators/accessibility-modifier-remover.spec.ts index eec9448..7e53f2d 100644 --- a/tests/operators/accessibility-modifier-remover.spec.ts +++ b/tests/operators/accessibility-modifier-remover.spec.ts @@ -1,10 +1,11 @@ import { describe, it } from 'vitest'; + import { - Deaccessibilizer, AccessibilityModifierRemover, + Deaccessibilizer, } from '../../src/index.js'; -import { SWIFT_FILE_SAMPLES_BASE_PATH } from '../utils/read-file-content.js'; import { getExpectIsSameFileAfterApplyingOperators } from '../utils/expect-is-same-file-after-applying-operators.js'; +import { SWIFT_FILE_SAMPLES_BASE_PATH } from '../utils/read-file-content.js'; const deaccessibilizer = new Deaccessibilizer(); const expectIsSameFileAfterApplyingOperators = diff --git a/tests/operators/accessibility-value-modifier-remover.spec.ts b/tests/operators/accessibility-value-modifier-remover.spec.ts index 14baabb..3ac1fff 100644 --- a/tests/operators/accessibility-value-modifier-remover.spec.ts +++ b/tests/operators/accessibility-value-modifier-remover.spec.ts @@ -1,10 +1,11 @@ import { describe, it } from 'vitest'; + import { - Deaccessibilizer, AccessibilityValueModifierRemover, + Deaccessibilizer, } from '../../src/index.js'; -import { SWIFT_FILE_SAMPLES_BASE_PATH } from '../utils/read-file-content.js'; import { getExpectIsSameFileAfterApplyingOperators } from '../utils/expect-is-same-file-after-applying-operators.js'; +import { SWIFT_FILE_SAMPLES_BASE_PATH } from '../utils/read-file-content.js'; const deaccessibilizer = new Deaccessibilizer(); const expectIsSameFileAfterApplyingOperators = diff --git a/tests/operators/image-decorative-label-remover.spec.ts b/tests/operators/image-decorative-label-remover.spec.ts index a7ef55d..bc632b9 100644 --- a/tests/operators/image-decorative-label-remover.spec.ts +++ b/tests/operators/image-decorative-label-remover.spec.ts @@ -1,10 +1,11 @@ import { describe, it } from 'vitest'; + import { Deaccessibilizer, ImageDecorativeLabelRemover, } from '../../src/index.js'; -import { SWIFT_FILE_SAMPLES_BASE_PATH } from '../utils/read-file-content.js'; import { getExpectIsSameFileAfterApplyingOperators } from '../utils/expect-is-same-file-after-applying-operators.js'; +import { SWIFT_FILE_SAMPLES_BASE_PATH } from '../utils/read-file-content.js'; const deaccessibilizer = new Deaccessibilizer(); const expectIsSameFileAfterApplyingOperators = diff --git a/tests/operators/standard-font-to-static-size-replacer.spec.ts b/tests/operators/standard-font-to-static-size-replacer.spec.ts index 950cda1..bce3b63 100644 --- a/tests/operators/standard-font-to-static-size-replacer.spec.ts +++ b/tests/operators/standard-font-to-static-size-replacer.spec.ts @@ -1,10 +1,11 @@ import { describe, it } from 'vitest'; + import { Deaccessibilizer, StandardFontToStaticSizeReplacer, } from '../../src/index.js'; -import { SWIFT_FILE_SAMPLES_BASE_PATH } from '../utils/read-file-content.js'; import { getExpectIsSameFileAfterApplyingOperators } from '../utils/expect-is-same-file-after-applying-operators.js'; +import { SWIFT_FILE_SAMPLES_BASE_PATH } from '../utils/read-file-content.js'; const deaccessibilizer = new Deaccessibilizer(); const expectIsSameFileAfterApplyingOperators = diff --git a/tests/swift-file-tree.spec.ts b/tests/swift-file-tree.spec.ts index 363af8f..49d720c 100644 --- a/tests/swift-file-tree.spec.ts +++ b/tests/swift-file-tree.spec.ts @@ -1,8 +1,9 @@ import { describe, expect, it } from 'vitest'; + import { Deaccessibilizer } from '../src/index.js'; import { - readFileContent, SWIFT_FILE_SAMPLES_BASE_PATH, + readFileContent, } from './utils/read-file-content.js'; const deaccessibilizer = new Deaccessibilizer(); diff --git a/tests/utils/expect-is-same-file-after-applying-operators.ts b/tests/utils/expect-is-same-file-after-applying-operators.ts index caf4996..17c3bd7 100644 --- a/tests/utils/expect-is-same-file-after-applying-operators.ts +++ b/tests/utils/expect-is-same-file-after-applying-operators.ts @@ -1,4 +1,5 @@ import { expect } from 'vitest'; + import { Deaccessibilizer, MutationGenerationOptions,