diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index e55c14fb..00000000 --- a/.eslintignore +++ /dev/null @@ -1,2 +0,0 @@ -/coverage/ -/dist/ diff --git a/.github/ISSUE_TEMPLATE/bug.md b/.github/ISSUE_TEMPLATE/bug.md deleted file mode 100644 index c1f2fbd7..00000000 --- a/.github/ISSUE_TEMPLATE/bug.md +++ /dev/null @@ -1,24 +0,0 @@ ---- -name: 🐛 Bug -about: Issues with prettier crashing ---- - -## Metadata - -- Operating system: Ubuntu -- Ruby version: latest -- Node version: latest -- `@prettier/plugin-ruby` or `prettier` gem version: latest -- Options: - - `rubyArrayLiteral` - `true` - - `rubyHashLabel` - `true` - - `rubyModifier` - `true` - - `rubySingleQuote` - `true` - - `rubyToProc` - `false` - - `trailingComma` - `"none"` - -## Input - -```ruby -# Code snippet -``` diff --git a/.github/ISSUE_TEMPLATE/formatting.md b/.github/ISSUE_TEMPLATE/formatting.md deleted file mode 100644 index e18e8565..00000000 --- a/.github/ISSUE_TEMPLATE/formatting.md +++ /dev/null @@ -1,36 +0,0 @@ ---- -name: ✨ Formatting -about: Issues for ugly or incorrect code ---- - -## Metadata - -- Operating system: Ubuntu -- Ruby version: latest -- Node version: latest -- `@prettier/plugin-ruby` or `prettier` gem version: latest -- Options: - - `rubyArrayLiteral` - `true` - - `rubyHashLabel` - `true` - - `rubyModifier` - `true` - - `rubySingleQuote` - `true` - - `rubyToProc` - `false` - - `trailingComma` - `"none"` - -## Input - -```ruby -# Code snippet -``` - -## Current output - -```ruby -# Code snippet -``` - -## Expected output - -```ruby -# Code snippet -``` diff --git a/.github/dependabot.yml b/.github/dependabot.yml index f7068438..29fe4b24 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -8,3 +8,7 @@ updates: directory: "/" schedule: interval: "daily" + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" diff --git a/.github/workflows/auto-merge.yml b/.github/workflows/auto-merge.yml new file mode 100644 index 00000000..44908aae --- /dev/null +++ b/.github/workflows/auto-merge.yml @@ -0,0 +1,22 @@ +name: Dependabot auto-merge +on: pull_request + +permissions: + contents: write + pull-requests: write + +jobs: + dependabot: + runs-on: ubuntu-latest + if: ${{ github.actor == 'dependabot[bot]' }} + steps: + - name: Dependabot metadata + id: metadata + uses: dependabot/fetch-metadata@v2.0.0 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + - name: Enable auto-merge for Dependabot PRs + run: gh pr merge --auto --merge "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml deleted file mode 100644 index c18c8ca4..00000000 --- a/.github/workflows/automerge.yml +++ /dev/null @@ -1,54 +0,0 @@ -name: Auto Merge pull requests - -# read-write repo token -# access to secrets -on: - workflow_run: - workflows: ["Main"] - types: - - completed - -jobs: - automerge: - runs-on: ubuntu-latest - # Only run if workflow completed successfully in a pull request made by dependabot - if: > - github.event.workflow_run.event == 'pull_request' && - github.event.workflow_run.conclusion == 'success' && - github.event.sender.login == 'dependabot[bot]' - steps: - - name: "Download artifact" - uses: actions/github-script@v3 - with: - # Artifact unzip code based on code in - # https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ - script: | - var artifacts = await github.actions.listWorkflowRunArtifacts({ - owner: context.repo.owner, - repo: context.repo.repo, - run_id: ${{github.event.workflow_run.id }}, - }); - var matchArtifact = artifacts.data.artifacts.filter((artifact) => { - return artifact.name == "save-pr-info" - })[0]; - var download = await github.actions.downloadArtifact({ - owner: context.repo.owner, - repo: context.repo.repo, - artifact_id: matchArtifact.id, - archive_format: 'zip', - }); - var fs = require('fs'); - fs.writeFileSync('${{github.workspace}}/save-pr-info.zip', Buffer.from(download.data)); - - run: unzip save-pr-info.zip - - name: "Merge pull request" - uses: actions/github-script@v3 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - var fs = require('fs'); - var issue_number = Number(fs.readFileSync('./PULL_REQUEST_NUMBER')); - await github.pulls.merge({ - owner: context.payload.repository.owner.login, - repo: context.payload.repository.name, - pull_number: issue_number - }) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 89ecd090..7c247608 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,6 +2,7 @@ name: Main on: - push - pull_request + jobs: ci: name: CI @@ -13,22 +14,19 @@ jobs: - ubuntu-latest - windows-latest ruby: - - "2.5" - - "2.6" - - "2.7" - "3.0" + - "3.1" + - "3.2" runs-on: ${{ matrix.platform }} - env: - PLUGIN_RUBY_CI: true steps: - uses: actions/checkout@main - uses: ruby/setup-ruby@v1 with: bundler-cache: true ruby-version: ${{ matrix.ruby }} - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v4 with: - node-version: 12.x + node-version: 20.x cache: yarn - run: yarn install --frozen-lockfile - run: yarn test @@ -37,68 +35,20 @@ jobs: lint: name: Lint runs-on: ubuntu-latest - env: - PLUGIN_RUBY_CI: true steps: - uses: actions/checkout@main - uses: ruby/setup-ruby@v1 with: bundler-cache: true ruby-version: "3.0" - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v4 with: - node-version: 12.x + node-version: 20.x cache: yarn - run: yarn install --frozen-lockfile - - run: yarn prepublishOnly - run: yarn checkFormat - run: yarn lint - smoketest: - name: Yarn PnP smoke test - strategy: - fail-fast: false - matrix: - platform: - - macos-latest - - ubuntu-latest - - windows-latest - yarn: - - 2.x - - 3.x - runs-on: ${{ matrix.platform }} - env: - PLUGIN_RUBY_CI: true - steps: - - uses: actions/checkout@main - - uses: ruby/setup-ruby@v1 - with: - bundler-cache: true - ruby-version: "3.0" - - uses: actions/setup-node@v2 - with: - node-version: 12.x - cache: yarn - - run: yarn install --frozen-lockfile - - run: yarn run prepublishOnly - - run: yarn pack - # Windows runners don't have /tmp, let's make sure it exists - - run: mkdir -p /tmp - - run: mv prettier-plugin-ruby-*.tgz /tmp/prettier-plugin-ruby.tgz - - run: mkdir /tmp/smoketest - - name: Smoke test - run: | - cd /tmp/smoketest - echo '{ "name": "smoketest" }' > package.json - yarn set version berry # workaround for https://github.com/yarnpkg/berry/issues/3180 - yarn set version ${{ matrix.yarn }} - yarn add prettier @prettier/plugin-ruby@file:/tmp/prettier-plugin-ruby.tgz - npx rimraf .yarn/unplugged # Make sure Yarn didn't unplug anything; this will deliberately break if it did - echo '{ "plugins": ["@prettier/plugin-ruby"] }' >.prettierrc.json - echo 'def add(a, b) ; a + b ; end' >smoketest.rb - yarn run prettier -w smoketest.rb - ruby -c smoketest.rb - gem: name: Gem runs-on: ubuntu-latest @@ -107,32 +57,12 @@ jobs: - uses: ruby/setup-ruby@v1 with: bundler-cache: true - ruby-version: "3.0" - - uses: actions/setup-node@v2 + ruby-version: "3.2" + - uses: actions/setup-node@v4 with: - node-version: 12.x + node-version: 20.x cache: yarn - run: yarn install --frozen-lockfile - - run: yarn prepublishOnly - run: gem build -o prettier.gem - run: gem unpack prettier.gem - run: prettier/exe/rbprettier --help - - # Saves pull request details for later workflow runs which can run in - # a privileged environment - save-pr-info: - name: Save PR info - needs: - - ci - - lint - runs-on: ubuntu-latest - if: github.event_name == 'pull_request' - steps: - - name: Save PR number - run: | - mkdir -p ./save-pr-info - echo ${{ github.event.number }} > ./save-pr-info/PULL_REQUEST_NUMBER - - uses: actions/upload-artifact@v2 - with: - name: save-pr-info - path: save-pr-info/ diff --git a/.gitignore b/.gitignore index 37e289b9..1a035cd8 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,6 @@ /test.rbs /test.haml *.gem -/dist/ # This is to better support the GitHub actions checking - since bundler changes # to being shipped by default with Ruby starting on 2.6. diff --git a/.npmignore b/.npmignore index bd042760..7a1a86d7 100644 --- a/.npmignore +++ b/.npmignore @@ -5,9 +5,9 @@ /node_modules/ /lib/ /pkg/ -/playground/ /test/ /vendor/ +/*.gem /.* /Gemfile* diff --git a/.prettierignore b/.prettierignore index 577f115a..f430e82a 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,6 +1,5 @@ /.bundle/ /coverage/ -/dist/ /pkg/ /playground/ /vendor/ @@ -17,7 +16,3 @@ *.txt *.gem - -# I'm ignoring this for now because it's a dump of a bunch of types that I don't -# want running onto multiple lines at the moment. -/src/types diff --git a/CHANGELOG.md b/CHANGELOG.md index efff5a0b..0e310a26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,12 +6,131 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a ## [Unreleased] +## [4.0.4] - 2023-12-12 + +### Changed + +- [#1413](https://github.com/prettier/plugin-ruby/pull/1413) - hrabe - Fix the cwd detection for mono-repos. + +## [4.0.3] - 2023-11-27 + +### Changed + +- [#1406](https://github.com/prettier/plugin-ruby/pull/1406) - mikesea - Support running without the RBS or Haml plugins loaded. +- [#1407](https://github.com/prettier/plugin-ruby/pull/1407) - hrabe - Support shimmed Ruby versions. + +## [4.0.2] - 2023-07-14 + +### Changed + +- [#1367](https://github.com/prettier/plugin-ruby/pull/1367) - kddnewton - Specify `prettier` as a peer dependency and not a runtime dependency. + +## [4.0.1] - 2023-07-08 + +### Changed + +- [#1363](https://github.com/prettier/plugin-ruby/pull/1363) - mscrivo, kddnewton - Ensure all data is read from socket before attempting to parse to JSON. + +## [4.0.0] - 2023-07-06 + +### Added + +- [#1283](https://github.com/prettier/plugin-ruby/pull/1283) - oriolgual - Use `process.execPath` instead of `"node"`. +- [#1358](https://github.com/prettier/plugin-ruby/pull/1358) - davidalejandroaguilar - Add the `rubyExecutablePath` option. +- [#1359](https://github.com/prettier/plugin-ruby/pull/1359) - kddnewton - Inherit stderr from the parser process in order to provide better error messages when failing to spawn parser server. This will put out missing gem errors, for example. + +### Changed + +- [#1360](https://github.com/prettier/plugin-ruby/pull/1360) - kddnewton - Require prettier v3.0.0+. + +## [3.2.2] - 2022-09-20 + +### Changed + +- [#1276](https://github.com/prettier/plugin-ruby/pull/1276) - kddnewton - Fix the parsing for options being passed to the server process. + +## [3.2.1] - 2022-09-19 + +### Changed + +- [#1274](https://github.com/prettier/plugin-ruby/pull/1274) - kddnewton - Support the next version of `syntax_tree-haml`. + +## [3.2.0] - 2022-07-22 + +### Added + +- [#1250](https://github.com/prettier/plugin-ruby/issues/1250) - alexf101, kddnewton - Respect the `tabWidth` option. + +### Changed + +- [#1255](https://github.com/prettier/plugin-ruby/pull/1255) - soberstadt - The rake task now runs check if write is false. +- [#1237](https://github.com/prettier/plugin-ruby/issues/1237) - boris-petrov - Disable the style rules associated with quotes. +- [#1248](https://github.com/prettier/plugin-ruby/pull/1248) - mhssmnn - Fix process waiting on STDIN. + +## [3.1.2] - 2022-05-13 + +### Changed + +- [#1127](https://github.com/prettier/plugin-ruby/issues/1227) - mscrivo, kddnewton - Support passing the `printWidth` option. + +## [3.1.1] - 2022-05-12 + +### Changed + +- [#1125](https://github.com/prettier/plugin-ruby/pull/1225) - kddnewton - Update the bundled rubocop config to be in sync with Syntax Tree. + +## [3.1.0] - 2022-05-12 + +### Added + +- [#1224](https://github.com/prettier/plugin-ruby/pull/1224) - kddnewton - Support passing the `rubyPlugins` option to configure Syntax Tree. + +## [3.0.0] - 2022-05-04 + +### Added + +- [#1190](https://github.com/prettier/plugin-ruby/pull/1190) - kddnewton - Encoding for source files is now guessed in a much better way. + +### Changed + +- [#1198](https://github.com/prettier/plugin-ruby/issues/1198) - pas-f, kddnewton - Fix crashes on JRuby with do blocks. +- [#1131](https://github.com/prettier/plugin-ruby/issues/1131) - hyrious, kddnewton - Ensure zombie processes are not left around when the server exits. +- [#1206](https://github.com/prettier/plugin-ruby/pull/1206) - kddnewton - Switch back to plain JavaScript for development. +- [#1190](https://github.com/prettier/plugin-ruby/pull/1190) - kddnewton - Switch over to using Syntax Tree for the backend. This now requires that users install the necessary gems. + +### Removed + +- [#1190](https://github.com/prettier/plugin-ruby/pull/1190) - kddnewton - The configuration options have been removed. Instead, configuration is to be done through modifying Syntax Tree. + +## [2.1.0] - 2022-04-04 + +### Added + +- [#1065](https://github.com/prettier/plugin-ruby/issues/1065) - langalex, kddnewton - The ability to set the `PRETTIER_RUBY_TIMEOUT_MS` environment variable to control how long to wait for the parser server to spin up. +- [#1173](https://github.com/prettier/plugin-ruby/pull/1173) - dleavitt - Support for RBS 2.x on Ruby 3.1. + +### Changed + +- [#1028](https://github.com/prettier/plugin-ruby/issues/1028) - levymetal, kddnewton - Fix up some nested formatting with very complicated RSpec assertions. +- [#1035](https://github.com/prettier/plugin-ruby/issues/1035) - qcn, kddnewton - Ensure we don't try to print `return` incorrectly when multiple statements are contained within parentheses. +- [#1048](https://github.com/prettier/plugin-ruby/pull/1048) - kddnewton - Completely refactor the Ruby parser to use classes instead of hashes. Also remove a lot of the `body` keys are replace them with actual names. +- [#1042](https://github.com/prettier/plugin-ruby/issues/1042) - JoshuaKGoldberg, kddnewton - Ensure blocks are printed correctly when there are trailing comments on the `do` keyword. +- [#1134](https://github.com/prettier/plugin-ruby/pull/1134) - mhssmnn - Fix piping for STDIN to the gem process. +- [#1167](https://github.com/prettier/plugin-ruby/pull/1167) - dleavitt - More consistent assignment indentation. +- [#1074](https://github.com/prettier/plugin-ruby/issues/1074) - wagenet, kddnewton - Fix up `return` when nodes return arrays of docs. + +### Removed + +- [#1048](https://github.com/prettier/plugin-ruby/pull/1048) - kddnewton - Drop support for Ruby 2.5. + +## [2.0.0] - 2021-10-28 + ### Changed - [#1018](https://github.com/prettier/plugin-ruby/issues/1018) - rindek, kddnewton - Ensure brackets are used when matching an array pattern with a single element. - [#906](https://github.com/prettier/plugin-ruby/issues/906) - Hansenq, kddnewton - Turn off the `Style/MultilineBlockChain` rubocop rule in our shipped configuration because multiple chained method calls with blocks can potentially conflict with rubocop's desired output. -## [2.0.0-rc4] +## [2.0.0-rc4] - 2021-10-18 ### Added @@ -22,14 +141,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a - [#1000](https://github.com/prettier/plugin-ruby/pull/1000) - nbudin, kddnewton - Fix for rescuing single top-level exceptions in `rescue` clauses. -## [2.0.0-rc3] +## [2.0.0-rc3] - 2021-10-01 ### Changed - [#987](https://github.com/prettier/plugin-ruby/pull/9870) - valscion - Ignore stderr when checking for node <-> ruby connection clients, restoring the behavior of v1.x - [#989](https://github.com/prettier/plugin-ruby/issues/989) - hubertjakubiak, kddnewton - Make sure comments after the keyword/lbrace are not moved inside the body of the statements of do and brace blocks. -## [2.0.0-rc2] +## [2.0.0-rc2] - 2021-09-30 ### Added @@ -40,7 +159,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a - [#943](https://github.com/prettier/plugin-ruby/issues/943) - valscion, kddnewton - Trailing call operators that are followed by comments should stay on the first line. -## [2.0.0-rc1] +## [2.0.0-rc1] - 2021-09-30 ### Added @@ -293,7 +412,6 @@ The comment in the above example should stay in place. ```ruby begin - rescue Foo, Bar # comment end @@ -449,7 +567,8 @@ return (a or b) if c? - kddnewton - Support for the `nokw_param` node for specifying when methods should no accept keywords, as in: ```ruby -def foo(**nil); end +def foo(**nil) +end ``` - kddnewton - Support for the `args_forward` node for forwarding all types of arguments, as in: @@ -495,9 +614,9 @@ will now be printed as: ```ruby Config::Download.new( - 'prettier', - filename: 'prettier.yml', - url: 'https://raw.githubusercontent.com/...' + "prettier", + filename: "prettier.yml", + url: "https://raw.githubusercontent.com/..." ).perform ``` @@ -1185,7 +1304,21 @@ would previously result in `array[]`, but now prints properly. - Initial release 🎉 -[unreleased]: https://github.com/prettier/plugin-ruby/compare/v2.0.0-rc4...HEAD +[unreleased]: https://github.com/prettier/plugin-ruby/compare/v4.0.4...HEAD +[4.0.4]: https://github.com/prettier/plugin-ruby/compare/v4.0.3...v4.0.4 +[4.0.3]: https://github.com/prettier/plugin-ruby/compare/v4.0.2...v4.0.3 +[4.0.2]: https://github.com/prettier/plugin-ruby/compare/v4.0.1...v4.0.2 +[4.0.1]: https://github.com/prettier/plugin-ruby/compare/v4.0.0...v4.0.1 +[4.0.0]: https://github.com/prettier/plugin-ruby/compare/v3.2.2...v4.0.0 +[3.2.2]: https://github.com/prettier/plugin-ruby/compare/v3.2.1...v3.2.2 +[3.2.1]: https://github.com/prettier/plugin-ruby/compare/v3.2.0...v3.2.1 +[3.2.0]: https://github.com/prettier/plugin-ruby/compare/v3.1.2...v3.2.0 +[3.1.2]: https://github.com/prettier/plugin-ruby/compare/v3.1.1...v3.1.2 +[3.1.1]: https://github.com/prettier/plugin-ruby/compare/v3.1.0...v3.1.1 +[3.1.0]: https://github.com/prettier/plugin-ruby/compare/v3.0.0...v3.1.0 +[3.0.0]: https://github.com/prettier/plugin-ruby/compare/v2.1.0...v3.0.0 +[2.1.0]: https://github.com/prettier/plugin-ruby/compare/v2.0.0...v2.1.0 +[2.0.0]: https://github.com/prettier/plugin-ruby/compare/v2.0.0-rc4...v2.0.0 [2.0.0-rc4]: https://github.com/prettier/plugin-ruby/compare/v2.0.0-rc3...v2.0.0-rc4 [2.0.0-rc3]: https://github.com/prettier/plugin-ruby/compare/v2.0.0-rc2...v2.0.0-rc3 [2.0.0-rc2]: https://github.com/prettier/plugin-ruby/compare/v2.0.0-rc1...v2.0.0-rc2 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 8994fa43..00000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,185 +0,0 @@ -# Contributing - -Thanks so much for your interest in contributing! This page provides background on how prettier and this plugin work, links for understanding each step that prettier executes, various helpful utilities for analyzing the tree structures being manipulated, and frequently asked questions. - -Armed with the knowledge below, we would love to see your contribution! Please open an issue or a pull request at https://github.com/prettier/plugin-ruby. - -- [How it works](#how-it-works) - - [Text to AST](#text-to-ast) - - [AST to Doc](#ast-to-doc) - - [Doc to text](#doc-to-text) -- [FAQ](#faq) -- [Useful links](#useful-links) - - [Ruby](#ruby) - - [Ripper](#ripper) - - [Prettier](#prettier) -- [Useful commands](#useful-commands) -- [Testing](#testing) - -## How it works - -In order to get printed, the code goes through a couple of transformations. The first is taking the entire file as text and parsing it into an abstract syntax tree (AST). The second is taking the AST and transforming it into prettier's intermediate representation, internally referred to as Docs. The final is taking the Doc nodes and converting them back into plain text, taking into account printing rules like max line length. Each of those steps is details below. - -### Text to AST - -When the prettier process first spins up, it examines which files it's going to print and selects an appropriate plugin for each one. Once selected, it runs that plugin's `parse` function, seen [here](src/ruby/parser.js). For the case of the Ruby plugin, that entails spawning a Ruby process that runs [parser.rb](src/ruby/parser.rb) with the input code preloaded on stdin. - -`parser.rb` will read the text off of stdin and then feed it to a new `Ripper` instance, which is a Ruby standard library recursive-descent parser. Briefly, the way that `Ripper` works is by tokenizing the input and then matching those tokens against a grammar to form s-expressions. To extend `Ripper`, you overwrite the methods that control how those s-expressions are formed, e.g., to modify the s-expression that is formed when `Ripper` encounters a string literal, you would override the `#on_string_literal` method. Below is an example for seeing that in action. - -Let's assume you have the following code: - -```ruby -1 + 1 -``` - -First, `Ripper` will tokenize: - - -```ruby -require 'ripper' - -pp Ripper.lex('1 + 1') - -=begin -[[[1, 0], :on_int, "1", EXPR_END], - [[1, 1], :on_sp, " ", EXPR_END], - [[1, 2], :on_op, "+", EXPR_BEG], - [[1, 3], :on_sp, " ", EXPR_BEG], - [[1, 4], :on_int, "1", EXPR_END]] -=end -``` - -You can see it has location metadata (row and column), the token type, the value associated with that token type, and the lexer state when that token was encountered. Then, it will convert those tokens into s-expressions: - - -```ruby -require 'ripper' - -pp Ripper.sexp_raw('1 + 1') - -=begin -[:program, - [:stmts_add, - [:stmts_new], - [:binary, [:@int, "1", [1, 0]], :+, [:@int, "1", [1, 4]]]]] -=end -``` - -As you can see above, the resulting s-expressions will call the following methods in order on the instantiated `Ripper` instance: `on_int`, `on_int`, `on_stmts_new`, `on_binary`, `on_stmts_add`, `on_program`. You can hook into any part of this process by overriding any of those methods (we override all of them). - -Now that the text has been transformed into an AST that we can work with, `parser.rb` will serialize the result to JSON, write it back to stdout, and exit. The `parse` function will then parse that JSON by reading off the child process once it has exited, and return that value back to prettier. - -### AST to Doc - -Once prettier has a working AST, it will take it and call the selected plugin's [`printNode` function](src/ruby/printer.js), whose purpose is to convert that AST into prettier's intermediate representation called Docs. It does this by handing the print function a `FastPath` object that keeps track of the state of the printing as it goes, and allows accessing various parts of the AST quickly. - -Effectively, it walks the AST in the reverse direction from the way `Ripper` built it (top-down instead of bottom-up). The first node that gets passed into the `print` function is the `program` node as that's always on top. Then it is the `program` node's responsibility to recursively call print on its child nodes as it best sees fit. - -As the nodes are printing themselves and their children, they're additionally building up a second AST. That AST is built using the `builder` commands from prettier core, described [here](https://github.com/prettier/prettier/blob/main/commands.md). As an example, below is how a `binary` node (like the one representing the `1 + 1` above) would handle printing itself: - -```javascript -const { group, indent, line } = require("prettier").doc.builders; - -const printBinary = (path, opts, print) => - group([ - [path.call(print, "body", 0), " "], - path.getValue().body[1], - indent([line, path.call(print, "body", 2)]) - ]); -``` - -Recall that the `binary` node looks like this: - -``` -[:binary, [:@int, "1", [1, 0]], :+, [:@int, "1", [1, 4]]] -``` - -This means that there is a node in the `0` position of the array that represents the left-hand operand, and a node in the `2` position of the array that represents the right-hand operand. The operator is represented as a string literal in the `1` position of the array. - -So, the `printBinary` function is going to use the following `prettier` builders to build up the intermediate represention: - -- `group` - marks places where `prettier` could split text if the line gets too long; if the max line length is hit, `prettier` will break apart the outermost `group` node first -- `indent` - increases the current print indent for the contents of the node if the parent node is broken, e.g., if the `binary` node is too long to fit on one line, it will indent the right-hand operand -- `line` - puts a space if the group is not broken, otherwise puts a newline - -Once every node has been printed like the `binary` node above, the `print` node returns the intermediate representation to `prettier`. - -### Doc to text - -At this point, this is where `prettier`'s printer takes over. Because the remainder of the process is language-agnostic and `prettier` knows how to handle its own `Doc` representation, the Ruby plugin no longer has a job to do. `prettier` will walk its own `Doc` nodes and print them out according to the rules established by the structure. - -## FAQ - -Below are a couple of questions frequently asked about the prettier Ruby plugin. - -### Why Ripper over the other available Ruby parsers? - -I've been asked this question a lot, and there are a lot of reasons for this: - -1. Ripper is stdlib, and when the node process running prettier spawns the Ruby process performing the parsing, it's a lot easier to just require ripper than to worry about inconsistent environments having gems installed in myriad places. -2. Ripper is fast, which is nice as we need that to give the developer a good experience. -3. It was originally written in Ripper. Changing the parser at this point would entail an entire rewrite of the system, as the project is inextricably tied to the AST. - -### Why are the Ruby options distinct from the JavaScript options? - -In order to support all preferences, the Ruby options need to be distinct from the JavaScript options, otherwise you would not be able to, for example, have single quotes in Ruby and double quotes in JavaScript. They also indicate somewhat different things. In JavaScript, nothing changes when you use single versus double quotes, whereas in Ruby single and doubles quotes change interpolation behavior. - -### What versions of Ruby are supported? - -We support all Ruby versions that are under security maintenance or better (https://www.ruby-lang.org/en/downloads/branches/). This means at the moment we support back to Ruby 2.5. This is not to say that prettier can't parse and print code that was written while running earlier versions of Ruby, it's just that the Ruby process running prettier (whatever `ruby` resolves to when the process runs) must be >= 2.5. - -### Do you support ERB files (.html.erb, .js.erb, etc.)? - -At the moment, prettier doesn't have baked-in support for template languages. The way it is accomplished in prettier core is to extend each of the individual parsers to have special placeholder AST nodes that then switch the printer over to the necessarily language. This is certainly possible to support ERB, but the work is still being investigated. See [this issue](https://github.com/prettier/plugin-ruby/issues/371) for more detail. - -## Useful links - -For further understanding, below is a list of helpful resources. - -### Ruby - -Links contained within the Ruby source that are relevant to this plugin. - -- [parse.y](https://github.com/ruby/ruby/blob/trunk/parse.y) - the parser generator within Ruby that gives you the names of the nodes as well as their structure -- [test_parser_events.rb](https://github.com/ruby/ruby/blob/trunk/test/ripper/test_parser_events.rb) - the parser test file that gives you code examples of each kind of node - -### Ripper - -Links relating to `ripper` and how it parses Ruby source. - -- [Ripper preview](https://ripper-preview.herokuapp.com) - a visualization of `ripper` and how it parses Ruby source -- [How ripper parses variables](https://rmosolgo.github.io/blog/2018/05/21/how-ripper-parses-variables/) - blog post neatly explaining how `ripper` parses variables -- [Ripper events](https://rmosolgo.github.io/ripper_events/) - documentation for each type of `ripper` node - -### Prettier - -Links relating to `prettier` and its plugins. - -- [Prettier plugin documentation](https://prettier.io/docs/en/plugins.html) - documentation around `prettier`'s plugin system -- [Builder commands](https://github.com/prettier/prettier/blob/main/commands.md) - the functions used to build the `prettier` IR -- [Writing a Prettier plugin](https://medium.com/@fvictorio/how-to-write-a-plugin-for-prettier-a0d98c845e70) - a nice tutorial on how to build a `prettier` plugin - -## Useful commands - -While developing, we've built a couple of small utilities for debugging the `prettier` printing process. To use them, first run `yarn` and `bundle` to install dependencies. - -- `bin/lex [file|source]` - outputs the tokens as ripper sees them -- `bin/sexp [file|source]` - outputs the AST that ripper builds before it gets passed back to `prettier` -- `bin/pragma [file]` - runs the `hasPragma` function against the given input file -- `bin/print [file|source]` - outputs the printed source of a Ruby file after running it through `prettier` - -## Testing - -There are two kinds of tests contained within this repository. - -The first are JavaScript tests (run with `jest`) that test the formatting against preconfigured fixtures to protect against regressions. They live in [test/js](test/js). To run them, run: - -``` -$ yarn test -``` - -The second are Ruby tests (run with `minitest`) that test the gem the wraps the `prettier` plugin as well as testing the various metadata attached to the AST nodes that `ripper` generates. They live in [test/rb](test/rb). To run them, run: - -``` -$ bundle exec rake -``` diff --git a/Gemfile b/Gemfile index c2d85b51..be173b20 100644 --- a/Gemfile +++ b/Gemfile @@ -1,11 +1,5 @@ # frozen_string_literal: true -source 'https://rubygems.org' +source "https://rubygems.org" gemspec - -gem 'bundler', '~> 2.1' -gem 'haml', '~> 5.2' -gem 'minitest', '~> 5.14' -gem 'rake', '~> 13.0' -gem 'rbs', '~> 1.0' diff --git a/README.md b/README.md index b96517c2..a0db67ff 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Gitter - GitHub Actions + GitHub Actions NPM Version @@ -59,118 +59,94 @@ d = [ 30_643_069_058 ] a, s = [], $*[0] -s.each_byte { |b| a << ('%036b' % d[b.chr.to_i]).scan(/\d{6}/) } +s.each_byte { |b| a << ("%036b" % d[b.chr.to_i]).scan(/\d{6}/) } a.transpose.each do |a| - a.join.each_byte { |i| print i == 49 ? ($*[1] || '#') : 32.chr } + a.join.each_byte { |i| print i == 49 ? ($*[1] || "#") : 32.chr } puts end ``` ## Getting started -To run `prettier` with the Ruby plugin, you're going to need [`ruby`](https://www.ruby-lang.org/en/documentation/installation/) (version `2.5` or newer) and [`node`](https://nodejs.org/en/download/) (version `8.3` or newer). If you're integrating with a project that is not already using `prettier`, you should use the Ruby gem. Otherwise you can use the `npm` package directly. +The `@prettier/plugin-ruby` plugin for `prettier` is a small wrapper around the [Syntax Tree](https://github.com/ruby-syntax-tree/syntax_tree) gem that provides a Ruby formatter for `prettier`. It does this by keeping a Ruby server running in that background that `prettier` can communicate with when it needs to format a Ruby file. This means that in order to function, you will need to have both the requisite `node` and `ruby` dependencies installed. Because of this configuration, there are a couple of ways that you can get setup to use this plugin. -Note that currently the editor integrations work best with the `npm` package, as most of the major editor plugins expect a `node_modules` directory. You can get them to work with the Ruby gem, but it requires manually configuring the paths. +- If you're already using `prettier` in your project to format other files in your project and want to install this as a plugin, you can install it using `npm`. +- If you're not using `prettier` yet in your project, then we recommend using the [Syntax Tree](https://github.com/ruby-syntax-tree/syntax_tree) gem directly instead of using this plugin. +- Note that this plugin also ships a gem named `prettier` which is a wrapper around the `prettier` CLI and includes this plugin by default, but _we no longer recommend its use_. If you're using that gem, you should migrate to using [Syntax Tree](https://github.com/ruby-syntax-tree/syntax_tree) instead. -This plugin currently supports formatting the following kinds of files: +To run `prettier` with the Ruby plugin as an `npm` package, you're going to need [`ruby`](https://www.ruby-lang.org/en/documentation/installation/) (version `2.7` or newer) and [`node`](https://nodejs.org/en/download/) (version `16` or newer). -- All varieties of Ruby source files (e.g., `*.rb`, `*.gemspec`, `Gemfile`, etc.) -- [RBS type language](https://github.com/ruby/rbs) files - requires having the `rbs` gem in your gem path -- [HAML template language](https://haml.info/) files - requires having the `haml` gem in your gem path - -### Ruby gem - -Add this line to your application's Gemfile: - -```ruby -gem 'prettier' -``` - -And then execute: +If you're using the `npm` CLI, then add the plugin by: ```bash -bundle +npm install --save-dev prettier @prettier/plugin-ruby ``` -Or install it yourself as: +Or if you're using `yarn`, then add the plugin by: ```bash -gem install prettier +yarn add --dev prettier @prettier/plugin-ruby ``` -The `rbprettier` executable is now installed and ready for use: +You'll also need to add the necessary Ruby dependencies. You can do this by running: ```bash -bundle exec rbprettier --write '**/*' +gem install bundler prettier_print syntax_tree syntax_tree-haml syntax_tree-rbs ``` -### `npm` package - -If you're using the `npm` CLI, then add the plugin by: +The `prettier` executable is now installed and ready for use: ```bash -npm install --save-dev prettier @prettier/plugin-ruby +./node_modules/.bin/prettier --plugin=@prettier/plugin-ruby --write '**/*' ``` -Or if you're using `yarn`, then add the plugin by: - -```bash -yarn add --dev prettier @prettier/plugin-ruby -``` +### Using Prettier >= 3.0 -The `prettier` executable is now installed and ready for use: +You need to tell Prettier to use the plugin, add the following to your existing [prettier configuration +file](https://prettier.io/docs/en/configuration.html). -```bash -./node_modules/.bin/prettier --write '**/*' +```json +{ + "plugins": ["@prettier/plugin-ruby"] +} ``` ## Configuration Below are the options (from [`src/plugin.js`](src/plugin.js)) that `@prettier/plugin-ruby` currently supports: -| API Option | CLI Option | Default | Description | -| ------------------ | ---------------------- | :------: | ------------------------------------------------------------------------------------------------------------------------------------ | -| `printWidth` | `--print-width` | `80` | Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#print-width)). | -| `requirePragma` | `--require-pragma` | `false` | Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#require-pragma)). | -| `rubyArrayLiteral` | `--ruby-array-literal` | `true` | When possible, favor the use of string and symbol array literals. | -| `rubyHashLabel` | `--ruby-hash-label` | `true` | When possible, uses the shortened hash key syntax, as opposed to hash rockets. | -| `rubyModifier` | `--ruby-modifier` | `true` | When it fits on one line, allows while and until statements to use the modifier form. | -| `rubySingleQuote` | `--ruby-single-quote` | `true` | When double quotes are not necessary for interpolation, prefers the use of single quotes for string literals. | -| `rubyToProc` | `--ruby-to-proc` | `false` | When possible, convert blocks to the more concise `Symbol#to_proc` syntax. | -| `tabWidth` | `--tab-width` | `2` | Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#tab-width)). | -| `trailingComma` | `--trailing-comma` | `"none"` | Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#trailing-comma)). `"es5"` is equivalent to `true`. | +| API Option | CLI Option | Default | Description | +| -------------------- | --------------------- | :------------------------------------------------: | --------------------------------------------------------------------------------------------------------------------------------------------------- | +| `printWidth` | `--print-width` | `80` | Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#print-width)). | +| `requirePragma` | `--require-pragma` | `false` | Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#require-pragma)). | +| `rubyExecutablePath` | `"ruby"` | Allows you to configure your Ruby executable path. | +| `rubyPlugins` | `--ruby-plugins` | `""` | The comma-separated list of plugins to require. See [Syntax Tree](https://github.com/ruby-syntax-tree/syntax_tree#plugins). | +| `rubySingleQuote` | `--ruby-single-quote` | `false` | Whether or not to default to single quotes for Ruby code. See [Syntax Tree](https://github.com/ruby-syntax-tree/syntax_tree#plugins). | +| `tabWidth` | `--tab-width` | `2` | Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#tab-width)). | +| `trailingComma` | `--trailing-comma` | `es5` | Almost same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#trailing-commas)). Will be on for any value except `none`. | Any of these can be added to your existing [prettier configuration file](https://prettier.io/docs/en/configuration.html). For example: ```json { - "rubySingleQuote": false + "tabWidth": 4 } ``` Or, they can be passed to `prettier` as arguments: ```bash -bundle exec rbprettier --ruby-single-quote false --write '**/*' +bundle exec rbprettier --tab-width 4 --write '**/*' ``` -### Usage with RuboCop - -RuboCop and Prettier for Ruby serve different purposes, but there is overlap -with some of RuboCop's functionality. - -Prettier provides a RuboCop configuration file to disable the rules which clash. -To enable, add the following config at the top of your project's `.rubocop.yml`: +### Ignoring code -#### Ruby gem +Sometimes you want to leave your formatting in place and have `prettier` not format it, but continue to format the rest of the file. `prettier` has the ability to do this with `prettier-ignore` comments, but because the underlying formatter for this plugin is [Syntax Tree](https://github.com/ruby-syntax-tree/syntax_tree), you instead would use a `stree-ignore` comment. -```yaml -inherit_gem: - prettier: rubocop.yml -``` +### Usage with RuboCop -#### `npm` package +RuboCop and Prettier for Ruby serve different purposes, but there is overlap with some of RuboCop's functionality. Prettier provides a RuboCop configuration file to disable the rules which would clash. To enable this file, add the following configuration at the top of your project's `.rubocop.yml`: ```yaml inherit_from: @@ -198,9 +174,11 @@ Refer to [this issue](https://github.com/prettier/plugin-ruby/issues/113#issueco ## Contributing -Check out our [contributing guide](CONTRIBUTING.md). Bug reports and pull requests are welcome on GitHub at https://github.com/prettier/plugin-ruby. +Thanks so much for your interest in contributing! You can contribute in many ways, including: -You can support `prettier/plugin-ruby` [on OpenCollective](https://opencollective.com/prettier-ruby/contribute). Your organization's logo will show up here with a link to your website. +- Contributing code to fix any bugs on [GitHub](https://github.com/prettier/plugin-ruby). +- Reporting issues on [GitHub](https://github.com/prettier/plugin-ruby/issues/new). +- Supporting `prettier/plugin-ruby` on [OpenCollective](https://opencollective.com/prettier-ruby/contribute). Your organization's logo will show up here with a link to your website. diff --git a/Rakefile b/Rakefile index b2132881..a4eb3b0f 100644 --- a/Rakefile +++ b/Rakefile @@ -1,12 +1,12 @@ # frozen_string_literal: true -require 'bundler/gem_tasks' -require 'rake/testtask' +require "bundler/gem_tasks" +require "rake/testtask" Rake::TestTask.new(:test) do |t| - t.libs << 'test/rb' - t.libs << 'lib' - t.test_files = FileList['test/rb/**/*_test.rb'] + t.libs << "test/rb" + t.libs << "lib" + t.test_files = FileList["test/rb/**/*_test.rb"] end task default: :test diff --git a/bin/console b/bin/console deleted file mode 100755 index 5d2f5a89..00000000 --- a/bin/console +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env ruby - -require 'bundler/setup' -require 'prettier' - -require 'irb' -IRB.start(__FILE__) diff --git a/bin/debug b/bin/debug deleted file mode 100755 index 4f92bf48..00000000 --- a/bin/debug +++ /dev/null @@ -1,170 +0,0 @@ -#!/usr/bin/env ruby - -require 'bundler/inline' - -gemfile do - source 'https://rubygems.org' - gem 'sinatra', require: 'sinatra/base' -end - -require_relative '../src/ruby/parser' - -class App < Sinatra::Base - HTML = DATA.read - - get '/' do - HTML - end - - post '/ast' do - builder = Prettier::Parser.new(request.body.read) - response = builder.parse - - if !response || builder.error? - halt 422 - else - JSON.fast_generate(response) - end - end - - start! -end - -__END__ - - - - - - - @prettier/plugin-ruby - - - -

@prettier/plugin-ruby

- - - - - - diff --git a/bin/doc.ts b/bin/doc.ts deleted file mode 100755 index 89aa9955..00000000 --- a/bin/doc.ts +++ /dev/null @@ -1,15 +0,0 @@ -#!./node_modules/.bin/ts-node - -import fs from "fs"; -import prettier from "prettier"; - -import plugin from "../src/plugin"; - -const debug = (prettier as any).__debug; - -const code = fs.existsSync(process.argv[2]) - ? fs.readFileSync(process.argv[2], "utf-8") - : process.argv.slice(2).join(" ").replace(/\\n/g, "\n"); - -const doc = debug.printToDoc(code, { parser: "ruby", plugins: [plugin] }); -console.log(debug.formatDoc(doc)); diff --git a/bin/lex b/bin/lex deleted file mode 100755 index b0fdc359..00000000 --- a/bin/lex +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env ruby - -require 'ripper' - -source = File.file?(ARGV[0]) ? File.read(ARGV[0]) : ARGV[0].gsub('\\n', "\n") -pp Ripper.lex(source) diff --git a/bin/pragma.ts b/bin/pragma.ts deleted file mode 100755 index 501cdae8..00000000 --- a/bin/pragma.ts +++ /dev/null @@ -1,6 +0,0 @@ -#!./node_modules/.bin/ts-node - -import fs from "fs"; -import parser from "../src/ruby/parser"; - -console.log(parser.hasPragma(fs.readFileSync(process.argv[2], "utf-8"))); diff --git a/bin/print.js b/bin/print.js new file mode 100755 index 00000000..51a3d1e9 --- /dev/null +++ b/bin/print.js @@ -0,0 +1,31 @@ +#!/usr/bin/env node + +import { existsSync, readFileSync } from "fs"; +import { formatWithCursor } from "prettier"; + +import plugin from "../src/plugin.js"; + +let parser = "ruby"; +let contentIdx = 2; + +if (["rbs", "haml"].includes(process.argv[contentIdx])) { + parser = process.argv[contentIdx]; + contentIdx += 1; +} + +let content; + +if (existsSync(process.argv[contentIdx])) { + content = readFileSync(process.argv[contentIdx], "utf-8"); +} else if (process.argv.length === contentIdx) { + const extension = parser === "ruby" ? "rb" : parser; + content = readFileSync(`test.${extension}`, "utf-8"); +} else { + content = process.argv.slice(contentIdx).join(" ").replace(/\\n/g, "\n"); +} + +formatWithCursor(content, { + parser, + plugins: [plugin], + cursorOffset: 1 +}).then(({ formatted }) => console.log(formatted)); diff --git a/bin/print.ts b/bin/print.ts deleted file mode 100755 index 05188d8a..00000000 --- a/bin/print.ts +++ /dev/null @@ -1,33 +0,0 @@ -#!./node_modules/.bin/ts-node - -import fs from "fs"; -import prettier from "prettier"; - -import plugin from "../src/plugin"; - -let parser = "ruby"; -let contentIdx = 2; - -if (["rbs", "haml"].includes(process.argv[contentIdx])) { - parser = process.argv[contentIdx]; - contentIdx += 1; -} - -let content; - -if (fs.existsSync(process.argv[contentIdx])) { - content = fs.readFileSync(process.argv[contentIdx], "utf-8"); -} else if (process.argv.length === contentIdx) { - const extension = parser === "ruby" ? "rb" : parser; - content = fs.readFileSync(`test.${extension}`, "utf-8"); -} else { - content = process.argv.slice(contentIdx).join(" ").replace(/\\n/g, "\n"); -} - -const { formatted } = prettier.formatWithCursor(content, { - parser, - plugins: [plugin as any as string], // hacky, but it works - cursorOffset: 1 -}); - -console.log(formatted); diff --git a/bin/sexp b/bin/sexp deleted file mode 100755 index adb1f4bf..00000000 --- a/bin/sexp +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env ruby - -require_relative '../src/ruby/parser' -require 'pp' - -PP.prepend( - Module.new do - def pp_hash(obj) - group(1, '{', '}') do - text obj[:type] - text "" - - group(1) do - breakable ' ' - pp obj[:body] - end - end - end - end -) - -source = - if !ARGV[0] - File.read('test.rb') - elsif File.file?(ARGV[0]) - File.read(ARGV[0]) - else - ARGV[0].gsub('\\n', "\n") - end - -parsed = Prettier::Parser.new(source).parse - -puts '=== SOURCE === ' -puts source - -puts "\n=== COMMENTS ===" -puts parsed[:comments] - -puts "\n=== S-EXPS ===" -pp parsed diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 00000000..5f507d16 --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,21 @@ +import eslintJs from "@eslint/js"; +import eslintConfigPrettier from "eslint-config-prettier"; +import globals from "globals"; + +export default [ + eslintJs.configs.recommended, + eslintConfigPrettier, + { + languageOptions: { + globals: { + ...globals.builtin, + ...globals.jest, + ...globals.node + } + }, + rules: { + "no-unused-vars": "off" + } + }, + { ignores: ["coverage"] } +]; diff --git a/exe/rbprettier b/exe/rbprettier index 3f3ba279..f5b653a3 100755 --- a/exe/rbprettier +++ b/exe/rbprettier @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$:.unshift(File.expand_path(File.join('..', 'lib'), __dir__)) -require 'prettier' +$:.unshift(File.expand_path(File.join("..", "lib"), __dir__)) +require "prettier" exit(Prettier.run(ARGV)) diff --git a/lib/prettier.rb b/lib/prettier.rb index 47b36b2d..fa68dceb 100644 --- a/lib/prettier.rb +++ b/lib/prettier.rb @@ -1,18 +1,22 @@ # frozen_string_literal: true -require 'json' unless defined?(JSON) -require 'open3' +require "json" unless defined?(JSON) +require "open3" module Prettier - PLUGIN = -File.expand_path('..', __dir__) - BINARY = -File.join(PLUGIN, 'node_modules', 'prettier', 'bin-prettier.js') - VERSION = -JSON.parse(File.read(File.join(PLUGIN, 'package.json')))['version'] + directory = -File.expand_path("..", __dir__) + package = File.read(File.join(directory, "package.json")) + + PLUGIN = -File.join(directory, "src/plugin.js") + BINARY = -File.join(directory, "node_modules/prettier/bin/prettier.cjs") + VERSION = -JSON.parse(package)["version"] def self.run(args) - quoted = args.map { |arg| arg.start_with?('-') ? arg : "\"#{arg}\"" } - command = "node #{BINARY} --plugin \"#{PLUGIN}\" #{quoted.join(' ')}" + quoted = args.map { |arg| arg.start_with?("-") ? arg : "\"#{arg}\"" } + command = "node #{BINARY} --plugin \"#{PLUGIN}\" #{quoted.join(" ")}" + opts = STDIN.tty? ? {} : { stdin_data: STDIN } - stdout, stderr, status = Open3.capture3({ 'RBPRETTIER' => '1' }, command) + stdout, stderr, status = Open3.capture3({}, command, opts) STDOUT.puts(stdout) # If we completed successfully, then just exit out. @@ -29,11 +33,11 @@ def self.run(args) If you installed this dependency through git instead of from rubygems, it does not install the necessary files by default. To fix this you can either install them yourself by cd-ing into the directory where this gem - is located (#{File.expand_path('..', __dir__)}) and running: + is located (#{File.expand_path("..", __dir__)}) and running: - `yarn && yarn prepublishOnly` + `yarn install` or - `npm install && npm run prepublishOnly` + `npm install` or you can change the source in your Gemfile to point directly to rubygems. MSG diff --git a/lib/prettier/rake/task.rb b/lib/prettier/rake/task.rb index a5591297..0da0fc9e 100644 --- a/lib/prettier/rake/task.rb +++ b/lib/prettier/rake/task.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require 'rake' -require 'rake/tasklib' +require "rake" +require "rake/tasklib" module Prettier module Rake @@ -35,7 +35,7 @@ class Task < ::Rake::TaskLib def initialize(name = :prettier) @name = name @write = true - @source_files = 'lib/**/*.rb' + @source_files = "lib/**/*.rb" yield self if block_given? define_task @@ -44,12 +44,12 @@ def initialize(name = :prettier) private def define_task - desc 'Runs prettier over source files' + desc "Runs prettier over source files" task(name) { run_task } end def run_task - Prettier.run([('--write' if write), source_files].compact) + Prettier.run([write ? "--write" : "--check", source_files].compact) exit($?.exitstatus) if $?&.exited? end end diff --git a/package.json b/package.json index 5617d3ad..69dea870 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,13 @@ { "name": "@prettier/plugin-ruby", - "version": "2.0.0-rc4", + "version": "4.0.4", "description": "prettier plugin for the Ruby programming language", - "main": "dist/plugin.js", + "type": "module", + "main": "src/plugin.js", "scripts": { - "checkFormat": "prettier --check '**/*'", + "checkFormat": "prettier . --check", "lint": "eslint --cache .", - "prepublishOnly": "tsc -p tsconfig.build.json && cp src/parser/getInfo.js dist/parser && cp src/parser/netcat.js dist/parser && cp src/parser/server.rb dist/parser && cp src/haml/parser.rb dist/haml && cp src/rbs/parser.rb dist/rbs && cp src/ruby/parser.rb dist/ruby", - "test": "jest" + "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js" }, "repository": { "type": "git", @@ -19,50 +19,27 @@ "url": "https://github.com/prettier/plugin-ruby/issues" }, "homepage": "https://github.com/prettier/plugin-ruby#readme", - "dependencies": { - "prettier": ">=2.3.0" + "peerDependencies": { + "prettier": "^3.0.0" }, "devDependencies": { - "@types/jest": "^27.0.1", - "@types/node": "^16.9.1", - "@types/prettier": "^2.3.2", - "@typescript-eslint/eslint-plugin": "^4.31.2", - "@typescript-eslint/parser": "^4.31.2", - "eslint": "^7.22.0", - "eslint-config-prettier": "^8.0.0", - "husky": "^7.0.0", - "jest": "^27.0.1", - "pretty-quick": "^3.1.0", - "ts-jest": "^27.0.5", - "ts-node": "^10.2.1", - "typescript": "^4.4.3" - }, - "eslintConfig": { - "extends": [ - "eslint:recommended", - "plugin:@typescript-eslint/recommended", - "prettier" - ], - "env": { - "es6": true, - "jest": true, - "node": true - }, - "parser": "@typescript-eslint/parser", - "rules": { - "no-unused-vars": "off", - "@typescript-eslint/explicit-module-boundary-types": "off", - "@typescript-eslint/no-explicit-any": "off" - } + "@eslint/js": "^9.21.0", + "eslint": "^9.21.0", + "eslint-config-prettier": "^10.0.2", + "globals": "^16.0.0", + "husky": "^9.1.7", + "jest": "^29.7.0", + "prettier": "^3.5.3", + "pretty-quick": "^4.1.1" }, "jest": { - "globalSetup": "./test/js/globalSetup.ts", - "globalTeardown": "./test/js/globalTeardown.ts", - "preset": "ts-jest", + "globalSetup": "./test/js/globalSetup.js", + "globalTeardown": "./test/js/globalTeardown.js", "setupFilesAfterEnv": [ - "./test/js/setupTests.ts" + "./test/js/setupTests.js" ], - "testRegex": ".test.ts$" + "testRegex": ".test.js$", + "transform": {} }, "husky": { "hooks": { @@ -72,7 +49,7 @@ "prettier": { "trailingComma": "none", "plugins": [ - "." + "./src/plugin.js" ] } } diff --git a/prettier.gemspec b/prettier.gemspec index c2dbbbf5..5cc3cf5a 100644 --- a/prettier.gemspec +++ b/prettier.gemspec @@ -1,27 +1,34 @@ # frozen_string_literal: true -require 'json' unless defined?(JSON) -package = JSON.parse(File.read(File.join(__dir__, 'package.json'))) +require "json" unless defined?(JSON) +package = JSON.parse(File.read(File.join(__dir__, "package.json"))) Gem::Specification.new do |spec| - spec.name = 'prettier' - spec.version = package['version'] - spec.authors = [package['author']] + spec.name = "prettier" + spec.version = package.fetch("version") + spec.authors = [package.fetch("author")] - spec.summary = package['description'] - spec.homepage = package['homepage'] - spec.license = package['license'] + spec.summary = package.fetch("description") + spec.homepage = package.fetch("homepage") + spec.license = package.fetch("license") spec.files = Dir.chdir(__dir__) do - %w[LICENSE bin/console package.json rubocop.yml] + - Dir['{{exe,lib,dist}/**/*,*.md}'] + - Dir[ - 'node_modules/prettier/{package.json,index.js,doc.js,bin-prettier.js,third-party.js,parser-*.js}' - ] + %w[LICENSE package.json rubocop.yml] + Dir["{{exe,lib,src}/**/*,*.md}"] + + Dir["node_modules/prettier/**/*"] end - spec.bindir = 'exe' - spec.executables = 'rbprettier' + spec.required_ruby_version = ">= 2.7.0" + + spec.bindir = "exe" + spec.executables = "rbprettier" spec.require_paths = %w[lib] + + spec.add_dependency "syntax_tree", ">= 4.0.1" + spec.add_dependency "syntax_tree-haml", ">= 2.0.0" + spec.add_dependency "syntax_tree-rbs", ">= 0.2.0" + + spec.add_development_dependency "bundler" + spec.add_development_dependency "minitest" + spec.add_development_dependency "rake" end diff --git a/rubocop.yml b/rubocop.yml index 4d960c32..64316d0c 100644 --- a/rubocop.yml +++ b/rubocop.yml @@ -1,6 +1,5 @@ # Disabling all Layout/* rules, as they're unnecessary when the user is using -# prettier to handle all of the formatting. - +# Syntax Tree to handle all of the formatting. Layout: Enabled: false @@ -13,7 +12,17 @@ Layout: Layout/LineLength: Enabled: true -Style/MultilineIfModifier: # rubyModifier +Style/MultilineIfModifier: + Enabled: false + +# Syntax Tree will expand empty methods to put the end keyword on the subsequent +# line to reduce git diff noise. +Style/EmptyMethod: + EnforcedStyle: expanded + +# lambdas that are constructed with the lambda method call cannot be safely +# turned into lambda literals without removing a method call. +Style/Lambda: Enabled: false # When method chains with multiple blocks are chained together, rubocop will let @@ -23,22 +32,33 @@ Style/MultilineIfModifier: # rubyModifier Style/MultilineBlockChain: Enabled: false -Style/SymbolArray: # rubyArrayLiteral +# Disable the single- vs double-quotes rules as these depend on whether the user +# has added or not `plugin/single_quotes` for `syntax_tree` +Style/StringLiterals: Enabled: false -Style/WordArray: # rubyArrayLiteral +Style/StringLiteralsInInterpolation: Enabled: false -Style/TrailingCommaInArguments: # trailingComma +Style/QuotedSymbols: Enabled: false -Style/TrailingCommaInArrayLiteral: # trailingComma +# We let users have a little more freedom with symbol and words arrays. If the +# user only has an individual item like ["value"] then we don't bother +# converting it because it ends up being just noise. +Style/SymbolArray: Enabled: false -Style/TrailingCommaInHashLiteral: # trailingComma +Style/WordArray: Enabled: false -# lambdas that are constructed with the lambda method call cannot be safely -# turned into lambda literals without removing a method call. -Style/Lambda: +# Disable the trailing-comma rules as these depend on whether the user has added +# or not `plugin/trailing_comma` for `syntax_tree` +Style/TrailingCommaInArguments: + Enabled: false + +Style/TrailingCommaInArrayLiteral: + Enabled: false + +Style/TrailingCommaInHashLiteral: Enabled: false diff --git a/src/haml/embed.ts b/src/haml/embed.ts deleted file mode 100644 index a5b89a9c..00000000 --- a/src/haml/embed.ts +++ /dev/null @@ -1,75 +0,0 @@ -import type { Plugin, HAML } from "../types"; -import prettier from "../prettier"; - -const { - hardline, - indent, - literalline, - markAsRoot, - mapDoc, - stripTrailingHardline -} = prettier; - -// This function is in here because it handles embedded parser values. I don't -// have a test that exercises it because I'm not sure for which parser it is -// necessary, but since it's in prettier core I'm keeping it here. -/* istanbul ignore next */ -function replaceNewlines(doc: Plugin.Doc) { - return mapDoc(doc, (currentDoc) => - typeof currentDoc === "string" && currentDoc.includes("\n") - ? currentDoc.split(/(\n)/g).map((v, i) => (i % 2 === 0 ? v : literalline)) - : currentDoc - ); -} - -const embed: Plugin.Embed = (path, _print, textToDoc, opts) => { - const node = path.getValue(); - - // We're only going to embed other languages on filter nodes. - if (node.type !== "filter") { - return null; - } - - let parser = node.value.name; - - // We don't want to deal with some weird recursive parser situation, so we - // need to explicitly call out the HAML parser here and just return null. - if (parser === "haml") { - return null; - } - - // In HAML the name of the JS filter is :javascript, whereas in prettier the - // name of the JS parser is babel. Here we explicitly handle that conversion. - if (parser === "javascript") { - parser = "babel"; - } - - // If there aren't any plugins that look like the name of the filter, then we - // will just exit early. - if ( - !opts.plugins.some( - (plugin) => - typeof plugin !== "string" && - plugin.parsers && - Object.prototype.hasOwnProperty.call(plugin.parsers, parser) - ) - ) { - return null; - } - - // If there is a plugin that has a parser that matches the name of this - // filter, then we're going to assume that's correct for embedding and go - // ahead and switch to that parser. - return markAsRoot([ - ":", - node.value.name, - indent([ - hardline, - replaceNewlines( - stripTrailingHardline(textToDoc(node.value.text, { parser })) - ) - ]) - ]); -}; - -export default embed; diff --git a/src/haml/parser.rb b/src/haml/parser.rb deleted file mode 100644 index cd8d9796..00000000 --- a/src/haml/parser.rb +++ /dev/null @@ -1,143 +0,0 @@ -# frozen_string_literal: true - -require 'ripper' - -begin - require 'haml' -rescue LoadError - # If we can't load the haml gem, then we're going to provide a shim parser - # that will warn and bail out. - class Prettier::HAMLParser - def self.parse(text) - warn( - 'The `haml` gem could not be loaded. Please ensure you have it ' \ - 'installed and that it is available in the gem path.' - ) - - false - end - end - - return -end - -class Haml::Parser::ParseNode - class DeepAttributeParser - def parse(string) - Haml::AttributeParser.available? ? parse_value(string) : string - end - - private - - def literal(string, level) - level == 0 ? string : "&#{string}" - end - - def parse_value(string, level = 0) - response = Ripper.sexp(string) - return literal(string, level) unless response - - case response[1][0][0] - when :hash - hash = Haml::AttributeParser.parse(string) - - if hash - # Explicitly not using Enumerable#to_h here to support Ruby 2.5 - hash.each_with_object({}) do |(key, value), response| - response[key] = parse_value(value, level + 1) - end - else - literal(string, level) - end - when :string_literal - string[1...-1] - else - literal(string, level) - end - end - end - - ESCAPE = /Haml::Helpers.html_escape\(\((.+)\)\)/.freeze - - # If a node comes in as the plain type but starts with one of the special - # characters that haml parses, then we need to escape it with a \ when - # printing. So here we make a regexp pattern to check if the node needs to be - # escaped. - special_chars = - Haml::Parser::SPECIAL_CHARACTERS.map { |char| Regexp.escape(char) } - - SPECIAL_START = /\A(?:#{special_chars.join('|')})/ - - def as_json - case type - when :comment, :doctype, :silent_script - to_h.tap do |json| - json.delete(:parent) - json[:children] = children.map(&:as_json) - end - when :filter, :haml_comment - to_h.tap { |json| json.delete(:parent) } - when :plain - to_h.tap do |json| - json.delete(:parent) - json[:children] = children.map(&:as_json) - - text = json[:value][:text] - json[:value][:text] = "\\#{text}" if text.match?(SPECIAL_START) - end - when :root - to_h.tap do |json| - json[:children] = children.map(&:as_json) - - # We need this information in the printer to know how to lay out - # multi-line attributes. - json[:supports_multiline] = - Gem::Version.new(Haml::VERSION) >= Gem::Version.new('5.2') - end - when :script - to_h.tap do |json| - json.delete(:parent) - json[:children] = children.map(&:as_json) - - if json[:value][:text].match?(ESCAPE) - json[:value][:text].gsub!(ESCAPE) { $1 } - json[:value].merge!(escape_html: 'escape_html', interpolate: true) - end - end - when :tag - to_h.tap do |json| - json.delete(:parent) - - # For some reason this is actually using a symbol to represent a null - # object ref instead of nil itself, so just replacing it here for - # simplicity in the printer - json[:value][:object_ref] = nil if json[:value][:object_ref] == :nil - - # Get a reference to the dynamic attributes hash - dynamic_attributes = value[:dynamic_attributes].to_h - - # If we have any in the old style, then we're going to pass it through - # the deep attribute parser filter. - if dynamic_attributes[:old] - dynamic_attributes[:old] = - DeepAttributeParser.new.parse(dynamic_attributes[:old]) - end - - json.merge!( - children: children.map(&:as_json), - value: value.merge(dynamic_attributes: dynamic_attributes) - ) - end - else - raise ArgumentError, "Unsupported type: #{type}" - end - end -end - -module Prettier - class HAMLParser - def self.parse(source) - Haml::Parser.new({}).call(source).as_json - end - end -end diff --git a/src/haml/parser.ts b/src/haml/parser.ts deleted file mode 100644 index 44a8a736..00000000 --- a/src/haml/parser.ts +++ /dev/null @@ -1,29 +0,0 @@ -import type { Plugin, HAML } from "../types"; -import parseSync from "../parser/parseSync"; - -const parser: Plugin.Parser = { - // This function is responsible for taking an input string of text and - // returning to prettier a JavaScript object that is the equivalent AST that - // represents the code stored in that string. We accomplish this by spawning a - // new process and reading JSON off STDOUT. - parse(text) { - return parseSync("haml", text); - }, - astFormat: "haml", - // This function handles checking whether or not the source string has the - // pragma for prettier. This is an optional workflow for incremental adoption. - hasPragma(text) { - return /^\s*-#\s*@(prettier|format)/.test(text); - }, - // These functions are just placeholders until we can actually perform this - // properly. The functions are necessary otherwise the format with cursor - // functions break. - locStart() { - return 0; - }, - locEnd() { - return 0; - } -}; - -export default parser; diff --git a/src/haml/printer.ts b/src/haml/printer.ts deleted file mode 100644 index 3a964a09..00000000 --- a/src/haml/printer.ts +++ /dev/null @@ -1,427 +0,0 @@ -import type { Plugin, HAML } from "../types"; -import prettier from "../prettier"; -import embed from "./embed"; - -const { - align, - fill, - group, - hardline, - ifBreak, - indent, - join, - line, - makeString, - softline -} = prettier; - -const docTypes = { - basic: "Basic", - frameset: "Frameset", - mobile: "Mobile", - rdfa: "RDFa", - strict: "Strict", - xml: "XML" -} as const; - -const docVersions = ["1.1", "5"]; - -// Prints out a hash key according to the configured prettier options. -function printHashKey(key: string, opts: Plugin.Options) { - let quoted = key; - const joiner = opts.rubyHashLabel ? ":" : " =>"; - - if (key.includes(":") || key.includes("-")) { - const quote = opts.rubySingleQuote ? "'" : '"'; - quoted = `${quote}${key}${quote}`; - } - - return `${opts.rubyHashLabel ? "" : ":"}${quoted}${joiner}`; -} - -// Prints out the value inside of a hash key-value pair according to the -// configured prettier options. -function printHashValue(value: string | number, opts: Plugin.Options) { - if (typeof value !== "string") { - return value.toString(); - } - - // This is a very special syntax created by the parser to let us know that - // this should be printed literally instead of as a string. - if (value.startsWith("&")) { - return value.slice(1); - } - - const quote = - opts.rubySingleQuote && !value.includes("#{") && !value.includes("'") - ? "'" - : '"'; - - return makeString(value, quote); -} - -// This will print an attributes object to a Doc node. It handles nesting on -// multiple levels and will print out according to whether or not the version of -// HAML being used supports multi-line attributes. -function printAttributes( - object: HAML.TagAttrs, - opts: Plugin.Options & { supportsMultiline: boolean; headerLength: number }, - level = 0 -) { - if (typeof object !== "object") { - return printHashValue(object, opts); - } - - const boundary = level === 0 ? softline : line; - const parts: Plugin.Doc[] = Object.keys(object).map((key) => [ - printHashKey(key, opts), - " ", - printAttributes(object[key], opts, level + 1) - ]); - - // If we have support for multi-line attributes laid out like a regular hash, - // then we print them that way here. - if (opts.supportsMultiline) { - return group([ - "{", - indent(group([boundary, join([",", line], parts)])), - boundary, - "}" - ]); - } - - // Otherwise, if we only have one attribute, then just print it inline - // regardless of how long it is. - if (parts.length === 0) { - return group(["{", parts[0], "}"]); - } - - // Otherwise, depending on how long the line is it will split the content into - // multi-line attributes that old Haml understands. - return group([ - "{", - parts[0], - ",", - align(opts.headerLength + 1, [line, join([",", line], parts.slice(1))]), - "}" - ]); -} - -// A utility function used in a silent script that is meant to determine if a -// child node is a continuation of a parent node (as in a when clause within a -// case statement or an else clause within an if). -function isContinuation( - parentNode: HAML.SilentScript, - childNode: HAML.AnyNode -) { - if (childNode.type !== "silent_script") { - return false; - } - - const parent = parentNode.value.keyword; - const child = childNode.value.keyword; - - return ( - (parent === "case" && ["when", "else"].includes(child)) || - (["if", "unless"].includes(parent) && ["elsif", "else"].includes(child)) - ); -} - -const printer: Plugin.PrinterConfig = { - embed, - // This is our printer's main print function that will switch on the type of - // node and print it out by returning a Doc tree. - print(path, opts, print) { - const node = path.getValue(); - - switch (node.type) { - // https://haml.info/docs/yardoc/file.REFERENCE.html#html-comments- - case "comment": { - const { value } = node; - const parts = ["/"]; - - if (value.revealed) { - parts.push("!"); - } - - if (value.conditional) { - parts.push(value.conditional); - } else if (value.text) { - parts.push(" ", value.text); - } - - return printWithChildren(node, group(parts)); - } - // https://haml.info/docs/yardoc/file.REFERENCE.html#doctype- - case "doctype": { - const { value } = node; - const parts = ["!!!"]; - - if (value.type in docTypes) { - parts.push(docTypes[value.type as keyof typeof docTypes]); - } else if (value.version && docVersions.includes(value.version)) { - parts.push(value.version); - } else { - parts.push(value.type); - } - - if (value.encoding) { - parts.push(value.encoding); - } - - return group(join(" ", parts)); - } - // https://haml.info/docs/yardoc/file.REFERENCE.html#filters - case "filter": - return group([ - ":", - node.value.name, - indent([hardline, join(hardline, node.value.text.trim().split("\n"))]) - ]); - // https://haml.info/docs/yardoc/file.REFERENCE.html#haml-comments-- - case "haml_comment": { - const { value } = node; - const parts: Plugin.Doc[] = ["-#"]; - - if (value.text) { - if (opts.originalText.split("\n")[node.line - 1].trim() === "-#") { - const lines = value.text.trim().split("\n"); - - parts.push(indent([hardline, join(hardline, lines)])); - } else { - parts.push(" ", value.text.trim()); - } - } - - return parts; - } - // https://haml.info/docs/yardoc/file.REFERENCE.html#plain-text - case "plain": - return node.value.text; - // The root node in the AST that we build in the parser. - case "root": { - const nodePath = path as Plugin.Path; - - return [join(hardline, nodePath.map(print, "children")), hardline]; - } - // https://haml.info/docs/yardoc/file.REFERENCE.html#inserting_ruby - case "script": { - const { value } = node; - const parts = []; - - if (value.escape_html) { - parts.unshift("&"); - } - - if (value.preserve) { - parts.push("~"); - } else if (!value.interpolate) { - parts.push("="); - } - - if (value.escape_html && !value.preserve && value.interpolate) { - parts.push(" ", value.text.trim().slice(1, -1)); - } else { - parts.push(" ", value.text.trim()); - } - - return printWithChildren(node, group(parts)); - } - // https://haml.info/docs/yardoc/file.REFERENCE.html#running-ruby-- - case "silent_script": { - const parts: Plugin.Doc[] = [`- ${node.value.text.trim()}`]; - - if (node.children.length > 0) { - const nodePath = path as Plugin.Path; - - parts.push( - nodePath.map((childPath) => { - const child = childPath.getValue(); - const concated = [hardline, print(childPath)]; - - return isContinuation(node, child) ? concated : indent(concated); - }, "children") - ); - } - - return group(parts); - } - // https://haml.info/docs/yardoc/file.REFERENCE.html#element-name- - case "tag": { - const { value } = node; - const { attributes, dynamic_attributes } = value; - const parts = []; - - // If we have a tag that isn't a div, then we need to print out that - // name of that tag first. If it is a div, first we'll check if there - // are any other things that would force us to print out the div - // explicitly, and otherwise we'll leave it off. - if (value.name !== "div") { - parts.push(`%${value.name}`); - } - - // If we have a class attribute, then we're going to print that here - // using the special class syntax. - if (attributes.class) { - parts.push(`.${attributes.class.replace(/ /g, ".")}`); - } - - // If we have an id attribute, then we're going to print that here using - // the special id syntax. - if (attributes.id) { - parts.push(`#${attributes.id}`); - } - - // If we're using dynamic attributes on this tag, then they come in as a - // string that looks like the output of Hash#inspect from Ruby. So here - // we're going to split it all up and print it out nicely. - if (dynamic_attributes.new) { - const docs: Plugin.Doc[] = []; - - dynamic_attributes.new - .slice(1, -2) - .split(",") - .forEach((pair, index) => { - if (index !== 0) { - docs.push(line); - } - docs.push(join("=", pair.slice(1).split('" => '))); - }); - - parts.push( - group(["(", align(parts.join("").length + 1, fill(docs)), ")"]) - ); - } - - // If there are any static attributes that are not class or id (because - // we already took care of those), then we're going to print them out - // here. - const staticAttributes = Object.keys(attributes).filter( - (name) => !["class", "id"].includes(name) - ); - - if (staticAttributes.length > 0) { - const docs = staticAttributes.reduce((accum, key) => { - const doc = `${printHashKey(key, opts)} ${printHashValue( - attributes[key], - opts - )}`; - - return accum.length === 0 ? [doc] : [...accum, ",", line, doc]; - }, [] as Plugin.Doc[]); - - parts.push( - group(["{", align(parts.join("").length + 1, fill(docs)), "}"]) - ); - } - - // If there are dynamic attributes that don't use the newer syntax, then - // we're going to print them out here. - if (dynamic_attributes.old) { - if (parts.length === 0) { - parts.push("%div"); - } - - if (typeof dynamic_attributes.old === "string") { - parts.push(dynamic_attributes.old); - } else { - // This is kind of a total hack in that I don't think you're - // really supposed to directly use `path.stack`, but it's the - // easiest way to get the root node without having to know how - // many levels deep we are. - const root = path.stack[0] as HAML.Root; - - parts.push( - printAttributes(dynamic_attributes.old, { - ...opts, - supportsMultiline: root.supports_multiline, - headerLength: parts.join("").length - }) - ); - } - } - - // https://haml.info/docs/yardoc/file.REFERENCE.html#object-reference- - if (value.object_ref) { - if (parts.length === 0) { - parts.push("%div"); - } - parts.push(value.object_ref); - } - - // https://haml.info/docs/yardoc/file.REFERENCE.html#whitespace-removal--and- - if (value.nuke_outer_whitespace) { - parts.push(">"); - } - - if (value.nuke_inner_whitespace) { - parts.push("<"); - } - - // https://haml.info/docs/yardoc/file.REFERENCE.html#empty-void-tags- - if (value.self_closing) { - parts.push("/"); - } - - if (value.value) { - let contents: Plugin.Doc[]; - - if (value.parse && value.value.match(/#[{$@]/)) { - // There's a weird case here where if the value includes - // interpolation and it's marked as { parse: true }, then we don't - // actually want the = prefix, and we want to remove extra escaping. - contents = [ - ifBreak("", " "), - value.value.slice(1, -1).replace(/\\"/g, '"') - ]; - } else if (value.parse) { - contents = ["= ", value.value]; - } else { - contents = [ifBreak("", " "), value.value]; - } - - return printWithChildren( - node, - group([group(parts), indent([softline, ...contents])]) - ); - } - - // In case none of the other if statements have matched and we're - // printing a div, we need to explicitly add it back into the array. - if (parts.length === 0 && value.name === "div") { - parts.push("%div"); - } - - return printWithChildren(node, group(parts)); - } - default: - throw new Error(`Unsupported node encountered: ${(node as any).type}`); - } - - // It's common to a couple of nodes to attach nested child nodes on the - // children property. This utility prints them out grouped together with - // their parent node docs. - function printWithChildren( - node: HAML.Comment | HAML.Script | HAML.Tag, - docs: Plugin.Doc - ) { - if (node.children.length === 0) { - return docs; - } - - const nodePath = path as Plugin.Path; - - return group([ - docs, - indent([hardline, join(hardline, nodePath.map(print, "children"))]) - ]); - } - }, - // This function handles adding the format pragma to a source string. This is - // an optional workflow for incremental adoption. - insertPragma(text) { - return `-# @format${text.startsWith("-#") ? "\n" : "\n\n"}${text}`; - } -}; - -export default printer; diff --git a/src/parser/getInfo.js b/src/parser/getInfo.js deleted file mode 100644 index 1243c224..00000000 --- a/src/parser/getInfo.js +++ /dev/null @@ -1,17 +0,0 @@ -// eslint-disable-next-line @typescript-eslint/no-var-requires -const { existsSync, readFileSync } = require("fs"); - -const filepath = process.argv[process.argv.length - 1]; - -const timeout = setTimeout(() => { - clearInterval(interval); - throw new Error("Failed to get information from parse server in time."); -}, 5000); - -const interval = setInterval(() => { - if (existsSync(filepath)) { - process.stdout.write(readFileSync(filepath).toString("utf8")); - clearTimeout(timeout); - clearInterval(interval); - } -}, 100); diff --git a/src/parser/netcat.js b/src/parser/netcat.js deleted file mode 100644 index 4a6971a0..00000000 --- a/src/parser/netcat.js +++ /dev/null @@ -1,14 +0,0 @@ -// A simple fallback when no netcat-compatible adapter is found on the system. -// On average, this is 2-3x slower than netcat, but still much faster than -// spawning a new Ruby process. - -// eslint-disable-next-line @typescript-eslint/no-var-requires -const { createConnection } = require("net"); - -const sock = process.argv[process.argv.length - 1]; -const client = createConnection(sock, () => process.stdin.pipe(client)); - -client.on("data", (data) => process.stdout.write(data)); -client.on("error", (error) => { - console.error(error); -}); diff --git a/src/parser/parseSync.ts b/src/parser/parseSync.ts deleted file mode 100644 index 388b7313..00000000 --- a/src/parser/parseSync.ts +++ /dev/null @@ -1,216 +0,0 @@ -import { spawn, spawnSync } from "child_process"; -import { - existsSync, - unlinkSync, - mkdtempSync, - copyFileSync, - mkdirSync, - rmdirSync -} from "fs"; -import os from "os"; -import path from "path"; -import process from "process"; - -type ParserArgs = { cmd: string; args: string[] }; -let parserArgs: undefined | ParserArgs; - -if (process.env.PRETTIER_RUBY_HOST) { - const [cmd, ...args] = process.env.PRETTIER_RUBY_HOST.split(" "); - parserArgs = { cmd, args }; -} - -// In order to properly parse ruby code, we need to tell the ruby process to -// parse using UTF-8. Unfortunately, the way that you accomplish this looks -// differently depending on your platform. -/* istanbul ignore next */ -export function getLang() { - const { env, platform } = process; - const envValue = env.LC_ALL || env.LC_CTYPE || env.LANG; - - // If an env var is set for the locale that already includes UTF-8 in the - // name, then assume we can go with that. - if (envValue && envValue.includes("UTF-8")) { - return envValue; - } - - // Otherwise, we're going to guess which encoding to use based on the system. - // This is probably not the best approach in the world, as you could be on - // linux and not have C.UTF-8, but in that case you're probably passing an env - // var for it. This object below represents all of the possible values of - // process.platform per: - // https://nodejs.org/api/process.html#process_process_platform - return { - aix: "C.UTF-8", - android: "C.UTF-8", - cygwin: "C.UTF-8", - darwin: "en_US.UTF-8", - freebsd: "C.UTF-8", - haiku: "C.UTF-8", - linux: "C.UTF-8", - netbsd: "C.UTF-8", - openbsd: "C.UTF-8", - sunos: "C.UTF-8", - win32: ".UTF-8" - }[platform]; -} - -// Generate the filepath that should be used to communicate the connection -// information between this process and the parser server. -export function getInfoFilepath() { - return path.join(os.tmpdir(), `prettier-ruby-parser-${process.pid}.info`); -} - -// Create a file that will act as a communication mechanism, spawn a parser -// server with that filepath as an argument, then spawn another process that -// will read that information in order to enable us to connect to it in the -// spawnSync function. -function spawnServer(): ParserArgs { - const tempDir = mkdtempSync(path.join(os.tmpdir(), "prettier-plugin-ruby-")); - const filepath = getInfoFilepath(); - - let serverRbPath = path.join(__dirname, "./server.rb"); - let getInfoJsPath = path.join(__dirname, "./getInfo.js"); - let cleanupTempFiles: () => void | undefined; - - if (runningInPnPZip()) { - // If we're running in a Yarn PnP environment inside a ZIP file, it's not possible to run - // the Ruby server or the getInfo.js script directly. Instead, we need to copy them and all - // the files they depend on to a temporary directory. - - const sourceFiles = [ - "parser/server.rb", - "parser/getInfo.js", - "parser/netcat.js", - "ruby/parser.rb", - "rbs/parser.rb", - "haml/parser.rb" - ]; - serverRbPath = path.join(tempDir, "parser", "server.rb"); - getInfoJsPath = path.join(tempDir, "parser", "getInfo.js"); - - sourceFiles.forEach((rubyFile) => { - const destDir = path.join(tempDir, path.dirname(rubyFile)); - if (!existsSync(destDir)) { - mkdirSync(destDir); - } - copyFileSync( - path.join(__dirname, "..", rubyFile), - path.join(tempDir, rubyFile) - ); - }); - - cleanupTempFiles = () => { - [ - getInfoJsPath, - ...sourceFiles.map((rubyFile) => path.join(tempDir, rubyFile)) - ].forEach((tmpFilePath) => { - if (existsSync(tmpFilePath)) { - unlinkSync(tmpFilePath); - } - }); - - sourceFiles.forEach((rubyFile) => { - const tempSubdir = path.join(tempDir, path.dirname(rubyFile)); - if (existsSync(tempSubdir)) { - rmdirSync(tempSubdir); - } - }); - - if (existsSync(tempDir)) { - rmdirSync(tempDir); - } - }; - } - - const server = spawn("ruby", [serverRbPath, filepath], { - env: Object.assign({}, process.env, { LANG: getLang() }), - detached: true, - stdio: "inherit" - }); - - server.unref(); - process.on("exit", () => { - if (existsSync(filepath)) { - unlinkSync(filepath); - } - - if (cleanupTempFiles != null) { - cleanupTempFiles(); - } - - try { - if (server.pid) { - process.kill(-server.pid); - } - } catch (e) { - if (process.env.PLUGIN_RUBY_CI) { - throw new Error(`Failed to kill the parser server: ${e}`); - } - } - }); - - const info = spawnSync("node", [getInfoJsPath, filepath]); - - if (info.status !== 0) { - throw new Error(` - We failed to spawn our parser server. Please report this error on GitHub - at https://github.com/prettier/plugin-ruby. The error message was: - - ${info.stderr.toString()}. - `); - } - - const [cmd, ...args] = info.stdout.toString().split(" "); - return { cmd, args }; -} - -// If we're in a yarn Plug'n'Play environment, then the relative paths being -// used by the parser server and the various scripts used to communicate -// therein are not going to work with its virtual file system. -function runningInPnPZip() { - return process.versions.pnp && __dirname.includes(".zip"); -} - -// You can optionally return location information from the source string when -// raising an error that prettier will handle for you nicely. -type LocatedError = Error & { loc?: any }; - -// Formats and sends a request to the parser server. We use netcat (or something -// like it) here since Prettier requires the results of `parse` to be -// synchronous and Node.js does not offer a mechanism for synchronous socket -// requests. -function parseSync(parser: string, source: string) { - if (!parserArgs) { - parserArgs = spawnServer(); - } - - const response = spawnSync(parserArgs.cmd, parserArgs.args, { - input: `${parser}|${source}`, - maxBuffer: 15 * 1024 * 1024 - }); - - const stdout = response.stdout.toString(); - const stderr = response.stderr.toString(); - const { status } = response; - - // If we didn't receive anything over stdout or we have a bad exit status, - // then throw whatever we can. - if (stdout.length === 0 || (status !== null && status !== 0)) { - throw new Error(stderr || "An unknown error occurred"); - } - - const parsed = JSON.parse(stdout); - - if (parsed.error) { - const error: LocatedError = new Error(parsed.error); - if (parsed.loc) { - error.loc = parsed.loc; - } - - throw error; - } - - return parsed; -} - -export default parseSync; diff --git a/src/parser/server.rb b/src/parser/server.rb deleted file mode 100644 index 8835437d..00000000 --- a/src/parser/server.rb +++ /dev/null @@ -1,141 +0,0 @@ -# frozen_string_literal: true - -require 'bundler/setup' if ENV['PLUGIN_RUBY_CI'] -require 'socket' -require 'json' -require 'fileutils' -require 'open3' - -require_relative '../ruby/parser' -require_relative '../rbs/parser' -require_relative '../haml/parser' - -# Make sure we trap these signals to be sure we get the quit command coming from -# the parent node process -quit = false -trap(:INT) { quit = true } -trap(:TERM) { quit = true } -trap(:QUIT) { quit = true } if Signal.list.key?('QUIT') - -# The information variable stores the actual connection information, which will -# either be an IP address and port or a path to a unix socket file. -information = '' - -# The candidates array is a list of potential programs that could be used to -# connect to our server. We'll run through them after the server starts to find -# the best one to use. -candidates = [] - -if Gem.win_platform? - # If we're on windows, we're going to start up a TCP server. The 0 here means - # to bind to some available port. - server = TCPServer.new('127.0.0.1', 0) - address = server.local_address - - # Ensure that we close the server when this process exits. - at_exit { server.close } - - information = "#{address.ip_address} #{address.ip_port}" - candidates = %w[nc telnet] -else - # If we're not on windows, then we're going to assume we can use unix socket - # files (since they're faster than a TCP server). - filepath = "/tmp/prettier-ruby-parser-#{Process.pid}.sock" - server = UNIXServer.new(filepath) - - # Ensure that we close the server and delete the socket file when this - # process exits. - at_exit do - server.close - File.unlink(filepath) - end - - information = server.local_address.unix_path - candidates = ['nc -w 3 -U', 'ncat -w 3 -U'] -end - -# This is the actual listening thread that will be acting as our server. We have -# to start it in another thread to begin with so that we can run through our -# candidate connection programs. Eventually we'll just join into this thread -# though and it will act as a daemon. -listener = - Thread.new do - loop do - break if quit - - # Start up a new thread that will handle each successive connection. - Thread.new(server.accept_nonblock) do |socket| - parser, source = socket.read.force_encoding('UTF-8').split('|', 2) - - response = - case parser - when 'ping' - 'pong' - when 'ruby' - Prettier::Parser.parse(source) - when 'rbs' - Prettier::RBSParser.parse(source) - when 'haml' - Prettier::HAMLParser.parse(source) - end - - if response - socket.write(JSON.fast_generate(response)) - else - socket.write('{ "error": true }') - end - rescue Prettier::Parser::ParserError => error - loc = { start: { line: error.lineno, column: error.column } } - socket.write(JSON.fast_generate(error: error.message, loc: loc)) - rescue StandardError => error - begin - socket.write(JSON.fast_generate(error: error.message)) - rescue Errno::EPIPE - # Do nothing, the pipe has been closed by the parent process so we don't - # actually care about writing to it anymore. - end - ensure - socket.close - end - rescue IO::WaitReadable, Errno::EINTR - # Wait for select(2) to give us a connection that has content for 1 - # second. Otherwise timeout and continue on (so that we hit our - # "break if quit" pretty often). - IO.select([server], nil, nil, 1) - - retry unless quit - end - end - -# Map each candidate connection method to a thread that will check if it works. -candidates.map! do |candidate| - Thread.new do - Thread.current.report_on_exception = false - - # We do not care about stderr here, so throw it away - stdout, _stderr, status = - Open3.capture3("#{candidate} #{information}", stdin_data: 'ping') - - candidate if JSON.parse(stdout) == 'pong' && status.exitstatus == 0 - rescue StandardError - # We don't actually care if this fails, because we'll just skip that - # connection option. - end -end - -# Find the first one prefix that successfully returned the correct value. -prefix = - candidates.detect do |candidate| - value = candidate.value - break value if value - end - -# Default to running the netcat.js script that we ship with the plugin. It's a -# good fallback as it will always work, but it is slower than the other options. -prefix ||= "node #{File.expand_path('netcat.js', __dir__)}" - -# Write out our connection information to the file given as the first argument -# to this script. -File.write(ARGV[0], "#{prefix} #{information}") - -listener.join diff --git a/src/plugin.js b/src/plugin.js new file mode 100644 index 00000000..71d2030b --- /dev/null +++ b/src/plugin.js @@ -0,0 +1,381 @@ +import { spawn } from "child_process"; +import fs from "fs"; +import net from "net"; +import os from "os"; +import path from "path"; +import process from "process"; +import url from "url"; +import { resolveConfigFile } from "prettier"; + +// In order to properly parse ruby code, we need to tell the ruby process to +// parse using UTF-8. Unfortunately, the way that you accomplish this looks +// differently depending on your platform. +function getLang() { + const { env, platform } = process; + const envValue = env.LC_ALL || env.LC_CTYPE || env.LANG; + + // If an env var is set for the locale that already includes UTF-8 in the + // name, then assume we can go with that. + if (envValue && envValue.includes("UTF-8")) { + return envValue; + } + + // Otherwise, we're going to guess which encoding to use based on the system. + // This is probably not the best approach in the world, as you could be on + // linux and not have C.UTF-8, but in that case you're probably passing an env + // var for it. This object below represents all of the possible values of + // process.platform per: + // https://nodejs.org/api/process.html#process_process_platform + return { + aix: "C.UTF-8", + android: "C.UTF-8", + cygwin: "C.UTF-8", + darwin: "en_US.UTF-8", + freebsd: "C.UTF-8", + haiku: "C.UTF-8", + linux: "C.UTF-8", + netbsd: "C.UTF-8", + openbsd: "C.UTF-8", + sunos: "C.UTF-8", + win32: ".UTF-8" + }[platform]; +} + +// Return the list of plugins that should be passed to the server process. +function getPlugins(opts) { + const plugins = new Set(); + + const rubyPlugins = opts.rubyPlugins.trim(); + if (rubyPlugins.length > 0) { + rubyPlugins.split(",").forEach((plugin) => plugins.add(plugin.trim())); + } + + if (opts.rubySingleQuote) { + plugins.add("plugin/single_quotes"); + } + + if (opts.trailingComma !== "none") { + plugins.add("plugin/trailing_comma"); + } + + return Array.from(plugins); +} + +// Create a file that will act as a communication mechanism, spawn a parser +// server with that filepath as an argument, then wait for the file to be +// created that will contain the connection information. +export async function spawnServer(opts, killOnExit = true) { + const tmpdir = os.tmpdir(); + const filepath = path.join(tmpdir, `prettier-ruby-parser-${process.pid}.txt`); + + const options = { + env: Object.assign({}, process.env, { LANG: getLang() }), + stdio: ["ignore", "ignore", "inherit"], + detached: true + }; + + if (opts.filepath) { + const prettierConfig = await resolveConfigFile(opts.filepath); + options.cwd = path.dirname(prettierConfig); + } + + const server = spawn( + opts.rubyExecutablePath || "ruby", + [ + url.fileURLToPath(new URL("./server.rb", import.meta.url)), + `--plugins=${getPlugins(opts).join(",")}`, + filepath + ], + options + ); + + server.unref(); + + if (killOnExit) { + process.on("exit", () => { + if (fs.existsSync(filepath)) { + fs.unlinkSync(filepath); + } + + try { + if (server.pid) { + // Kill the server process if it's still running. If we're on windows + // we're going to use the process ID number. If we're not, we're going + // to use the negative process ID to indicate the group. + const pid = process.platform === "win32" ? server.pid : -server.pid; + process.kill(pid); + } + } catch (error) { + // If there's an error killing the process, we're going to ignore it. + } + }); + } + + return new Promise((resolve, reject) => { + const interval = setInterval(() => { + if (fs.existsSync(filepath)) { + const connectionJSON = fs.readFileSync(filepath).toString("utf-8"); + resolve({ + serverPID: server.pid, + connectionFilepath: filepath, + connectionOptions: JSON.parse(connectionJSON) + }); + + clearTimeout(timeout); + clearInterval(interval); + } else if (server.exitCode) { + reject(new Error("Failed to start parse server.")); + clearTimeout(timeout); + clearInterval(interval); + } + }, 100); + + const timeout = setTimeout( + () => { + const message = + "Failed to get connection options from parse server in time. If this happens repeatedly, try increasing the PRETTIER_RUBY_TIMEOUT_MS environment variable beyond 10000."; + + clearInterval(interval); + reject(new Error(message)); + }, + parseInt(process.env.PRETTIER_RUBY_TIMEOUT_MS || "10000", 10) + ); + }); +} + +let connectionOptions; +if (process.env.PRETTIER_RUBY_HOST) { + connectionOptions = JSON.parse(process.env.PRETTIER_RUBY_HOST); +} + +// Formats and sends an asynchronous request to the parser server. +async function parse(parser, source, opts) { + if (!connectionOptions) { + const spawnedServer = await spawnServer(opts); + connectionOptions = spawnedServer.connectionOptions; + } + + return new Promise((resolve, reject) => { + const socket = new net.Socket(); + let chunks = ""; + + socket.on("error", (error) => { + reject(error); + }); + + socket.on("data", (data) => { + chunks += data.toString("utf-8"); + }); + + socket.on("end", () => { + const response = JSON.parse(chunks); + + if (response.error) { + const error = new Error(response.error); + if (response.loc) { + error.loc = response.loc; + } + + reject(error); + } + + resolve(response); + }); + + socket.connect(connectionOptions, () => { + socket.end( + JSON.stringify({ + parser, + source, + maxwidth: opts.printWidth, + tabwidth: opts.tabWidth + }) + ); + }); + }); +} + +// Metadata mostly pulled from linguist and rubocop: +// https://github.com/github/linguist/blob/master/lib/linguist/languages.yml +// https://github.com/rubocop/rubocop/blob/master/spec/rubocop/target_finder_spec.rb +const plugin = { + languages: [ + { + name: "Ruby", + parsers: ["ruby"], + extensions: [ + ".arb", + ".axlsx", + ".builder", + ".eye", + ".fcgi", + ".gemfile", + ".gemspec", + ".god", + ".jb", + ".jbuilder", + ".mspec", + ".opal", + ".pluginspec", + ".podspec", + ".rabl", + ".rake", + ".rb", + ".rbi", + ".rbuild", + ".rbw", + ".rbx", + ".ru", + ".ruby", + ".thor", + ".watchr" + ], + filenames: [ + ".irbrc", + ".pryrc", + ".simplecov", + "Appraisals", + "Berksfile", + "Brewfile", + "Buildfile", + "Capfile", + "Cheffile", + "Dangerfile", + "Deliverfile", + "Fastfile", + "Gemfile", + "Guardfile", + "Jarfile", + "Mavenfile", + "Podfile", + "Puppetfile", + "Rakefile", + "Snapfile", + "Thorfile", + "Vagabondfile", + "Vagrantfile", + "buildfile" + ], + interpreters: ["jruby", "macruby", "rake", "rbx", "ruby"], + linguistLanguageId: 326, + vscodeLanguageIds: ["ruby"] + }, + { + name: "RBS", + parsers: ["rbs"], + extensions: [".rbs"] + }, + { + name: "HAML", + parsers: ["haml"], + extensions: [".haml"], + vscodeLanguageIds: ["haml"] + } + ], + parsers: { + ruby: { + parse(text, opts) { + return parse("ruby", text, opts); + }, + astFormat: "ruby", + hasPragma(text) { + return /^\s*#[^\S\n]*@(?:prettier|format)\s*?(?:\n|$)/m.test(text); + }, + locStart() { + return 0; + }, + locEnd() { + return 0; + } + }, + rbs: { + parse(text, opts) { + return parse("rbs", text, opts); + }, + astFormat: "rbs", + hasPragma(text) { + return /^\s*#[^\S\n]*@(prettier|format)\s*(\n|$)/.test(text); + }, + locStart() { + return 0; + }, + locEnd() { + return 0; + } + }, + haml: { + parse(text, opts) { + return parse("haml", text, opts); + }, + astFormat: "haml", + hasPragma(text) { + return /^\s*-#\s*@(prettier|format)/.test(text); + }, + locStart() { + return 0; + }, + locEnd() { + return 0; + } + } + }, + printers: { + ruby: { + print(path) { + return path.getValue(); + }, + insertPragma(text) { + return `# @format${text.startsWith("#") ? "\n" : "\n\n"}${text}`; + } + }, + rbs: { + print(path) { + return path.getValue(); + }, + insertPragma(text) { + return `# @format${text.startsWith("#") ? "\n" : "\n\n"}${text}`; + } + }, + haml: { + print(path) { + return path.getValue(); + }, + insertPragma(text) { + return `-# @format${text.startsWith("-#") ? "\n" : "\n\n"}${text}`; + } + } + }, + options: { + rubyPlugins: { + type: "string", + category: "Ruby", + default: "", + description: "The comma-separated list of plugins to require.", + since: "3.1.0" + }, + rubySingleQuote: { + type: "boolean", + category: "Ruby", + default: false, + description: + "When double quotes are not necessary for interpolation, prefers the use of single quotes for string literals.", + since: "1.0.0" + }, + rubyExecutablePath: { + type: "string", + category: "Ruby", + default: "ruby", + description: + "The path to the Ruby executable to use to run the formatter.", + since: "3.3.0" + } + }, + defaultOptions: { + printWidth: 80, + tabWidth: 2, + trailingComma: "none", + singleQuote: false + } +}; + +export default plugin; diff --git a/src/plugin.ts b/src/plugin.ts deleted file mode 100644 index 77f47ee5..00000000 --- a/src/plugin.ts +++ /dev/null @@ -1,148 +0,0 @@ -import rubyPrinter from "./ruby/printer"; -import rubyParser from "./ruby/parser"; - -import rbsPrinter from "./rbs/printer"; -import rbsParser from "./rbs/parser"; - -import hamlPrinter from "./haml/printer"; -import hamlParser from "./haml/parser"; - -/* - * metadata mostly pulled from linguist and rubocop: - * https://github.com/github/linguist/blob/master/lib/linguist/languages.yml - * https://github.com/rubocop/rubocop/blob/master/spec/rubocop/target_finder_spec.rb - */ -const plugin = { - languages: [ - { - name: "Ruby", - parsers: ["ruby"], - extensions: [ - ".arb", - ".axlsx", - ".builder", - ".eye", - ".fcgi", - ".gemfile", - ".gemspec", - ".god", - ".jb", - ".jbuilder", - ".mspec", - ".opal", - ".pluginspec", - ".podspec", - ".rabl", - ".rake", - ".rb", - ".rbi", - ".rbuild", - ".rbw", - ".rbx", - ".ru", - ".ruby", - ".thor", - ".watchr" - ], - filenames: [ - ".irbrc", - ".pryrc", - ".simplecov", - "Appraisals", - "Berksfile", - "Brewfile", - "Buildfile", - "Capfile", - "Cheffile", - "Dangerfile", - "Deliverfile", - "Fastfile", - "Gemfile", - "Guardfile", - "Jarfile", - "Mavenfile", - "Podfile", - "Puppetfile", - "Rakefile", - "Snapfile", - "Thorfile", - "Vagabondfile", - "Vagrantfile", - "buildfile" - ], - interpreters: ["jruby", "macruby", "rake", "rbx", "ruby"], - linguistLanguageId: 326, - vscodeLanguageIds: ["ruby"] - }, - { - name: "RBS", - parsers: ["rbs"], - extensions: [".rbs"] - }, - { - name: "HAML", - parsers: ["haml"], - extensions: [".haml"], - vscodeLanguageIds: ["haml"] - } - ], - parsers: { - ruby: rubyParser, - rbs: rbsParser, - haml: hamlParser - }, - printers: { - ruby: rubyPrinter, - rbs: rbsPrinter, - haml: hamlPrinter - }, - options: { - rubyArrayLiteral: { - type: "boolean", - category: "Ruby", - default: true, - description: - "When possible, favor the use of string and symbol array literals.", - since: "1.0.0" - }, - rubyHashLabel: { - type: "boolean", - category: "Ruby", - default: true, - description: - "When possible, uses the shortened hash key syntax, as opposed to hash rockets.", - since: "1.0.0" - }, - rubyModifier: { - type: "boolean", - category: "Ruby", - default: true, - description: - "When it fits on one line, allows if, unless, while, and until statements to use the modifier form.", - since: "1.0.0" - }, - rubySingleQuote: { - type: "boolean", - category: "Ruby", - default: true, - description: - "When double quotes are not necessary for interpolation, prefers the use of single quotes for string literals.", - since: "1.0.0" - }, - rubyToProc: { - type: "boolean", - category: "Ruby", - default: false, - description: - "When possible, convert blocks to the more concise Symbol#to_proc syntax.", - since: "1.0.0" - } - }, - defaultOptions: { - printWidth: 80, - tabWidth: 2, - trailingComma: "none" - } -}; - -export = plugin; diff --git a/src/prettier.ts b/src/prettier.ts deleted file mode 100644 index 4f4f5a82..00000000 --- a/src/prettier.ts +++ /dev/null @@ -1,24 +0,0 @@ -import type * as Prettier from "prettier"; - -type Doc = Prettier.doc.builders.Doc; -type Builders = Omit & { - // Explicitly overwriting the type of the join builder because I don't want to - // have to go around saying "as Doc[]" everywhere. - join: (sep: Doc, docs: Doc | Doc[]) => Prettier.doc.builders.Concat; -}; - -// If `RBPRETTIER` is set, then this is being run from the `Prettier::run` ruby -// method. In that case, we need to pull `prettier` from the node_modules -// directly, as it's been shipped with the gem. -/* istanbul ignore next */ -// eslint-disable-next-line @typescript-eslint/no-var-requires -const source: typeof Prettier = require(process.env.RBPRETTIER - ? "../node_modules/prettier" - : "prettier"); - -// Cramming everything together to make it simpler to pull in all of the right -// utilities and builders. -const builders = source.doc.builders as Builders; -const exported = { ...builders, ...source.doc.utils, ...source.util }; - -export default exported; diff --git a/src/rbs/parser.rb b/src/rbs/parser.rb deleted file mode 100644 index d44ca0e1..00000000 --- a/src/rbs/parser.rb +++ /dev/null @@ -1,98 +0,0 @@ -#!/usr/bin/env ruby - -begin - require 'rbs' -rescue LoadError - # If we can't load the rbs gem, then we're going to provide a shim parser that - # will warn and bail out. - class Prettier::RBSParser - def self.parse(text) - warn( - 'The `rbs` gem could not be loaded. Please ensure you have it ' \ - 'installed and that it is available in the gem path.' - ) - - false - end - end - - return -end - -# Monkey-patch this so that we can get the character positions. -class RBS::Location - def to_json(*args) - { - start: { - line: start_line, - column: start_column - }, - end: { - line: end_line, - column: end_column - }, - start_pos: start_pos, - end_pos: end_pos - }.to_json(*args) - end -end - -# Monkey-patch this so that we get whether or not it needs to be escaped. -class RBS::Types::Function::Param - def to_json(*a) - escaped = name && /\A#{RBS::Parser::KEYWORDS_RE}\z/.match?(name) - { type: type, name: name, escaped: escaped }.to_json(*a) - end -end - -# Monkey-patch this so that we get the name field in the serialized JSON, as -# well as information about whether or not we need to escape it. -class RBS::AST::Members::MethodDefinition - def to_json(*a) - { - member: :method_definition, - name: name, - kind: kind, - types: types, - annotations: annotations, - location: location, - comment: comment, - overload: overload - }.to_json(*a) - end -end - -# Monkey-patch this so that we get the information we need about how to join the -# key-value pairs of the record. -class RBS::Types::Record - def to_json(*a) - fields_extra = {} - - # Explicitly not using Enumerable#to_h here to support Ruby 2.5 - fields.each do |key, type| - if key.is_a?(Symbol) && key.match?(/\A[A-Za-z_][A-Za-z_]*\z/) && - !key.match?(RBS::Parser::KEYWORDS_RE) - fields_extra[key] = { type: type, joiner: :label } - else - fields_extra[key.inspect] = { type: type, joiner: :rocket } - end - end - - { class: :record, fields: fields_extra, location: location }.to_json(*a) - end -end - -# The main parser interface. -module Prettier - class RBSParser - def self.parse(text) - { - declarations: RBS::Parser.parse_signature(text), - location: { - start_pos: 0, - end_pos: text.length - } - } - end - end -end diff --git a/src/rbs/parser.ts b/src/rbs/parser.ts deleted file mode 100644 index 646b1515..00000000 --- a/src/rbs/parser.ts +++ /dev/null @@ -1,32 +0,0 @@ -import type { Plugin, RBS } from "../types"; -import parseSync from "../parser/parseSync"; - -const parser: Plugin.Parser = { - // This function is responsible for taking an input string of text and - // returning to prettier a JavaScript object that is the equivalent AST that - // represents the code stored in that string. We accomplish this by spawning a - // new Ruby process of parser.rb and reading JSON off STDOUT. - parse(text) { - return parseSync("rbs", text); - }, - astFormat: "rbs", - // This function handles checking whether or not the source string has the - // pragma for prettier. This is an optional workflow for incremental adoption. - hasPragma(text) { - return /^\s*#[^\S\n]*@(format|prettier)\s*(\n|$)/.test(text); - }, - // This function is critical for comments and cursor support, and is - // responsible for returning the index of the character within the source - // string that is the beginning of the given node. - locStart(node) { - return node.location.start_pos; - }, - // This function is critical for comments and cursor support, and is - // responsible for returning the index of the character within the source - // string that is the ending of the given node. - locEnd(node) { - return node.location.end_pos; - } -}; - -export default parser; diff --git a/src/rbs/printer.ts b/src/rbs/printer.ts deleted file mode 100644 index f9277261..00000000 --- a/src/rbs/printer.ts +++ /dev/null @@ -1,667 +0,0 @@ -import type { util } from "prettier"; -import type { RequiredKeys, Plugin, RBS } from "../types"; -import prettier from "../prettier"; - -const { group, hardline, indent, makeString, join, line, softline } = prettier; - -// For some lists of entities in the AST, the parser returns them as an unsorted -// object (presumably because Ruby hashes have implicit ordering). We do not -// have that in JavaScript, so here we sort each object by its position in the -// source string. -function getSortedKeys>( - object: T -): (keyof T)[] { - return Object.keys(object).sort( - (left, right) => - object[left].type.location.start_pos - - object[right].type.location.start_pos - ); -} - -// In some cases, we want to just defer to whatever was in the source. -function getSource(node: { location: RBS.Location }, opts: Plugin.Options) { - const { location } = node; - return opts.originalText.slice(location.start_pos, location.end_pos); -} - -const printer: Plugin.PrinterConfig = { - // This is the generic node print function, used to convert any node in the - // AST into its equivalent Doc representation. - print(path, opts, print) { - const node = path.getValue(); - let doc = null; - - if (node.declarations) { - // Prints out the root of the tree, which includes zero or more - // declarations. - return [ - join([hardline, hardline], path.map(print, "declarations")), - hardline - ]; - } - - /* istanbul ignore else */ - if (node.declaration) { - switch (node.declaration) { - // Prints out a type alias, which is a declaration that looks like: - // type foo = String - case "alias": { - doc = group([ - "type ", - node.name, - " =", - indent(group([line, path.call(printType, "type")])) - ]); - break; - } - // Prints out a class declarations, which looks like: - // class Foo end - case "class": { - const nodePath = path as Plugin.Path; - const parts: Plugin.Doc[] = [ - "class ", - printNameAndTypeParams(nodePath, node) - ]; - - if (node.super_class) { - const superPath = nodePath as Plugin.Path< - RequiredKeys - >; - parts.push(" < ", superPath.call(printNameAndArgs, "super_class")); - } - - parts.push(indent(printMembers(nodePath)), hardline, "end"); - doc = group(parts); - break; - } - // Prints out a constant or a global declaration, which looks like: - // Foo: String - // $foo: String - case "constant": - case "global": { - doc = group([node.name, ": ", path.call(printType, "type")]); - break; - } - // Prints out an interface declaration, which looks like: - // interface _Foo end - case "interface": { - const nodePath = path as Plugin.Path; - - doc = group([ - "interface ", - printNameAndTypeParams(nodePath, node), - indent(printMembers(nodePath)), - hardline, - "end" - ]); - break; - } - // Prints out a module declaration, which looks like: - // module Foo end - case "module": { - const nodePath = path as Plugin.Path; - const parts: Plugin.Doc[] = [ - "module ", - printNameAndTypeParams(nodePath, node) - ]; - - if (node.self_types.length > 0) { - parts.push( - " : ", - join(", ", nodePath.map(printNameAndArgs, "self_types")) - ); - } - - parts.push(indent(printMembers(nodePath)), hardline, "end"); - doc = group(parts); - break; - } - /* istanbul ignore next */ - default: - throw new Error(`unknown declaration: ${(node as any).declaration}`); - } - } else if (node.member) { - switch (node.member) { - // Prints out an alias within a declaration, which looks like: - // alias foo bar - // alias self.foo self.bar - case "alias": { - if (node.kind === "singleton") { - doc = ["alias self.", node.new_name, " self.", node.old_name]; - } else { - doc = ["alias ", node.new_name, " ", node.old_name]; - } - break; - } - // Prints out an attr_* meta method, which looks like: - // attr_accessor foo - // attr_reader self.foo() - // attr_writer self.foo(@bar): String - case "attr_accessor": - case "attr_reader": - case "attr_writer": { - const parts: Plugin.Doc[] = [node.member, " "]; - - if (node.kind === "singleton") { - parts.push("self."); - } - - parts.push(node.name); - - if (node.ivar_name === false) { - parts.push("()"); - } else if (node.ivar_name) { - parts.push("(", node.ivar_name, ")"); - } - - parts.push(": ", path.call(printType, "type")); - doc = group(parts); - break; - } - // Prints out a class or instance variable member, which looks like: - // @foo: String - // @@foo: String - case "class_variable": - case "instance_variable": { - doc = group([node.name, ": ", path.call(printType, "type")]); - break; - } - // Prints out a class instance variable member, which looks like: - // self.@foo: String - case "class_instance_variable": { - doc = ["self.", node.name, ": ", path.call(printType, "type")]; - break; - } - // Prints out a mixin, which looks like: - // include Foo - // prepend Foo - // extend Foo - case "include": - case "extend": - case "prepend": { - const nodePath = path as Plugin.Path; - - doc = group([node.member, " ", printNameAndArgs(nodePath)]); - break; - } - case "public": - case "private": { - doc = node.member; - break; - } - case "method_definition": { - const nodePath = path as Plugin.Path; - - doc = printMethodDefinition(nodePath, node); - break; - } - /* istanbul ignore next */ - default: - throw new Error(`unknown member: ${(node as any).member}`); - } - } else { - const ast = JSON.stringify(node, null, 2); - throw new Error(`Unsupported node encountered:\n${ast}`); - } - - // An annotation can be attached to most kinds of nodes, and should be - // printed using %a{}. Certain nodes can't have annotations at all. - if (node.annotations && node.annotations.length > 0) { - const annotationsPath = path as Plugin.Path<{ - annotations: RBS.Annotation[]; - }>; - - doc = [ - join( - hardline, - annotationsPath.map((annotationPath) => { - const annotationNode = annotationPath.getValue(); - - // If there are already braces inside the annotation, then we're - // just going to print out the original string to avoid having to - // escape anything. - if (/[{}]/.test(annotationNode.string)) { - return getSource(annotationNode, opts); - } - - return ["%a{", annotationNode.string, "}"]; - }, "annotations") - ), - hardline, - doc - ]; - } - - // Comments come in as one whole string, so here we split it up into - // multiple lines and then prefix it with the pound sign. - if (node.comment) { - doc = [ - join( - hardline, - node.comment.string - .slice(0, -1) - .split("\n") - .map((segment) => `# ${segment}`) - ), - hardline, - doc - ]; - } - - return doc; - - // Prints out a string in the source, which looks like: - // 'foo' - function printString(node: RBS.Literal) { - // We're going to go straight to the source here, as if we don't then - // we're going to end up with the result of String#inspect, which does - // weird things to escape sequences. - const value = getSource(node, opts); - - // Get the quote that was used in the source and the quote that we want to - // be using. - const originalQuote = value[0]; - const preferredQuote = opts.rubySingleQuote ? "'" : '"'; - - // Determine if we're allowed to change the quote based on whether or not - // there is an escape sequence in the source string. - const quote = node.literal.includes("\\") - ? originalQuote - : preferredQuote; - - return makeString(value.slice(1, -1), quote as util.Quote, false); - } - - // Certain nodes are names with optional arguments attached, as in Array[A]. - // We handle all of that printing centralized here. - function printNameAndArgs(path: Plugin.Path) { - const node = path.getValue(); - - if (node.args.length === 0) { - return node.name; - } - - return group([ - node.name, - "[", - join(", ", path.map(printType, "args")), - "]" - ]); - } - - // This is the big function that prints out any individual type, which can - // look like all kinds of things, listed in the case statement below. - function printType( - path: Plugin.Path, - options?: number | { forceParens: boolean } - ): Plugin.Doc { - const node = path.getValue(); - const forceParens = typeof options === "object" && options.forceParens; - - switch (node.class) { - case "literal": - if (node.literal[0] === '"') { - return printString(node); - } - return node.literal; - case "optional": { - const nodePath = path as Plugin.Path; - - return [ - nodePath.call( - (typePath) => printType(typePath, { forceParens: true }), - "type" - ), - "?" - ]; - } - case "tuple": { - // If we don't have any sub types, we explicitly need the space in - // between the brackets to not confuse the parser. - if (node.types.length === 0) { - return "[ ]"; - } - - const nodePath = path as Plugin.Path; - return group([ - "[", - join(", ", nodePath.map(printType, "types")), - "]" - ]); - } - case "union": { - const nodePath = path as Plugin.Path; - const doc = group( - join([line, "| "], nodePath.map(printType, "types")) - ); - - if (forceParens) { - return ["(", doc, ")"]; - } - - return doc; - } - case "intersection": { - const nodePath = path as Plugin.Path; - const doc = group( - join( - [line, "& "], - nodePath.map( - (typePath) => printType(typePath, { forceParens: true }), - "types" - ) - ) - ); - - if (forceParens) { - return ["(", doc, ")"]; - } - - return doc; - } - case "class_singleton": - return ["singleton(", node.name, ")"]; - case "proc": - return [ - "^", - printMethodSignature(path as Plugin.Path) - ]; - case "record": { - const nodePath = path as Plugin.Path; - const parts: Plugin.Doc[] = []; - - getSortedKeys(node.fields).forEach((field) => { - const fieldParts = []; - - if (node.fields[field].joiner === "rocket") { - fieldParts.push(`${field} => `); - } else { - fieldParts.push(`${field}: `); - } - - fieldParts.push(nodePath.call(printType, "fields", field, "type")); - parts.push(fieldParts); - }); - - return group([ - "{", - indent([line, join([",", line], parts)]), - line, - "}" - ]); - } - case "class_instance": - case "interface": { - const nodePath = path as Plugin.Path; - return printNameAndArgs(nodePath); - } - case "alias": - case "variable": - return node.name; - case "bool": - case "bot": - case "class": - case "instance": - case "nil": - case "self": - case "top": - case "untyped": - case "void": - return node.class; - /* istanbul ignore next */ - default: - throw new Error(`unknown type: ${(node as any).class}`); - } - } - - // Prints out the members of a class, module, or interface. - function printMembers( - path: Plugin.Path - ) { - let lastLine: number | null = null; - const docs: Plugin.Doc[] = []; - - path.each((memberPath) => { - const memberNode = memberPath.getValue(); - - if ( - lastLine !== null && - memberNode.location.start.line - lastLine >= 2 - ) { - docs.push([hardline, hardline]); - } else { - docs.push(hardline); - } - - docs.push(print(memberPath)); - lastLine = memberNode.location.end.line; - }, "members"); - - return docs; - } - - // Prints out the name of a class, interface, or module declaration. - // Additionally loops through each type parameter if there are any and print - // them out joined by commas. Checks for validation and variance. - function printNameAndTypeParams( - path: Plugin.Path, - node: RBS.NameAndTypeParams - ) { - if (node.type_params.params.length === 0) { - return node.name; - } - - const docs = path.map( - (paramPath) => { - const node = paramPath.getValue(); - const parts = []; - - if (node.skip_validation) { - parts.push("unchecked"); - } - - if (node.variance === "covariant") { - parts.push("out"); - } else if (node.variance === "contravariant") { - parts.push("in"); - } - - return join(" ", [...parts, node.name]); - }, - "type_params", - "params" - ); - - return [node.name, "[", join(", ", docs), "]"]; - } - - // Returns an array of printed parameters so that the calling function can - // join them together in whatever way. - function printMethodParams(path: Plugin.Path) { - const node = path.getValue(); - let parts: Plugin.Doc[] = []; - - // required positionals, as in (A) - parts = parts.concat(path.map(printMethodParam, "required_positionals")); - - // optional positionals, as in (?A) - parts = parts.concat( - path.map( - (paramPath) => ["?", printMethodParam(paramPath)], - "optional_positionals" - ) - ); - - // rest positional, as in (*A) - if (node.rest_positionals) { - const restPositionalsPath = path as Plugin.Path< - RequiredKeys - >; - parts.push([ - "*", - restPositionalsPath.call(printMethodParam, "rest_positionals") - ]); - } - - // trailing positionals are required positionals after a rest - parts = parts.concat(path.map(printMethodParam, "trailing_positionals")); - - // required keywords, as in (a: A) - getSortedKeys(node.required_keywords).forEach((name) => { - parts.push([ - name, - ": ", - path.call(printMethodParam, "required_keywords", name) - ]); - }); - - // optional keywords, as in (?a: A) - getSortedKeys(node.optional_keywords).forEach((name) => { - parts.push([ - "?", - name, - ": ", - path.call(printMethodParam, "optional_keywords", name) - ]); - }); - - // rest keyword, as in (**A) - if (node.rest_keywords) { - const restKeywordsPath = path as Plugin.Path< - RequiredKeys - >; - parts.push([ - "**", - restKeywordsPath.call(printMethodParam, "rest_keywords") - ]); - } - - return parts; - - // Prints out a method parameter at a given path. Handles printing out the - // name if there is one (and whether or not it's escaped). - function printMethodParam(path: Plugin.Path) { - const node = path.getValue(); - const parts = [path.call(printType, "type")]; - - if (node.name) { - parts.push(" "); - - if (node.escaped) { - parts.push("`", node.name, "`"); - } else { - parts.push(node.name); - } - } - - return parts; - } - } - - // Prints out a specific method signature, which looks like: - // (T t) -> void - function printMethodSignature( - path: Plugin.Path - ): Plugin.Doc { - const node = path.getValue(); - const parts = []; - - // We won't have a type_params key if we're printing a block - if (node.type_params && node.type_params.length > 0) { - parts.push("[", join(", ", node.type_params), "] "); - } - - const params = path.call(printMethodParams, "type"); - - if (params.length > 0) { - parts.push( - "(", - indent([softline, join([",", line], params)]), - softline, - ") " - ); - } - - if (node.block) { - if (!node.block.required) { - parts.push("?"); - } - - parts.push( - "{", - indent([line, path.call(printMethodSignature, "block")]), - line, - "} " - ); - } - - parts.push( - "-> ", - path.call( - (typePath) => printType(typePath, { forceParens: true }), - "type", - "return_type" - ) - ); - - return group(parts); - } - - // Prints out a method definition, which looks like: - // def t: (T t) -> void - function printMethodDefinition( - path: Plugin.Path, - node: RBS.MethodDefinition - ) { - let typeDocs: Plugin.Doc = path.map(printMethodSignature, "types"); - - if (node.overload) { - typeDocs.push("..."); - } - - if (typeDocs.length === 1) { - typeDocs = [" ", typeDocs[0]]; - } else { - typeDocs = indent(group([line, join([line, "| "], typeDocs)])); - } - - const parts: Plugin.Doc[] = ["def "]; - - if (node.kind === "singleton") { - parts.push("self."); - } else if (node.kind === "singleton_instance") { - parts.push("self?."); - } - - const escaped = isMethodNameEscaped(); - parts.push(escaped ? `\`${node.name}\`` : node.name, ":", typeDocs); - - return group(parts); - - // Determine if a method name is escaped in the original source. - function isMethodNameEscaped() { - const pos = node.location.start_pos + 4; - const name = opts.originalText.slice(pos, pos + 2).trimStart(); - - return name[0] === "`" && name[1] !== ":"; - } - } - }, - // This is an escape-hatch to ignore nodes in the tree. If you have a comment - // that includes this pattern, then the entire node will be ignored and just - // the original source will be printed out. - hasPrettierIgnore(path) { - const node = path.getValue(); - - return ( - (node.comment && node.comment.string.includes("prettier-ignore")) || false - ); - }, - // This function handles adding the format pragma to a source string. This is - // an optional workflow for incremental adoption. - insertPragma(text) { - return `# @format${text[0] === "#" ? "\n" : "\n\n"}${text}`; - } -}; - -export default printer; diff --git a/src/ruby/embed.ts b/src/ruby/embed.ts deleted file mode 100644 index 2df3d380..00000000 --- a/src/ruby/embed.ts +++ /dev/null @@ -1,137 +0,0 @@ -import type { Plugin, Ruby } from "../types"; -import prettier from "../prettier"; -import { literallineWithoutBreakParent } from "../utils"; - -const { - group, - indent, - dedent, - lineSuffix, - mapDoc, - markAsRoot, - stripTrailingHardline -} = prettier; - -const parsers: Record = { - css: "css", - javascript: "babel", - js: "babel", - less: "less", - markdown: "markdown", - ruby: "ruby", - scss: "scss" -}; - -// This function is in here because it handles embedded parser values. I don't -// have a test that exercises it because I'm not sure for which parser it is -// necessary, but since it's in prettier core I'm keeping it here. -/* istanbul ignore next */ -function replaceNewlines(doc: Plugin.Doc) { - return mapDoc(doc, (currentDoc: Plugin.Doc) => - typeof currentDoc === "string" && currentDoc.includes("\n") - ? currentDoc - .split(/(\n)/g) - .map((v, i) => (i % 2 === 0 ? v : literallineWithoutBreakParent)) - : currentDoc - ); -} - -// Returns a number that represents the minimum amount of leading whitespace -// that is present on every line in the given string. So for example if you have -// the following heredoc: -// -// <<~HERE -// my -// content -// here -// HERE -// -// then the return value of this function would be 2. If you indented every line -// of the inner content 2 more spaces then this function would return 4. -function getCommonLeadingWhitespace(content: string) { - const pattern = /^\s+/; - - return content - .split("\n") - .slice(0, -1) - .filter((line) => line.trim().length > 0) - .reduce((minimum, line) => { - const matched = pattern.exec(line); - const length = matched ? matched[0].length : 0; - - return minimum === null ? length : Math.min(minimum, length); - }, content.length); -} - -// Returns a new string with the common whitespace stripped out. Effectively it -// emulates what a squiggly heredoc does in Ruby. -function stripCommonLeadingWhitespace(content: string) { - const lines = content.split("\n"); - const minimum = getCommonLeadingWhitespace(content); - - return lines.map((line) => line.slice(minimum)).join("\n"); -} - -const embed: Plugin.Embed = (path, print, textToDoc) => { - const node = path.getValue(); - - // Currently we only support embedded formatting on heredoc nodes - if (node.type !== "heredoc") { - return null; - } - - // First, ensure that we don't have any interpolation - const { beging, body, ending } = node; - const isSquiggly = beging.body[2] === "~"; - - if (body.some((part) => part.type !== "@tstring_content")) { - return null; - } - - // Next, find the parser associated with this heredoc (if there is one). For - // example, if you use <<~CSS, we'd hook it up to the css parser. - const parser = parsers[beging.body.slice(3).toLowerCase()]; - if (!parser) { - return null; - } - - // Get the content as if it were a source string. - let content = body.map((part) => part.body).join(""); - - // If we're using a squiggly heredoc, then we're going to manually strip off - // the leading whitespace of each line up to the minimum leading whitespace so - // that the embedded parser can handle that for us. - if (isSquiggly) { - content = stripCommonLeadingWhitespace(content); - } - - // Pass that content into the embedded parser. Get back the doc node. - const formatted = [ - literallineWithoutBreakParent, - replaceNewlines(stripTrailingHardline(textToDoc(content, { parser }))) - ]; - - // If we're using a squiggly heredoc, then we can properly handle indentation - // ourselves. - if (isSquiggly) { - return [ - path.call(print, "beging"), - lineSuffix( - dedent([ - indent(markAsRoot(formatted)), - { type: "line", hard: true }, - ending.trim() - ]) - ) - ]; - } - - // Otherwise, we need to just assume it's formatted correctly and return the - // content as it is. - return markAsRoot([ - path.call(print, "beging"), - lineSuffix(group([formatted, literallineWithoutBreakParent, ending.trim()])) - ]); -}; - -export default embed; diff --git a/src/ruby/nodes.ts b/src/ruby/nodes.ts deleted file mode 100644 index ac1e00d5..00000000 --- a/src/ruby/nodes.ts +++ /dev/null @@ -1,249 +0,0 @@ -import type { Plugin, Ruby } from "../types"; - -import { printAlias } from "./nodes/alias"; -import { printAref, printArefField } from "./nodes/aref"; -import { - printArgParen, - printArgs, - printArgsAddBlock, - printArgsAddStar, - printBlockArg -} from "./nodes/args"; -import { printArray, printWord } from "./nodes/arrays"; -import { - printAssign, - printOpAssign, - printVarField, - printVarRef -} from "./nodes/assign"; -import { printBlockVar, printBraceBlock, printDoBlock } from "./nodes/blocks"; -import { - printCall, - printCallContainer, - printMethodAddArg, - printMethodAddBlock -} from "./nodes/calls"; -import { printCase, printWhen } from "./nodes/case"; -import { printClass, printModule, printSClass } from "./nodes/class"; -import { printCommand, printCommandCall } from "./nodes/commands"; -import { - printElse, - printElsif, - printIf, - printIfModifier, - printTernary, - printUnless, - printUnlessModifier -} from "./nodes/conditionals"; -import { - printConstPath, - printConstRef, - printDefined, - printField, - printTopConst -} from "./nodes/constants"; -import { printBreak, printNext, printYield, printYield0 } from "./nodes/flow"; -import { - printAssocNew, - printAssocSplat, - printHash, - printHashContents -} from "./nodes/hashes"; -import { printHeredoc } from "./nodes/heredocs"; -import { printBEGIN, printEND } from "./nodes/hooks"; -import { printInt } from "./nodes/ints"; -import { printLambda } from "./nodes/lambdas"; -import { - printFor, - printUntil, - printUntilModifer, - printWhile, - printWhileModifier -} from "./nodes/loops"; -import { - printMAssign, - printMLHS, - printMLHSAddPost, - printMLHSAddStar, - printMLHSParen, - printMRHS, - printMRHSAddStar, - printMRHSNewFromArgs -} from "./nodes/massign"; -import { - printAccessControl, - printDef, - printSingleLineMethod -} from "./nodes/methods"; -import { - printBinary, - printDot2, - printDot3, - printUnary -} from "./nodes/operators"; -import { - printArgsForward, - printKeywordRestParam, - printParams, - printRestParam -} from "./nodes/params"; -import { - printAryPtn, - printFndPtn, - printHshPtn, - printIn, - printRAssign -} from "./nodes/patterns"; -import { printRegexpLiteral } from "./nodes/regexp"; -import { - printBegin, - printEnsure, - printRedo, - printRescue, - printRescueEx, - printRescueMod, - printRetry -} from "./nodes/rescue"; -import { printReturn, printReturn0 } from "./nodes/return"; -import { - printBodyStmt, - printComment, - printEndContent, - printParen, - printProgram, - printStmts -} from "./nodes/statements"; -import { - printChar, - printDynaSymbol, - printStringConcat, - printStringDVar, - printStringEmbExpr, - printStringLiteral, - printSymbolLiteral, - printXStringLiteral -} from "./nodes/strings"; -import { printSuper, printZSuper } from "./nodes/super"; -import { printUndef } from "./nodes/undef"; - -const nodes: Partial<{ - [_T in Ruby.AnyNode["type"] | "@comment"]: Plugin.Printer; -}> = { - "@__end__": printEndContent, - "@CHAR": printChar, - "@comment": printComment, - "@int": printInt, - access_ctrl: printAccessControl, - alias: printAlias, - aref: printAref, - aref_field: printArefField, - arg_paren: printArgParen, - args: printArgs, - args_add_block: printArgsAddBlock, - args_add_star: printArgsAddStar, - args_forward: printArgsForward, - array: printArray, - aryptn: printAryPtn, - assign: printAssign, - assoc_new: printAssocNew, - assoc_splat: printAssocSplat, - assoclist_from_args: printHashContents, - bare_assoc_hash: printHashContents, - BEGIN: printBEGIN, - begin: printBegin, - binary: printBinary, - blockarg: printBlockArg, - block_var: printBlockVar, - bodystmt: printBodyStmt, - brace_block: printBraceBlock, - break: printBreak, - call: printCall, - case: printCase, - class: printClass, - command: printCommand, - command_call: printCommandCall, - const_path_field: printConstPath, - const_path_ref: printConstPath, - const_ref: printConstRef, - def: printDef, - defs: printDef, - defsl: printSingleLineMethod, - defined: printDefined, - do_block: printDoBlock, - dot2: printDot2, - dot3: printDot3, - dyna_symbol: printDynaSymbol, - else: printElse, - elsif: printElsif, - END: printEND, - ensure: printEnsure, - fcall: printCallContainer, - fndptn: printFndPtn, - field: printField, - for: printFor, - hash: printHash, - heredoc: printHeredoc, - hshptn: printHshPtn, - if: printIf, - ifop: printTernary, - if_mod: printIfModifier, - in: printIn, - kwrest_param: printKeywordRestParam, - lambda: printLambda, - massign: printMAssign, - method_add_arg: printMethodAddArg, - method_add_block: printMethodAddBlock, - mlhs: printMLHS, - mlhs_add_post: printMLHSAddPost, - mlhs_add_star: printMLHSAddStar, - mlhs_paren: printMLHSParen, - mrhs: printMRHS, - mrhs_add_star: printMRHSAddStar, - mrhs_new_from_args: printMRHSNewFromArgs, - module: printModule, - next: printNext, - opassign: printOpAssign, - params: printParams, - paren: printParen, - program: printProgram, - rassign: printRAssign, - redo: printRedo, - regexp_literal: printRegexpLiteral, - rescue: printRescue, - rescue_ex: printRescueEx, - rescue_mod: printRescueMod, - rest_param: printRestParam, - retry: printRetry, - return: printReturn, - return0: printReturn0, - sclass: printSClass, - stmts: printStmts, - string_concat: printStringConcat, - string_dvar: printStringDVar, - string_embexpr: printStringEmbExpr, - string_literal: printStringLiteral, - super: printSuper, - symbol_literal: printSymbolLiteral, - top_const_field: printTopConst, - top_const_ref: printTopConst, - unary: printUnary, - undef: printUndef, - unless: printUnless, - unless_mod: printUnlessModifier, - until: printUntil, - until_mod: printUntilModifer, - var_alias: printAlias, - var_field: printVarField, - var_ref: printVarRef, - vcall: printCallContainer, - when: printWhen, - while: printWhile, - while_mod: printWhileModifier, - word: printWord, - xstring_literal: printXStringLiteral, - yield: printYield, - yield0: printYield0, - zsuper: printZSuper -}; - -export default nodes; diff --git a/src/ruby/nodes/alias.ts b/src/ruby/nodes/alias.ts deleted file mode 100644 index 9fd23d34..00000000 --- a/src/ruby/nodes/alias.ts +++ /dev/null @@ -1,70 +0,0 @@ -import type { Plugin, Ruby } from "../../types"; -import prettier from "../../prettier"; - -const { addTrailingComment, align, group, hardline, line } = prettier; - -// The `alias` keyword is used to make a method respond to another name as well -// as the current one. For example, to get the method `foo` to also respond to -// `bar`, you would: -// -// alias bar foo -// -// Now, in the current context you can call `bar` and it will execute the `foo` -// method. -// -// When you're aliasing two methods, you can either provide bare words (like the -// example above) or you can provide symbols (note that this includes dynamic -// symbols like :"foo-#{bar}-baz"). In general, to be consistent with the ruby -// style guide, we prefer bare words: -// -// https://github.com/rubocop-hq/ruby-style-guide#alias-method-lexically -// -// The `alias` node contains two children. The left and right align with the -// arguments passed to the keyword. So, for the above example the left would be -// the symbol literal `bar` and the right could be the symbol literal `foo`. -export const printAlias: Plugin.Printer = ( - path, - opts, - print -) => { - const keyword = "alias "; - - // In general, return the printed doc of the argument at the provided index. - // Special handling is given for symbol literals that are not bare words, as - // we convert those into bare words by just pulling out the ident node. - const printAliasArg = ( - argPath: Plugin.Path< - Ruby.Backref | Ruby.DynaSymbol | Ruby.GVar | Ruby.SymbolLiteral - > - ) => { - const argNode = argPath.getValue(); - - if (argNode.type === "symbol_literal") { - // If we're going to descend into the symbol literal to grab out the ident - // node, then we need to make sure we copy over any comments as well, - // otherwise we could accidentally skip printing them. - if (argNode.comments) { - argNode.comments.forEach((comment) => { - addTrailingComment(argNode.body[0], comment); - }); - } - - return argPath.call(print, "body", 0); - } - - return print(argPath); - }; - - return group([ - keyword, - path.call(printAliasArg, "body", 0), - group( - align(keyword.length, [ - // If the left child has any comments, then we need to explicitly break - // this into two lines - path.getValue().body[0].comments ? hardline : line, - path.call(printAliasArg, "body", 1) - ]) - ) - ]); -}; diff --git a/src/ruby/nodes/aref.ts b/src/ruby/nodes/aref.ts deleted file mode 100644 index fdc855ca..00000000 --- a/src/ruby/nodes/aref.ts +++ /dev/null @@ -1,56 +0,0 @@ -import type { Plugin, Ruby } from "../../types"; -import prettier from "../../prettier"; - -const { group, indent, join, line, softline } = prettier; - -// `aref` nodes are when you're pulling a value out of a collection at a -// specific index. Put another way, it's any time you're calling the method -// `#[]`. -// -// The nodes usually contains two children, details below in the -// `printArefField` function. In some cases, you don't necessarily have the -// second child node, because you can call procs with a pretty esoteric syntax. -// In the following example, you wouldn't have a second child, and `"foo"` would -// be the first child. -// -// foo[] -// -export const printAref: Plugin.Printer = (path, opts, print) => { - const indexNode = path.getValue().body[1]; - - if (!indexNode) { - return [path.call(print, "body", 0), "[]"]; - } - - return printArefField(path, opts, print); -}; - -// `aref_field` nodes are for assigning values into collections at specific -// indices. Put another way, it's any time you're calling the method `#[]=`. -// The `aref_field` node itself is just the left side of the assignment, and -// they're always wrapped in `assign` nodes. -// -// The nodes always contain two children, the name of the array (usually a -// `vcall` node and the index (usually an `args_add_block` node). The -// `args_add_block` is one of a couple nodes that has special handling where its -// printed form is actually an array to make joining easier. -// -// So in the following example, `"foo"` is the array and `["bar"]` is the index. -// -// foo[bar] = baz -// -export const printArefField: Plugin.Printer = ( - path, - opts, - print -) => { - const [printedArray, printedIndex] = path.map(print, "body"); - - return group([ - printedArray, - "[", - indent([softline, join([",", line], printedIndex)]), - softline, - "]" - ]); -}; diff --git a/src/ruby/nodes/args.ts b/src/ruby/nodes/args.ts deleted file mode 100644 index 49a70758..00000000 --- a/src/ruby/nodes/args.ts +++ /dev/null @@ -1,205 +0,0 @@ -import type { Plugin, Ruby } from "../../types"; -import prettier from "../../prettier"; - -import { getTrailingComma } from "../../utils"; -import toProc from "../toProc"; - -const { group, ifBreak, indent, join, line, softline } = prettier; - -const noTrailingComma = ["command", "command_call"]; - -function getArgParenTrailingComma(node: Ruby.Args | Ruby.ArgsAddBlock) { - // If we have a block, then we don't want to add a trailing comma. - if (node.type === "args_add_block" && node.body[1]) { - return ""; - } - - // If we only have one argument and that first argument necessitates that we - // skip putting a comma (because it would interfere with parsing the argument) - // then we don't want to add a trailing comma. - if (node.body.length === 1 && noTrailingComma.includes(node.body[0].type)) { - return ""; - } - - return ifBreak(",", ""); -} - -export const printArgParen: Plugin.Printer = ( - path, - opts, - print -) => { - const argsNode = path.getValue().body[0]; - - if (argsNode === null) { - return ""; - } - - // Here we can skip the entire rest of the method by just checking if it's - // an args_forward node, as we're guaranteed that there are no other arg - // nodes. - if (argsNode.type === "args_forward") { - return group([ - "(", - indent([softline, path.call(print, "body", 0)]), - softline, - ")" - ]); - } - - // Now here we return a doc that represents the whole grouped expression, - // including the surrouding parentheses. - return group([ - "(", - indent([ - softline, - join([",", line], path.call(print, "body", 0)), - getTrailingComma(opts) ? getArgParenTrailingComma(argsNode) : "" - ]), - softline, - ")" - ]); -}; - -export const printArgs: Plugin.Printer = ( - path, - { rubyToProc }, - print -) => { - const args = path.map(print, "body"); - - // Don't bother trying to do any kind of fancy toProc transform if the - // option is disabled. - if (rubyToProc) { - let blockNode = null; - - // Look up the chain to see if these arguments are contained within a - // method_add_block node, and if they are that that node has a block - // associated with it. If it does, we're going to attempt to transform it - // into the to_proc shorthand and add it to the list of arguments. - [1, 2, 3].find((parent) => { - const parentNode = path.getParentNode(parent); - blockNode = - parentNode && - parentNode.type === "method_add_block" && - parentNode.body[1]; - - return blockNode; - }); - - const proc = blockNode && toProc(path, blockNode); - - // If we have a successful to_proc transformation, but we're part of an - // aref node, that means it's something to the effect of - // - // foo[:bar].each(&:to_s) - // - // In this case we need to just return regular arguments, otherwise we - // would end up putting &:to_s inside the brackets accidentally. - if (proc && path.getParentNode(1).type !== "aref") { - args.push(proc); - } - } - - return args; -}; - -export const printArgsAddBlock: Plugin.Printer = ( - path, - opts, - print -) => { - const node = path.getValue(); - const blockNode = node.body[1]; - - const parts = path.call(print, "body", 0) as Plugin.Doc[]; - - if (blockNode) { - let blockDoc = path.call(print, "body", 1) as any; - - if (!(blockNode.comments || []).some(({ leading }) => leading)) { - // If we don't have any leading comments, we can just prepend the - // operator. - blockDoc = ["&", blockDoc]; - } else { - // If we have a method call like: - // - // foo( - // # comment - // &block - // ) - // - // then we need to make sure we don't accidentally prepend the operator - // before the comment. - // - // In prettier >= 2.3.0, the comments are printed as an array before the - // content. I don't love this kind of reflection, but it's the simplest - // way at the moment to get this right. - blockDoc = blockDoc[0].concat(["&", blockDoc[1]], blockDoc.slice(2)); - } - - parts.push(blockDoc); - } - - return parts; -}; - -export const printArgsAddStar: Plugin.Printer = ( - path, - opts, - print -) => { - let docs: Plugin.Doc[] = []; - - path.each((argPath, argIndex) => { - const doc = print(argPath) as Plugin.Doc[]; - - // If it's the first child, then it's an array of args, so we're going to - // concat that onto the existing docs if there are any. - if (argIndex === 0) { - if (doc.length > 0) { - docs = docs.concat(doc); - } - return; - } - - // If it's after the splat, then it's an individual arg, so we're just going - // to push it onto the array. - if (argIndex !== 1) { - docs.push(doc); - return; - } - - // If we don't have any leading comments, we can just prepend the operator. - const argsNode = argPath.getValue() as Ruby.AnyNode; - if (!(argsNode.comments || []).some(({ leading }) => leading)) { - docs.push(["*", doc]); - return; - } - - // If we have an array like: - // - // [ - // # comment - // *values - // ] - // - // then we need to make sure we don't accidentally prepend the operator - // before the comment(s). - // - // In prettier >= 2.3.0, the comments are printed as an array before the - // content. I don't love this kind of reflection, but it's the simplest way - // at the moment to get this right. - docs.push((doc[0] as Plugin.Doc[]).concat(["*", doc[1]], doc.slice(2))); - }, "body"); - - return docs; -}; - -export const printBlockArg: Plugin.Printer = ( - path, - opts, - print -) => { - return ["&", path.call(print, "body", 0)]; -}; diff --git a/src/ruby/nodes/arrays.ts b/src/ruby/nodes/arrays.ts deleted file mode 100644 index d77f2f77..00000000 --- a/src/ruby/nodes/arrays.ts +++ /dev/null @@ -1,157 +0,0 @@ -import type { Plugin, Ruby } from "../../types"; -import prettier from "../../prettier"; -import { getTrailingComma, printEmptyCollection } from "../../utils"; - -const { group, ifBreak, indent, join, line, softline } = prettier; - -// Checks that every argument within this args node is a string_literal node -// that has no spaces or interpolations. This means we're dealing with an array -// that looks something like: -// -// ['a', 'b', 'c'] -// -function isStringArray(args: Ruby.Args | Ruby.ArgsAddStar) { - return ( - args.body.length > 1 && - args.body.every((arg) => { - // We want to verify that every node inside of this array is a string - // literal. We also want to make sure none of them have comments attached. - if (arg.type !== "string_literal" || arg.comments) { - return false; - } - - // If the string has multiple parts (meaning plain string content but also - // interpolated content) then we know it's not a simple string. - if (arg.body.length !== 1) { - return false; - } - - const part = arg.body[0]; - - // If the only part of this string is not @tstring_content then it's - // interpolated, so again we can return false. - if (part.type !== "@tstring_content") { - return false; - } - - // Finally, verify that the string doesn't contain a space, an escape - // character, or brackets so that we know it can be put into a string - // literal array. - return !/[\s\\[\]]/.test(part.body); - }) - ); -} - -// Checks that every argument within this args node is a symbol_literal node (as -// opposed to a dyna_symbol) so it has no interpolation. This means we're -// dealing with an array that looks something like: -// -// [:a, :b, :c] -// -function isSymbolArray(args: Ruby.Args | Ruby.ArgsAddStar) { - return ( - args.body.length > 1 && - args.body.every((arg) => arg.type === "symbol_literal" && !arg.comments) - ); -} - -// Prints out a word that is a part of a special array literal that accepts -// interpolation. The body is an array of either plain strings or interpolated -// expressions. -export const printWord: Plugin.Printer = (path, opts, print) => { - return path.map(print, "body"); -}; - -// Prints out a special array literal. Accepts the parts of the array literal as -// an argument, where the first element of the parts array is a string that -// contains the special start. -function printArrayLiteral(start: string, parts: Plugin.Doc[]) { - return group([ - start, - "[", - indent([softline, join(line, parts)]), - softline, - "]" - ]); -} - -const arrayLiteralStarts = { - qsymbols: "%i", - qwords: "%w", - symbols: "%I", - words: "%W" -}; - -// An array node is any literal array in Ruby. This includes all of the special -// array literals as well as regular arrays. If it is a special array literal -// then it will have one child that represents the special array, otherwise it -// will have one child that contains all of the elements of the array. -export const printArray: Plugin.Printer = (path, opts, print) => { - const array = path.getValue(); - const args = array.body[0]; - - // If there is no inner arguments node, then we're dealing with an empty - // array, so we can go ahead and return. - if (args === null) { - return printEmptyCollection(path, opts, "[", "]"); - } - - // If we don't have a regular args node at this point then we have a special - // array literal. In that case we're going to print out the body (which will - // return to us an array with the first one being the start of the array) and - // send that over to the printArrayLiteral function. - if (args.type !== "args" && args.type !== "args_add_star") { - return path.call( - (arrayPath) => - printArrayLiteral( - arrayLiteralStarts[args.type], - arrayPath.map(print, "body") - ), - "body", - 0 - ); - } - - if (opts.rubyArrayLiteral) { - // If we have an array that contains only simple string literals with no - // spaces or interpolation, then we're going to print a %w array. - if (isStringArray(args)) { - const printString = (stringPath: Plugin.Path) => - stringPath.call(print, "body", 0); - - const nodePath = path as Plugin.Path<{ - body: [{ body: Ruby.StringLiteral[] }]; - }>; - const parts = nodePath.map(printString, "body", 0, "body"); - - return printArrayLiteral("%w", parts); - } - - // If we have an array that contains only simple symbol literals with no - // interpolation, then we're going to print a %i array. - if (isSymbolArray(args)) { - const printSymbol = (symbolPath: Plugin.Path) => - symbolPath.call(print, "body", 0); - - const nodePath = path as Plugin.Path<{ - body: [{ body: Ruby.SymbolLiteral[] }]; - }>; - const parts = nodePath.map(printSymbol, "body", 0, "body"); - - return printArrayLiteral("%i", parts); - } - } - - // Here we have a normal array of any type of object with no special literal - // types or anything. - return group([ - "[", - indent([ - softline, - join([",", line], path.call(print, "body", 0)), - getTrailingComma(opts) ? ifBreak(",", "") : "" - ]), - softline, - "]" - ]); -}; diff --git a/src/ruby/nodes/assign.ts b/src/ruby/nodes/assign.ts deleted file mode 100644 index 30918557..00000000 --- a/src/ruby/nodes/assign.ts +++ /dev/null @@ -1,49 +0,0 @@ -import type { Plugin, Ruby } from "../../types"; -import prettier from "../../prettier"; -import { skipAssignIndent } from "../../utils"; - -const { group, indent, join, line } = prettier; - -export const printAssign: Plugin.Printer = (path, opts, print) => { - const [, valueNode] = path.getValue().body; - const [targetDoc, valueDoc] = path.map(print, "body"); - - let rightSideDoc = valueDoc; - - // If the right side of this assignment is a multiple assignment, then we need - // to join it together with commas. - if (["mrhs_add_star", "mrhs_new_from_args"].includes(valueNode.type)) { - rightSideDoc = group(join([",", line], valueDoc)); - } - - if (skipAssignIndent(valueNode)) { - return group([targetDoc, " = ", rightSideDoc]); - } - - return group([targetDoc, " =", indent([line, rightSideDoc])]); -}; - -export const printOpAssign: Plugin.Printer = ( - path, - opts, - print -) => { - return group([ - path.call(print, "body", 0), - " ", - path.call(print, "body", 1), - indent([line, path.call(print, "body", 2)]) - ]); -}; - -export const printVarField: Plugin.Printer = ( - path, - opts, - print -) => { - return path.getValue().body ? path.call(print, "body", 0) : ""; -}; - -export const printVarRef: Plugin.Printer = (path, opts, print) => { - return path.call(print, "body", 0); -}; diff --git a/src/ruby/nodes/blocks.ts b/src/ruby/nodes/blocks.ts deleted file mode 100644 index 9a3f315c..00000000 --- a/src/ruby/nodes/blocks.ts +++ /dev/null @@ -1,119 +0,0 @@ -import type { Plugin, Ruby } from "../../types"; -import prettier from "../../prettier"; -import { hasAncestor } from "../../utils"; - -const { breakParent, group, ifBreak, indent, join, removeLines, softline } = - prettier; - -export const printBlockVar: Plugin.Printer = ( - path, - opts, - print -) => { - const parts = ["|", removeLines(path.call(print, "body", 0))]; - - // The second part of this node is a list of optional block-local variables - if (path.getValue().body[1]) { - parts.push("; ", join(", ", path.map(print, "body", 1))); - } - - parts.push("| "); - return parts; -}; - -// You have to go through the main print function if you could potentially have -// comments attached. So we're doing this weird reflection on the printed docs -// to retroactively change the printed keyword depending on if we're using -// braces or not. Ideally we wouldn't do this, we would instead do this -// reflection in the child printer, but this keeps the logic to just this file -// and contains it, so keeping it here for now. -function printBlockBeging( - path: Plugin.Path, - print: Plugin.Print, - useBraces: boolean -) { - let docs = print(path); - const doc = useBraces ? "{" : "do"; - - if (Array.isArray(docs)) { - docs[1] = doc; - } else { - docs = doc; - } - - return docs; -} - -type Block = Ruby.BraceBlock | Ruby.DoBlock; - -function printBlock(braces: boolean): Plugin.Printer { - return function printBlockWithBraces(path, opts, print) { - const [variables, statements] = path.getValue().body; - const stmts = - statements.type === "stmts" ? statements.body : statements.body[0].body; - - let doBlockBody: Plugin.Doc = ""; - if ( - stmts.length !== 1 || - stmts[0].type !== "void_stmt" || - stmts[0].comments - ) { - doBlockBody = indent([softline, path.call(print, "body", 1)]); - } - - // If this block is nested underneath a command or command_call node, then - // we can't use `do...end` because that will get associated with the parent - // node as opposed to the current node (because of the difference in - // operator precedence). Instead, we still use a multi-line format but - // switch to using braces instead. - const useBraces = braces && hasAncestor(path, ["command", "command_call"]); - - const doBlock = [ - " ", - path.call( - (begingPath) => printBlockBeging(begingPath, print, useBraces), - "beging" - ), - variables ? [" ", path.call(print, "body", 0)] : "", - doBlockBody, - [softline, useBraces ? "}" : "end"] - ]; - - // We can hit this next pattern if within the block the only statement is a - // comment. - if ( - stmts.length === 1 && - stmts[0].type === "void_stmt" && - stmts[0].comments - ) { - return [breakParent, doBlock]; - } - - const blockReceiver = path.getParentNode().body[0]; - - // If the parent node is a command node, then there are no parentheses - // around the arguments to that command, so we need to break the block - if (["command", "command_call"].includes(blockReceiver.type)) { - return [breakParent, doBlock]; - } - - const hasBody = stmts.some(({ type }) => type !== "void_stmt"); - const braceBlock = [ - " ", - path.call( - (begingPath) => printBlockBeging(begingPath, print, true), - "beging" - ), - hasBody || variables ? " " : "", - variables ? path.call(print, "body", 0) : "", - path.call(print, "body", 1), - hasBody ? " " : "", - "}" - ]; - - return group(ifBreak(doBlock, braceBlock)); - }; -} - -export const printBraceBlock = printBlock(true); -export const printDoBlock = printBlock(false); diff --git a/src/ruby/nodes/calls.ts b/src/ruby/nodes/calls.ts deleted file mode 100644 index 51502e01..00000000 --- a/src/ruby/nodes/calls.ts +++ /dev/null @@ -1,329 +0,0 @@ -import type { Plugin, Ruby } from "../../types"; -import prettier from "../../prettier"; -import { makeCall, noIndent } from "../../utils"; -import toProc from "../toProc"; - -const { group, hardline, ifBreak, indent, join, softline } = prettier; -const chained = ["call", "method_add_arg", "method_add_block"]; - -function hasLeadingComments(node: Ruby.AnyNode) { - return node.comments?.some(({ leading }) => leading); -} - -// We decorate these nodes with a bunch of extra stuff so that we can display -// nice method chains. -type Chain = { - chain?: number; - callChain?: number; - breakDoc?: Plugin.Doc[]; - firstReceiverType?: string; -}; - -type ChainedCall = Ruby.Call & Chain; -type ChainedMethodAddArg = Ruby.MethodAddArg & Chain; -type ChainedMethodAddBlock = Ruby.MethodAddBlock & Chain; - -export const printCall: Plugin.Printer = (path, opts, print) => { - const node = path.getValue(); - const [receiverNode, , messageNode] = node.body; - - const receiverDoc = path.call(print, "body", 0); - const operatorDoc = makeCall(path, opts, print); - - // You can call lambdas with a special syntax that looks like func.(*args). - // In this case, "call" is returned for the 3rd child node. We don't alter - // call syntax so if `call` is implicit, we don't print it out. - const messageDoc = messageNode === "call" ? "" : path.call(print, "body", 2); - - // Create some arrays that are going to represent each side of our call. - let leftSideDoc = [receiverDoc]; - let rightSideDoc = [operatorDoc, messageDoc]; - - // If there are leading comments on the right side of the call, then it means - // we have a structure where there's a receiver and an operator together, then - // a comment, then the message, as in: - // - // foo. - // # comment - // baz - // - // In the case we need to group the receiver and the operator together or - // we'll end up with a syntax error. - const operatorIsTrailing = - messageNode !== "call" && hasLeadingComments(messageNode); - - if (operatorIsTrailing) { - leftSideDoc = [receiverDoc, operatorDoc]; - rightSideDoc = [messageDoc]; - } - - // For certain left sides of the call nodes, we want to attach directly to - // the } or end. - if (noIndent.includes(receiverNode.type)) { - return [leftSideDoc, rightSideDoc]; - } - - if ( - receiverNode.type === "call" && - receiverNode.body[2] !== "call" && - receiverNode.body[2].body === "where" && - messageDoc === "not" - ) { - // This is very specialized behavior wherein we group .where.not calls - // together because it looks better. For more information, see - // https://github.com/prettier/plugin-ruby/issues/862. - } else { - // Otherwise, we're going to put a line node into the right side doc. - rightSideDoc.unshift(receiverNode.comments ? hardline : softline); - } - - // Get a reference to the parent node so we can check if we're inside a chain - const parentNode = path.getParentNode(); - - // If our parent node is a chained node then we're not going to group the - // right side of the expression, as we want to have a nice multi-line layout. - if (chained.includes(parentNode.type) && !node.comments) { - parentNode.chain = (node.chain || 0) + 1; - parentNode.callChain = (node.callChain || 0) + 1; - parentNode.firstReceiverType = node.firstReceiverType || receiverNode.type; - - // Here we're going to determine what doc nodes to send up to the parent - // node to represent when we're in the multi-line form. - let breakDocLHS: Plugin.Doc[]; - - if (node.breakDoc && operatorIsTrailing) { - // Here we already have a child node that has passed up its - // representation. In this case node.breakDoc represents the receiver - // without any lines inserted. With regard to this node, it means it's - // everything up until the operator. So we're just going to append the - // operator. - breakDocLHS = node.breakDoc.concat(operatorDoc); - } else if (node.breakDoc) { - // Here we don't need a trailing operator, so we're just going to use the - // existing node.breakDoc. The operator will be a part of the rightSideDoc - // variable. - breakDocLHS = node.breakDoc; - } else { - // Here we're at the bottom of the chain, so there's no representation yet - // for the receiver. So we're just going to pass up the left side. - breakDocLHS = leftSideDoc; - } - - parentNode.breakDoc = breakDocLHS.concat(rightSideDoc); - } - - // If we're at the top of a chain, then we're going to print out a nice - // multi-line layout if this doesn't break into multiple lines. - if ( - !chained.includes(parentNode.type) && - (node.chain || 0) >= 3 && - node.breakDoc - ) { - return ifBreak(group(indent(node.breakDoc.concat(rightSideDoc))), [ - leftSideDoc, - group(rightSideDoc) - ]); - } - - return group([leftSideDoc, group(indent(rightSideDoc))]); -}; - -export const printMethodAddArg: Plugin.Printer = ( - path, - opts, - print -) => { - const node = path.getValue(); - - const [methodNode, argNode] = node.body; - const [methodDoc, argsDoc] = path.map(print, "body") as [ - Plugin.Doc, - Plugin.Doc[] - ]; - - // You can end up here if you have a method with a ? ending, presumably - // because the parser knows that it cannot be a local variable. You can also - // end up here if you are explicitly using an empty set of parentheses. - if (argsDoc.length === 0) { - // If you're using an explicit set of parentheses on something that looks - // like a constant, then we need to match that in order to maintain valid - // Ruby. For example, you could do something like Foo(), on which we would - // need to keep the parentheses to make it look like a method call. - if (methodNode.type === "fcall" && methodNode.body[0].type === "@const") { - return [methodDoc, "()"]; - } - - // If you're using an explicit set parentheses with the special call syntax, - // then we need to explicitly print out an extra set of parentheses. For - // example, if you call something like Foo.new.() (implicitly calling the - // #call method on a new instance of the Foo class), then we have to print - // out those parentheses, otherwise we'll end up with Foo.new. - if (methodNode.type === "call" && methodNode.body[2] === "call") { - return [methodDoc, "()"]; - } - - return methodDoc; - } - - // This case will ONLY be hit if we can successfully turn the block into a - // to_proc call. In that case, we just explicitly add the parens around it. - if (argNode.type === "args" && argsDoc.length > 0) { - return [methodDoc, "(", ...argsDoc, ")"]; - } - - // Get a reference to the parent node so we can check if we're inside a chain - const parentNode = path.getParentNode(); - - // If our parent node is a chained node then we're not going to group the - // right side of the expression, as we want to have a nice multi-line layout. - if (chained.includes(parentNode.type) && !node.comments) { - parentNode.chain = (node.chain || 0) + 1; - parentNode.breakDoc = (node.breakDoc || [methodDoc]).concat(argsDoc); - parentNode.firstReceiverType = node.firstReceiverType; - } - - // This is the threshold at which we will start to try to make a nicely - // indented call chain. For the most part, it's always 3. - let threshold = 3; - - // Here, we have very specialized behavior where if we're within a sig block, - // then we're going to assume we're creating a Sorbet type signature. In that - // case, we really want the threshold to be lowered to 2 so that we create - // method chains off of any two method calls within the block. For more - // details, see - // https://github.com/prettier/plugin-ruby/issues/863. - let sigBlock = path.getParentNode(2); - if (sigBlock) { - // If we're at a do_block, then we want to go one more level up. This is - // because do_blocks have bodystmt nodes instead of just stmt nodes. - if (sigBlock.type === "do_block") { - sigBlock = path.getParentNode(3); - } - - if ( - sigBlock.type === "method_add_block" && - sigBlock.body[1] && - sigBlock.body[0].type === "method_add_arg" && - sigBlock.body[0].body[0].type === "fcall" && - sigBlock.body[0].body[0].body[0].body === "sig" - ) { - threshold = 2; - } - } - - // If we're at the top of a chain, then we're going to print out a nice - // multi-line layout if this doesn't break into multiple lines. - if ( - !chained.includes(parentNode.type) && - (node.chain || 0) >= threshold && - node.breakDoc - ) { - // This is pretty specialized behavior. Basically if we're at the top of a - // chain but we've only had method calls without arguments and now we have - // arguments, then we're effectively trying to call a method with arguments - // that is nested under a bunch of stuff. So we group together to first part - // to make it so just the arguments break. This looks like, for example: - // - // config.action_dispatch.rescue_responses.merge!( - // 'ActiveRecord::ConnectionTimeoutError' => :service_unavailable, - // 'ActiveRecord::QueryCanceled' => :service_unavailable - // ) - // - if (node.callChain === node.chain) { - return [group(indent(node.breakDoc)), group(argsDoc)]; - } - - return ifBreak(group(indent(node.breakDoc.concat(argsDoc))), [ - methodDoc, - argsDoc - ]); - } - - // If there are already parentheses, then we can just use the doc that's - // already printed. - if (argNode.type == "arg_paren") { - return [methodDoc, argsDoc]; - } - - return [methodDoc, " ", join(", ", argsDoc), " "]; -}; - -export const printMethodAddBlock: Plugin.Printer = ( - path, - opts, - print -) => { - const node = path.getValue(); - - const [callNode, blockNode] = node.body; - const [callDoc, blockDoc] = path.map(print, "body"); - - // Don't bother trying to do any kind of fancy toProc transform if the option - // is disabled. - if (opts.rubyToProc) { - const proc = toProc(path, blockNode); - - if (proc && callNode.type === "call") { - return group([ - path.call(print, "body", 0), - "(", - indent([softline, proc]), - [softline, ")"] - ]); - } - - if (proc) { - return path.call(print, "body", 0); - } - } - - // Get a reference to the parent node so we can check if we're inside a chain - const parentNode = path.getParentNode(); - - // If our parent node is a chained node then we're not going to group the - // right side of the expression, as we want to have a nice multi-line layout. - if (chained.includes(parentNode.type)) { - parentNode.chain = (node.chain || 0) + 1; - parentNode.breakDoc = (node.breakDoc || [callDoc]).concat(blockDoc); - parentNode.firstReceiverType = node.firstReceiverType; - } - - // If we're at the top of a chain, then we're going to print out a nice - // multi-line layout if this doesn't break into multiple lines. - if ( - !chained.includes(parentNode.type) && - (node.chain || 0) >= 3 && - node.breakDoc - ) { - // This is pretty specialized behavior. Basically if we're at the top of a - // chain but we've only had method calls without arguments and now we have - // a method call with a block, then we're effectively trying to call a - // method with arguments that is nested under a bunch of stuff. So we group - // together to first part to make it so just the block breaks. This looks - // like, for example: - // - // Rails.application.routes.draw do - // root 'articles#index' - // resources :articles - // end - // - if (node.callChain === node.chain) { - return [group(indent(node.breakDoc)), group(blockDoc)]; - } - - return ifBreak(group(indent(node.breakDoc.concat(blockDoc))), [ - callDoc, - blockDoc - ]); - } - - return [callDoc, blockDoc]; -}; - -export const printCallContainer: Plugin.Printer = ( - path, - opts, - print -) => { - return path.call(print, "body", 0); -}; diff --git a/src/ruby/nodes/case.ts b/src/ruby/nodes/case.ts deleted file mode 100644 index d0ad9692..00000000 --- a/src/ruby/nodes/case.ts +++ /dev/null @@ -1,59 +0,0 @@ -import type { Plugin, Ruby } from "../../types"; -import prettier from "../../prettier"; - -const { align, fill, group, hardline, indent, line } = prettier; - -export const printCase: Plugin.Printer = (path, opts, print) => { - const parts: Plugin.Doc[] = ["case"]; - - // You don't need to explicitly have something to test against in a case - // statement (without it it effectively becomes an if/elsif chain). - if (path.getValue().body[0]) { - parts.push(" ", path.call(print, "body", 0)); - } - - return [...parts, hardline, path.call(print, "body", 1), hardline, "end"]; -}; - -export const printWhen: Plugin.Printer = (path, opts, print) => { - const [, , addition] = path.getValue().body; - - // The `fill` builder command expects an array of docs alternating with - // line breaks. This is so it can loop through and determine where to break. - const preds = fill( - (path.call(print, "body", 0) as Plugin.Doc[]).reduce( - (accum: Plugin.Doc[], pred, index) => { - if (index === 0) { - return [pred]; - } - - // Pull off the last element and make it concat with a comma so that - // we can maintain alternating lines and docs. - return [ - ...accum.slice(0, -1), - [accum[accum.length - 1], ","], - line, - pred - ]; - }, - [] as Plugin.Doc[] - ) - ); - - const stmts = path.call(print, "body", 1) as Plugin.Doc[]; - const parts: Plugin.Doc[] = [["when ", align("when ".length, preds)]]; - - // It's possible in a when to just have empty void statements, in which case - // we would skip adding the body. - if (!stmts.every((part) => !part)) { - parts.push(indent([hardline, stmts])); - } - - // This is the next clause on the case statement, either another `when` or - // an `else` clause. - if (addition) { - parts.push(hardline, path.call(print, "body", 2)); - } - - return group(parts); -}; diff --git a/src/ruby/nodes/class.ts b/src/ruby/nodes/class.ts deleted file mode 100644 index 039a51a8..00000000 --- a/src/ruby/nodes/class.ts +++ /dev/null @@ -1,57 +0,0 @@ -import type { Plugin, Ruby } from "../../types"; -import prettier from "../../prettier"; -import { isEmptyBodyStmt } from "../../utils"; - -const { group, hardline, indent } = prettier; - -export const printClass: Plugin.Printer = (path, opts, print) => { - const [, superclass, bodystmt] = path.getValue().body; - - const parts = ["class ", path.call(print, "body", 0)]; - if (superclass) { - parts.push(" < ", path.call(print, "body", 1)); - } - - const declaration = group(parts); - if (isEmptyBodyStmt(bodystmt)) { - return group([declaration, hardline, "end"]); - } - - return group([ - declaration, - indent([hardline, path.call(print, "body", 2)]), - [hardline, "end"] - ]); -}; - -export const printModule: Plugin.Printer = (path, opts, print) => { - const node = path.getValue(); - const declaration = group(["module ", path.call(print, "body", 0)]); - - if (isEmptyBodyStmt(node.body[1])) { - return group([declaration, hardline, "end"]); - } - - return group([ - declaration, - indent([hardline, path.call(print, "body", 1)]), - hardline, - "end" - ]); -}; - -export const printSClass: Plugin.Printer = (path, opts, print) => { - const bodystmt = path.getValue().body[1]; - const declaration = ["class << ", path.call(print, "body", 0)]; - - if (isEmptyBodyStmt(bodystmt)) { - return group([declaration, hardline, "end"]); - } - - return group([ - declaration, - indent([hardline, path.call(print, "body", 1)]), - hardline, - "end" - ]); -}; diff --git a/src/ruby/nodes/commands.ts b/src/ruby/nodes/commands.ts deleted file mode 100644 index 0710f50d..00000000 --- a/src/ruby/nodes/commands.ts +++ /dev/null @@ -1,150 +0,0 @@ -import type { Plugin, Ruby } from "../../types"; -import prettier from "../../prettier"; -import { makeCall } from "../../utils"; - -const { align, group, ifBreak, indent, join, line, softline } = prettier; - -function throwBadDoc(doc: never): never; -function throwBadDoc(doc: Plugin.Doc) { - throw new Error(`Unknown doc ${doc}`); -} - -// Loop through the already created doc nodes and determine the overall length -// so that we can properly align the command arguments. -function docLength(doc: Plugin.Doc): number { - if (Array.isArray(doc)) { - return doc.reduce((sum, child) => sum + docLength(child), 0); - } - - if (typeof doc === "string") { - return doc.length; - } - - switch (doc.type) { - case "concat": - case "fill": - return doc.parts.reduce((sum, child) => sum + docLength(child), 0); - case "align": - case "group": - case "indent": - case "line-suffix": - return docLength(doc.contents); - case "if-break": - return docLength(doc.flatContents); - case "line": - return doc.soft ? 0 : 1; - case "break-parent": - case "cursor": - case "indent-if-break": - case "label": - case "line-suffix-boundary": - case "trim": - return 0; - default: - throwBadDoc(doc); - } -} - -function hasDef(node: Ruby.Command) { - return ( - node.body[1].type === "args_add_block" && - node.body[1].body[0].type === "args" && - node.body[1].body[0].body[0] && - ["def", "defs"].includes(node.body[1].body[0].body[0].type) - ); -} - -// Very special handling case for rspec matchers. In general with rspec matchers -// you expect to see something like: -// -// expect(foo).to receive(:bar).with( -// 'one', -// 'two', -// 'three', -// 'four', -// 'five' -// ) -// -// In this case the arguments are aligned to the left side as opposed to being -// aligned with the `receive` call. -function skipArgsAlign(node: Ruby.CommandCall) { - return ["to", "not_to", "to_not"].includes(node.body[2].body); -} - -// If there is a ternary argument to a command and it's going to get broken -// into multiple lines, then we're going to have to use parentheses around the -// command in order to make sure operator precedence doesn't get messed up. -function hasTernaryArg(node: Ruby.Args | Ruby.ArgsAddBlock) { - return (node.body[0] as any).body.some( - (child: Ruby.AnyNode) => child.type === "ifop" - ); -} - -export const printCommand: Plugin.Printer = ( - path, - opts, - print -) => { - const node = path.getValue(); - - const command = path.call(print, "body", 0); - const joinedArgs = join([",", line], path.call(print, "body", 1)); - - const hasTernary = hasTernaryArg(node.body[1]); - let breakArgs; - - if (hasTernary) { - breakArgs = indent([softline, joinedArgs]); - } else if (hasDef(node)) { - breakArgs = joinedArgs; - } else { - breakArgs = align(docLength(command) + 1, joinedArgs); - } - - return group( - ifBreak( - [ - command, - hasTernary ? "(" : " ", - breakArgs, - hasTernary ? [softline, ")"] : "" - ], - [command, " ", joinedArgs] - ) - ); -}; - -export const printCommandCall: Plugin.Printer = ( - path, - opts, - print -) => { - const node = path.getValue(); - const parts = [ - path.call(print, "body", 0), - makeCall(path, opts, print), - path.call(print, "body", 2) - ]; - - if (!node.body[3]) { - return parts; - } - - const argDocs = join([",", line], path.call(print, "body", 3)); - let breakDoc; - - if (hasTernaryArg(node.body[3])) { - breakDoc = parts.concat("(", indent([softline, argDocs]), softline, ")"); - parts.push(" "); - } else if (skipArgsAlign(node)) { - parts.push(" "); - breakDoc = parts.concat(argDocs); - } else { - parts.push(" "); - breakDoc = parts.concat(align(docLength(parts), argDocs)); - } - - const joinedDoc = parts.concat(argDocs); - - return group(ifBreak(breakDoc, joinedDoc)); -}; diff --git a/src/ruby/nodes/conditionals.ts b/src/ruby/nodes/conditionals.ts deleted file mode 100644 index 9d835622..00000000 --- a/src/ruby/nodes/conditionals.ts +++ /dev/null @@ -1,320 +0,0 @@ -import type { Plugin, Ruby } from "../../types"; -import prettier from "../../prettier"; -import { - containsAssignment, - inlineEnsureParens, - isEmptyStmts -} from "../../utils"; - -const { align, breakParent, hardline, group, ifBreak, indent, softline } = - prettier; - -// If the statements are just a single if/unless, in block or modifier form, or -// a ternary -function containsSingleConditional(stmts: Ruby.Stmts) { - return ( - stmts.body.length === 1 && - ["if", "if_mod", "ifop", "unless", "unless_mod"].includes( - stmts.body[0].type - ) - ); -} - -function printWithAddition( - keyword: string, - path: Plugin.Path, - print: Plugin.Print, - breaking: boolean -) { - return [ - `${keyword} `, - align(keyword.length + 1, path.call(print, "body", 0)), - indent([softline, path.call(print, "body", 1)]), - [softline, path.call(print, "body", 2)], - [softline, "end"], - breaking ? breakParent : "" - ]; -} - -// For the unary `not` operator, we need to explicitly add parentheses to it in -// order for it to be valid from within a ternary. Otherwise if the clause of -// the ternary isn't a unary `not`, we can just pass it along. -function printTernaryClause(clause: Plugin.Doc) { - if (Array.isArray(clause)) { - const [part] = clause; - - if (Array.isArray(part) && part[0] === "not") { - // We are inside of a statements list and the statement is a unary `not`. - return ["not(", part[2], ")"]; - } - - if (clause[0] === "not") { - // We are inside a ternary condition and the clause is a unary `not`. - return ["not(", clause[2], ")"]; - } - } - - return clause; -} - -// The conditions for a ternary look like `foo : bar` where `foo` represents -// the truthy clause and `bar` represents the falsy clause. In the case that the -// parent node is an `unless`, these have to flip in order. -function printTernaryClauses( - keyword: string, - truthyClause: Plugin.Doc, - falsyClause: Plugin.Doc -) { - const parts = [ - printTernaryClause(truthyClause), - " : ", - printTernaryClause(falsyClause) - ]; - - return keyword === "if" ? parts : parts.reverse(); -} - -// Handles ternary nodes. If it does not fit on one line, then we break out into -// an if/else statement. Otherwise we remain as a ternary. -export const printTernary: Plugin.Printer = ( - path, - _opts, - print -) => { - const [predicate, truthyClause, falsyClause] = path.map(print, "body"); - const ternaryClauses = printTernaryClauses("if", truthyClause, falsyClause); - - return group( - ifBreak( - [ - "if ", - align(3, predicate), - indent([softline, truthyClause]), - [softline, "else"], - indent([softline, falsyClause]), - [softline, "end"] - ], - [predicate, " ? ", ...ternaryClauses] - ) - ); -}; - -// Prints an `if_mod` or `unless_mod` node. Because it was previously in the -// modifier form, we're guaranteed to not have an additional node, so we can -// just work with the predicate and the body. -function printSingle( - keyword: string, - modifier = false -): Plugin.Printer< - Ruby.If | Ruby.IfModifier | Ruby.Unless | Ruby.UnlessModifier -> { - return function printSingleWithKeyword(path, { rubyModifier }, print) { - const [, statementsNode] = path.getValue().body; - const predicateDoc = path.call(print, "body", 0); - const statementsDoc = path.call(print, "body", 1); - - const multilineParts = [ - `${keyword} `, - align(keyword.length + 1, predicateDoc), - indent([softline, statementsDoc]), - softline, - "end" - ]; - - // If we do not allow modifier form conditionals or there are comments - // inside of the body of the conditional, then we must print in the - // multiline form. - if ( - !rubyModifier || - (!modifier && (statementsNode as Ruby.If | Ruby.Unless).body[0].comments) - ) { - return [multilineParts, breakParent]; - } - - const inline = inlineEnsureParens(path, [ - path.call(print, "body", 1), - ` ${keyword} `, - path.call(print, "body", 0) - ]); - - // An expression with a conditional modifier (expression if true), the - // conditional body is parsed before the predicate expression, meaning that - // if the parser encountered a variable declaration, it would initialize - // that variable first before evaluating the predicate expression. That - // parse order means the difference between a NameError or not. #591 - // https://docs.ruby-lang.org/en/2.0.0/syntax/control_expressions_rdoc.html#label-Modifier+if+and+unless - if (modifier && containsAssignment(statementsNode)) { - return inline; - } - - return group(ifBreak(multilineParts, inline)); - }; -} - -const noTernary = [ - "alias", - "assign", - "break", - "command", - "command_call", - "heredoc", - "if", - "if_mod", - "ifop", - "lambda", - "massign", - "next", - "opassign", - "rescue_mod", - "return", - "return0", - "super", - "undef", - "unless", - "unless_mod", - "until_mod", - "var_alias", - "void_stmt", - "while_mod", - "yield", - "yield0", - "zsuper" -]; - -// Certain expressions cannot be reduced to a ternary without adding parens -// around them. In this case we say they cannot be ternaried and default instead -// to breaking them into multiple lines. -function canTernaryStmts(stmts: Ruby.Stmts) { - if (stmts.body.length !== 1) { - return false; - } - - const stmt = stmts.body[0]; - - // If the user is using one of the lower precedence "and" or "or" operators, - // then we can't use a ternary expression as it would break the flow control. - if (stmt.type === "binary" && ["and", "or"].includes(stmt.body[1])) { - return false; - } - - // Check against the blocklist of statement types that are not allowed to be - // a part of a ternary expression. - return !noTernary.includes(stmt.type); -} - -// In order for an `if` or `unless` expression to be shortened to a ternary, -// there has to be one and only one "addition" (another clause attached) which -// is of the "else" type. Both the body of the main node and the body of the -// additional node must have only one statement, and that statement list must -// pass the `canTernaryStmts` check. -function canTernary(path: Plugin.Path) { - const [predicate, stmts, addition] = path.getValue().body; - - return ( - !["assign", "opassign", "command_call", "command"].includes( - predicate.type - ) && - addition && - addition.type === "else" && - [stmts, addition.body[0]].every(canTernaryStmts) - ); -} - -// A normalized print function for both `if` and `unless` nodes. -function printConditional( - keyword: string -): Plugin.Printer { - return (path, opts, print) => { - if (canTernary(path)) { - let ternaryParts = [ - path.call(print, "body", 0), - " ? ", - ...printTernaryClauses( - keyword, - path.call(print, "body", 1), - path.call(print, "body", 2, "body", 0) - ) - ]; - - if (["binary", "call"].includes(path.getParentNode().type)) { - ternaryParts = ["(", ...ternaryParts, ")"]; - } - - return group( - ifBreak(printWithAddition(keyword, path, print, false), ternaryParts) - ); - } - - const [predicate, statements, addition] = path.getValue().body; - - // If there's an additional clause that wasn't matched earlier, we know we - // can't go for the inline option. - if (addition) { - return group(printWithAddition(keyword, path, print, true)); - } - - // If the body of the conditional is empty, then we explicitly have to use the - // block form. - if (isEmptyStmts(statements)) { - return [ - `${keyword} `, - align(keyword.length + 1, path.call(print, "body", 0)), - hardline, - "end" - ]; - } - - // Two situations in which we need to use the block form: - // - // 1. If the predicate of the conditional contains an assignment, then we can't - // know for sure that it doesn't impact the body of the conditional. - // - // 2. If the conditional contains just another conditional, then collapsing it - // would result in double modifiers on the same line. - if ( - containsAssignment(predicate) || - containsSingleConditional(statements) - ) { - return [ - `${keyword} `, - align(keyword.length + 1, path.call(print, "body", 0)), - indent([hardline, path.call(print, "body", 1)]), - hardline, - "end" - ]; - } - - return printSingle(keyword)(path, opts, print); - }; -} - -export const printElse: Plugin.Printer = (path, opts, print) => { - const stmts = path.getValue().body[0]; - - return [ - stmts.body.length === 1 && stmts.body[0].type === "command" - ? breakParent - : "", - "else", - indent([softline, path.call(print, "body", 0)]) - ]; -}; - -export const printElsif: Plugin.Printer = (path, opts, print) => { - const [, , addition] = path.getValue().body; - const parts = [ - group(["elsif ", align("elsif".length - 1, path.call(print, "body", 0))]), - indent([hardline, path.call(print, "body", 1)]) - ]; - - if (addition) { - parts.push(group([hardline, path.call(print, "body", 2)])); - } - - return group(parts); -}; - -export const printIf = printConditional("if"); -export const printIfModifier = printSingle("if", true); -export const printUnless = printConditional("unless"); -export const printUnlessModifier = printSingle("unless", true); diff --git a/src/ruby/nodes/constants.ts b/src/ruby/nodes/constants.ts deleted file mode 100644 index d99d3d80..00000000 --- a/src/ruby/nodes/constants.ts +++ /dev/null @@ -1,46 +0,0 @@ -import type { Plugin, Ruby } from "../../types"; -import prettier from "../../prettier"; -import { makeCall } from "../../utils"; - -const { group, indent, join, softline } = prettier; - -export const printConstPath: Plugin.Printer< - Ruby.ConstPathField | Ruby.ConstPathRef -> = (path, opts, print) => { - return join("::", path.map(print, "body")); -}; - -export const printConstRef: Plugin.Printer = ( - path, - opts, - print -) => { - return path.call(print, "body", 0); -}; - -export const printDefined: Plugin.Printer = ( - path, - opts, - print -) => { - return group([ - "defined?(", - indent([softline, path.call(print, "body", 0)]), - softline, - ")" - ]); -}; - -export const printField: Plugin.Printer = (path, opts, print) => { - return group([ - path.call(print, "body", 0), - makeCall(path, opts, print), - path.call(print, "body", 2) - ]); -}; - -export const printTopConst: Plugin.Printer< - Ruby.TopConstField | Ruby.TopConstRef -> = (path, opts, print) => { - return ["::", path.call(print, "body", 0)]; -}; diff --git a/src/ruby/nodes/flow.ts b/src/ruby/nodes/flow.ts deleted file mode 100644 index d3628e72..00000000 --- a/src/ruby/nodes/flow.ts +++ /dev/null @@ -1,84 +0,0 @@ -import type { Plugin, Ruby } from "../../types"; -import prettier from "../../prettier"; -import { literal } from "../../utils"; - -const { join } = prettier; - -function nodeDive(node: any, steps: PropertyKey[]) { - let current = node; - - steps.forEach((step) => { - current = current[step]; - }); - - return current; -} - -const unskippableParens = [ - "if_mod", - "rescue_mod", - "unless_mod", - "until_mod", - "while_mod" -]; - -function maybeHandleParens( - path: Plugin.Path, - print: Plugin.Print, - keyword: string, - steps: PropertyKey[] -) { - const node = nodeDive(path.getValue(), steps); - if (node.type !== "paren") { - return null; - } - - const stmts = node.body[0].body; - if (stmts.length === 1 && !unskippableParens.includes(stmts[0].type)) { - return [`${keyword} `, (path as any).call(print, ...steps, "body", 0)]; - } - - return [keyword, (path as any).call(print, ...steps)]; -} - -export const printBreak: Plugin.Printer = (path, opts, print) => { - const content = path.getValue().body[0]; - - if (content.body.length === 0) { - return "break"; - } - - const steps = ["body", 0, "body", 0, "body", 0]; - return ( - maybeHandleParens(path, print, "break", steps) || [ - "break ", - join(", ", path.call(print, "body", 0)) - ] - ); -}; - -export const printNext: Plugin.Printer = (path, opts, print) => { - const args = path.getValue().body[0].body[0]; - - if (!args) { - return "next"; - } - - const steps = ["body", 0, "body", 0, "body", 0]; - return ( - maybeHandleParens(path, print, "next", steps) || [ - "next ", - join(", ", path.call(print, "body", 0)) - ] - ); -}; - -export const printYield: Plugin.Printer = (path, opts, print) => { - if (path.getValue().body[0].type === "paren") { - return ["yield", path.call(print, "body", 0)]; - } - - return ["yield ", join(", ", path.call(print, "body", 0))]; -}; - -export const printYield0 = literal("yield"); diff --git a/src/ruby/nodes/hashes.ts b/src/ruby/nodes/hashes.ts deleted file mode 100644 index 20e02219..00000000 --- a/src/ruby/nodes/hashes.ts +++ /dev/null @@ -1,166 +0,0 @@ -import type { Plugin, Ruby } from "../../types"; -import prettier from "../../prettier"; -import { - getTrailingComma, - printEmptyCollection, - skipAssignIndent -} from "../../utils"; - -const { group, ifBreak, indent, join, line } = prettier; - -type KeyPrinter = ( - path: Plugin.Path, - print: Plugin.Print -) => Plugin.Doc; -type HashContents = (Ruby.AssoclistFromArgs | Ruby.BareAssocHash) & { - keyPrinter: KeyPrinter; -}; - -// When attempting to convert a hash rocket into a hash label, you need to take -// care because only certain patterns are allowed. Ruby source says that they -// have to match keyword arguments to methods, but don't specify what that is. -// After some experimentation, it looks like it's: -// -// * Starts with a letter (either case) or an underscore -// * Does not end in equal -// -// This function represents that check, as it determines if it can convert the -// symbol node into a hash label. -function isValidHashLabel(symbolLiteral: Ruby.SymbolLiteral) { - const label = symbolLiteral.body[0].body; - return label.match(/^[_A-Za-z]/) && !label.endsWith("="); -} - -function canUseHashLabels(contentsNode: HashContents) { - return contentsNode.body.every((assocNode) => { - if (assocNode.type === "assoc_splat") { - return true; - } - - switch (assocNode.body[0].type) { - case "@label": - return true; - case "symbol_literal": - return isValidHashLabel(assocNode.body[0]); - case "dyna_symbol": - return true; - default: - return false; - } - }); -} - -const printHashKeyLabel: KeyPrinter = (path, print) => { - const node = path.getValue(); - - switch (node.type) { - case "@label": - return print(path); - case "symbol_literal": { - const nodePath = path as Plugin.Path; - return [nodePath.call(print, "body", 0), ":"]; - } - case "dyna_symbol": - return [print(path), ":"]; - default: - // This should never happen, but keeping it here so that the two key - // printers can maintain the same signature. - return ""; - } -}; - -const printHashKeyRocket: KeyPrinter = (path, print) => { - const node = path.getValue(); - let doc = print(path); - - if (node.type === "@label") { - const sDoc = doc as string; // since we know this is a label - doc = [":", sDoc.slice(0, sDoc.length - 1)]; - } else if (node.type === "dyna_symbol") { - doc = [":", doc]; - } - - return [doc, " =>"]; -}; - -export const printAssocNew: Plugin.Printer = ( - path, - opts, - print -) => { - const [keyNode, valueNode] = path.getValue().body; - const { keyPrinter } = path.getParentNode() as HashContents; - - const parts = [path.call((keyPath) => keyPrinter(keyPath, print), "body", 0)]; - const valueDoc = path.call(print, "body", 1); - - // If we're printing a child hash then we want it to break along with its - // parent hash, so we don't group the parts. - if (valueNode.type === "hash") { - parts.push(" ", valueDoc); - return parts; - } - - if (!skipAssignIndent(valueNode) || keyNode.comments) { - parts.push(indent([line, valueDoc])); - } else { - parts.push(" ", valueDoc); - } - - return group(parts); -}; - -export const printAssocSplat: Plugin.Printer = ( - path, - opts, - print -) => { - return ["**", path.call(print, "body", 0)]; -}; - -export const printHashContents: Plugin.Printer = ( - path, - opts, - print -) => { - const node = path.getValue(); - - // First determine which key printer we're going to use, so that the child - // nodes can reference it when they go to get printed. - node.keyPrinter = - opts.rubyHashLabel && canUseHashLabels(path.getValue()) - ? printHashKeyLabel - : printHashKeyRocket; - - return join([",", line], path.map(print, "body")); -}; - -export const printHash: Plugin.Printer = (path, opts, print) => { - const hashNode = path.getValue(); - - // Hashes normally have a single assoclist_from_args child node. If it's - // missing, then it means we're dealing with an empty hash, so we can just - // exit here and print. - if (hashNode.body[0] === null) { - return printEmptyCollection(path, opts, "{", "}"); - } - - const hashDoc = [ - "{", - indent([ - line, - path.call(print, "body", 0), - getTrailingComma(opts) ? ifBreak(",", "") : "" - ]), - line, - "}" - ]; - - // If we're inside another hash, then we don't want to group our contents - // because we want this hash to break along with its parent hash. - if (path.getParentNode().type === "assoc_new") { - return hashDoc; - } - - return group(hashDoc); -}; diff --git a/src/ruby/nodes/heredocs.ts b/src/ruby/nodes/heredocs.ts deleted file mode 100644 index 390b42a7..00000000 --- a/src/ruby/nodes/heredocs.ts +++ /dev/null @@ -1,33 +0,0 @@ -import type { Plugin, Ruby } from "../../types"; -import prettier from "../../prettier"; -import { literallineWithoutBreakParent } from "../../utils"; - -const { group, lineSuffix, join } = prettier; - -export const printHeredoc: Plugin.Printer = ( - path, - opts, - print -) => { - const { body, ending } = path.getValue(); - - const parts = body.map((part, index) => { - if (part.type !== "@tstring_content") { - // In this case, the part of the string is an embedded expression - return path.call(print, "body", index); - } - - // In this case, the part of the string is just regular string content - return join(literallineWithoutBreakParent, part.body.split(/\r?\n/)); - }); - - // We use a literalline break because matching indentation is required - // for the heredoc contents and ending. If the line suffix contains a - // break-parent, all ancestral groups are broken, and heredocs automatically - // break lines in groups they appear in. We prefer them to appear in-line if - // possible, so we use a literalline without the break-parent. - return group([ - path.call(print, "beging"), - lineSuffix(group([literallineWithoutBreakParent, ...parts, ending])) - ]); -}; diff --git a/src/ruby/nodes/hooks.ts b/src/ruby/nodes/hooks.ts deleted file mode 100644 index 85f05caf..00000000 --- a/src/ruby/nodes/hooks.ts +++ /dev/null @@ -1,33 +0,0 @@ -import type { Plugin, Ruby } from "../../types"; -import prettier from "../../prettier"; - -const { group, indent, line } = prettier; - -// The `BEGIN` and `END` keywords are used to hook into the Ruby process. Any -// `BEGIN` blocks are executed right when the process starts up, and the `END` -// blocks are executed right before exiting. -// -// BEGIN { -// # content goes here -// } -// -// END { -// # content goes here -// } -// -// Interesting side note, you don't use `do...end` blocks with these hooks. Both -// nodes contain one child which is a `stmts` node. -function printHook(name: string): Plugin.Printer { - return function printHookWithName(path, opts, print) { - return group([ - name, - " ", - path.call(print, "body", 0), - indent([line, path.call(print, "body", 1)]), - [line, "}"] - ]); - }; -} - -export const printBEGIN = printHook("BEGIN"); -export const printEND = printHook("END"); diff --git a/src/ruby/nodes/ints.ts b/src/ruby/nodes/ints.ts deleted file mode 100644 index 45437f82..00000000 --- a/src/ruby/nodes/ints.ts +++ /dev/null @@ -1,27 +0,0 @@ -import type { Plugin, Ruby } from "../../types"; - -// An @int node is any literal integer in Ruby. They can come in a number of -// bases, and look like the following: -// -// Binary (2) - 0b0110 -// Octal (8) - 0o34 or 034 -// Decimal (10) - a normal number like 159 -// Hexidecimal (16) - 0xac5 -// -// If it's a decimal number, it can be optional separated by any number of -// arbitrarily places underscores. This can be useful for dollars and cents -// (34_99), dates (2020_11_30), and normal 3 digit separation (1_222_333). -export const printInt: Plugin.Printer = (path) => { - const { body } = path.getValue(); - - // If the number is a base 10 number, is sufficiently large, and is not - // already formatted with underscores, then add them in in between the - // numbers every three characters starting from the right. - if (!body.startsWith("0") && body.length >= 5 && !body.includes("_")) { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - const segments = ` ${body}`.slice((body.length + 2) % 3).match(/.{3}/g)!; - return segments.join("_").trim(); - } - - return body; -}; diff --git a/src/ruby/nodes/lambdas.ts b/src/ruby/nodes/lambdas.ts deleted file mode 100644 index f1f8180b..00000000 --- a/src/ruby/nodes/lambdas.ts +++ /dev/null @@ -1,78 +0,0 @@ -import type { Plugin, Ruby } from "../../types"; -import prettier from "../../prettier"; -import { hasAncestor } from "../../utils"; - -const { group, ifBreak, indent, line } = prettier; - -// We can have our params coming in as the first child of the main lambda node, -// or if we have them wrapped in parens then they'll be one level deeper. Even -// though it's possible to omit the parens if you only have one argument, we're -// going to keep them in no matter what for consistency. -function printLambdaParams( - path: Plugin.Path, - print: Plugin.Print -) { - let node = path.getValue().body[0]; - - // In this case we had something like -> (foo) { bar } which would mean that - // we're looking at a paren node, so we'll descend one level deeper to get at - // the actual params node. - if (node.type !== "params") { - node = node.body[0]; - } - - // If we don't have any params at all, then we're just going to bail out and - // print nothing. This is to avoid printing an empty set of parentheses. - if (node.body.every((type) => !type)) { - return ""; - } - - return path.call(print, "body", 0); -} - -// Lambda nodes represent stabby lambda literals, which can come in a couple of -// flavors. They can use either braces or do...end for their block, and their -// arguments can be not present, have no parentheses for a single argument, or -// have parentheses for multiple arguments. Below are a couple of examples: -// -// -> { 1 } -// -> a { a + 1 } -// ->(a) { a + 1 } -// ->(a, b) { a + b } -// ->(a, b = 1) { a + b } -// -// -> do -// 1 -// end -// -// -> a do -// a + 1 -// end -// -// ->(a, b) do -// a + b -// end -// -// Generally, we're going to favor do...end for the multi-line form and braces -// for the single-line form. However, if we have an ancestor that is a command -// or command_call node, then we'll need to use braces either way because of -// operator precendence. -export const printLambda: Plugin.Printer = (path, opts, print) => { - const params = printLambdaParams(path, print); - const inCommand = hasAncestor(path, ["command", "command_call"]); - - return group( - ifBreak( - [ - "->", - params, - " ", - inCommand ? "{" : "do", - indent([line, path.call(print, "body", 1)]), - line, - inCommand ? "}" : "end" - ], - ["->", params, " { ", path.call(print, "body", 1), " }"] - ) - ); -}; diff --git a/src/ruby/nodes/loops.ts b/src/ruby/nodes/loops.ts deleted file mode 100644 index 7be9f9dc..00000000 --- a/src/ruby/nodes/loops.ts +++ /dev/null @@ -1,89 +0,0 @@ -import type { Plugin, Ruby } from "../../types"; -import prettier from "../../prettier"; -import { - containsAssignment, - inlineEnsureParens, - isEmptyStmts -} from "../../utils"; - -const { align, breakParent, group, hardline, ifBreak, indent, join, softline } = - prettier; - -function printLoop( - keyword: string, - modifier: boolean -): Plugin.Printer< - Ruby.While | Ruby.WhileModifier | Ruby.Until | Ruby.UntilModifier -> { - return function printLoopWithOptions(path, { rubyModifier }, print) { - const [, stmts] = path.getValue().body; - - // If the only statement inside this while loop is a void statement, then we - // can shorten to just displaying the predicate and then a semicolon. - if (isEmptyStmts(stmts)) { - return group([ - group([keyword, " ", path.call(print, "body", 0)]), - hardline, - "end" - ]); - } - - const inlineLoop = inlineEnsureParens(path, [ - path.call(print, "body", 1), - ` ${keyword} `, - path.call(print, "body", 0) - ]); - - // If we're in the modifier form and we're modifying a `begin`, then this is - // a special case where we need to explicitly use the modifier form because - // otherwise the semantic meaning changes. This looks like: - // - // begin - // foo - // end while bar - // - // The above is effectively a `do...while` loop (which we don't have in - // ruby). - if (modifier && path.getValue().body[1].type === "begin") { - return inlineLoop; - } - - const blockLoop = [ - [`${keyword} `, align(keyword.length + 1, path.call(print, "body", 0))], - indent([softline, path.call(print, "body", 1)]), - softline, - "end" - ]; - - // If we're disallowing inline loops or if the predicate of the loop - // contains an assignment (in which case we can't know for certain that that - // assignment doesn't impact the statements inside the loop) then we can't - // use the modifier form and we must use the block form. - if (!rubyModifier || containsAssignment(path.getValue().body[0])) { - return [breakParent, blockLoop]; - } - - return group(ifBreak(blockLoop, inlineLoop)); - }; -} - -export const printFor: Plugin.Printer = (path, opts, print) => { - const [varDoc, rangeDoc, stmtsDoc] = path.map(print, "body"); - const varsDoc = - path.getValue().body[0].type === "mlhs" ? join(", ", varDoc) : varDoc; - - return group([ - "for ", - varsDoc, - " in ", - rangeDoc, - indent([hardline, stmtsDoc]), - hardline, - "end" - ]); -}; - -export const printWhile = printLoop("while", false); -export const printWhileModifier = printLoop("while", true); -export const printUntil = printLoop("until", false); -export const printUntilModifer = printLoop("until", true); diff --git a/src/ruby/nodes/massign.ts b/src/ruby/nodes/massign.ts deleted file mode 100644 index 65779a65..00000000 --- a/src/ruby/nodes/massign.ts +++ /dev/null @@ -1,108 +0,0 @@ -import type { Plugin, Ruby } from "../../types"; -import prettier from "../../prettier"; - -const { group, indent, join, line, softline } = prettier; - -export const printMAssign: Plugin.Printer = ( - path, - opts, - print -) => { - let right = path.call(print, "body", 1); - - if ( - ["mrhs_add_star", "mrhs_new_from_args"].includes( - path.getValue().body[1].type - ) - ) { - right = group(join([",", line], right)); - } - - const parts: Plugin.Doc[] = [join([",", line], path.call(print, "body", 0))]; - if ((path.getValue().body[0] as any).comma) { - parts.push(","); - } - - return group([group(parts), " =", indent([line, right])]); -}; - -export const printMLHS: Plugin.Printer = (path, opts, print) => { - return path.map(print, "body"); -}; - -export const printMLHSAddPost: Plugin.Printer = ( - path, - opts, - print -) => { - return [ - ...(path.call(print, "body", 0) as Plugin.Doc[]), - ...(path.call(print, "body", 1) as Plugin.Doc[]) - ]; -}; - -export const printMLHSAddStar: Plugin.Printer = ( - path, - opts, - print -) => { - const parts: Plugin.Doc[] = ["*"]; - - if (path.getValue().body[1]) { - parts.push(path.call(print, "body", 1)); - } - - return [...(path.call(print, "body", 0) as Plugin.Doc[]), parts]; -}; - -export const printMLHSParen: Plugin.Printer = ( - path, - opts, - print -) => { - if (["massign", "mlhs_paren"].includes(path.getParentNode().type)) { - // If we're nested in brackets as part of the left hand side of an - // assignment, i.e., (a, b, c) = 1, 2, 3 - // ignore the current node and just go straight to the content - return path.call(print, "body", 0); - } - - const parts: Plugin.Doc[] = [ - softline, - join([",", line], path.call(print, "body", 0)) - ]; - - if ((path.getValue().body[0] as any).comma) { - parts.push(","); - } - - return group(["(", indent(parts), [softline, ")"]]); -}; - -export const printMRHS: Plugin.Printer = (path, opts, print) => { - return path.map(print, "body"); -}; - -export const printMRHSAddStar: Plugin.Printer = ( - path, - opts, - print -) => { - const [leftDoc, rightDoc] = path.map(print, "body"); - - return [...(leftDoc as Plugin.Doc[]), ["*", rightDoc]]; -}; - -export const printMRHSNewFromArgs: Plugin.Printer = ( - path, - opts, - print -) => { - const parts = path.call(print, "body", 0) as Plugin.Doc[]; - - if (path.getValue().body[1]) { - parts.push(path.call(print, "body", 1)); - } - - return parts; -}; diff --git a/src/ruby/nodes/methods.ts b/src/ruby/nodes/methods.ts deleted file mode 100644 index ce227f85..00000000 --- a/src/ruby/nodes/methods.ts +++ /dev/null @@ -1,90 +0,0 @@ -import type { Plugin, Ruby } from "../../types"; -import prettier from "../../prettier"; -import { isEmptyBodyStmt } from "../../utils"; - -const { group, hardline, indent, line } = prettier; - -export const printDef: Plugin.Printer = ( - path, - opts, - print -) => { - const node = path.getValue(); - const declaration: Plugin.Doc[] = ["def "]; - - let paramsNode: Ruby.Params | Ruby.Paren; - let bodystmtNode: Ruby.Bodystmt; - - let nameDoc: Plugin.Doc; - let paramsDoc: Plugin.Doc; - let bodystmtDoc: Plugin.Doc; - - if (node.type === "def") { - paramsNode = node.body[1]; - bodystmtNode = node.body[2]; - - nameDoc = path.call(print, "body", 0); - paramsDoc = path.call(print, "body", 1); - bodystmtDoc = path.call(print, "body", 2); - } else { - // In this case, we're printing a method that's defined as a singleton, so - // we need to include the target and the operator - declaration.push(path.call(print, "body", 0), path.call(print, "body", 1)); - - paramsNode = node.body[3]; - bodystmtNode = node.body[4]; - - nameDoc = path.call(print, "body", 2); - paramsDoc = path.call(print, "body", 3); - bodystmtDoc = path.call(print, "body", 4); - } - - // In case there are no parens but there are arguments - const parens = - paramsNode.type === "params" && paramsNode.body.some((type) => type); - declaration.push(nameDoc, parens ? "(" : "", paramsDoc, parens ? ")" : ""); - - if (isEmptyBodyStmt(bodystmtNode)) { - return group([...declaration, "; end"]); - } - - return group([ - group(declaration), - indent([hardline, bodystmtDoc]), - hardline, - "end" - ]); -}; - -export const printSingleLineMethod: Plugin.Printer = ( - path, - opts, - print -) => { - const parensNode = path.getValue().body[1]; - let paramsDoc: Plugin.Doc = ""; - - if (parensNode) { - const paramsNode = parensNode.body[0]; - - if (paramsNode.body.some((type) => type)) { - paramsDoc = path.call(print, "body", 1); - } - } - - return group([ - "def ", - path.call(print, "body", 0), - paramsDoc, - " =", - indent(group([line, path.call(print, "body", 2)])) - ]); -}; - -export const printAccessControl: Plugin.Printer = ( - path, - opts, - print -) => { - return path.call(print, "body", 0); -}; diff --git a/src/ruby/nodes/operators.ts b/src/ruby/nodes/operators.ts deleted file mode 100644 index 65eb4da0..00000000 --- a/src/ruby/nodes/operators.ts +++ /dev/null @@ -1,73 +0,0 @@ -import type { Plugin, Ruby } from "../../types"; -import prettier from "../../prettier"; -import { noIndent } from "../../utils"; - -const { group, indent, line, softline } = prettier; - -export const printBinary: Plugin.Printer = (path, opts, print) => { - const [, operator, rightNode] = path.getValue().body; - const space = operator === "**" ? "" : " "; - - if (noIndent.includes(rightNode.type)) { - return group([ - group(path.call(print, "body", 0)), - space, - operator, - space, - group(path.call(print, "body", 2)) - ]); - } - - return group([ - group(path.call(print, "body", 0)), - space, - group( - indent([ - operator, - space === "" ? softline : line, - path.call(print, "body", 2) - ]) - ) - ]); -}; - -// dot2 nodes are used with ranges (or flip-flops). They can optionally drop -// their left side for beginless ranges or their right side for endless ranges. -export const printDot2: Plugin.Printer = (path, opts, print) => { - const [leftNode, rightNode] = path.getValue().body; - - return [ - leftNode ? path.call(print, "body", 0) : "", - "..", - rightNode ? path.call(print, "body", 1) : "" - ]; -}; - -// dot3 nodes are used with ranges (or flip-flops). They can optionally drop -// their left side for beginless ranges or their right side for endless ranges. -export const printDot3: Plugin.Printer = (path, opts, print) => { - const [leftNode, rightNode] = path.getValue().body; - - return [ - leftNode ? path.call(print, "body", 0) : "", - "...", - rightNode ? path.call(print, "body", 1) : "" - ]; -}; - -export const printUnary: Plugin.Printer = (path, opts, print) => { - const node = path.getValue(); - const contentsDoc = path.call(print, "body", 0); - - if (node.oper === "not") { - // Here we defer to the original source, as it's kind of difficult to - // determine if we can actually remove the parentheses being used. - if (node.paren) { - return ["not", "(", contentsDoc, ")"]; - } else { - return ["not", " ", contentsDoc]; - } - } - - return [node.oper, contentsDoc]; -}; diff --git a/src/ruby/nodes/params.ts b/src/ruby/nodes/params.ts deleted file mode 100644 index 247ee7a7..00000000 --- a/src/ruby/nodes/params.ts +++ /dev/null @@ -1,118 +0,0 @@ -import type { Plugin, Ruby } from "../../types"; -import prettier from "../../prettier"; -import { literal } from "../../utils"; - -const { group, hardline, join, indent, line, lineSuffix, softline } = prettier; - -function printRestParamSymbol( - symbol: string -): Plugin.Printer { - return function printRestParamWithSymbol(path, opts, print) { - return path.getValue().body[0] - ? [symbol, path.call(print, "body", 0)] - : symbol; - }; -} - -export const printParams: Plugin.Printer = (path, opts, print) => { - const [reqs, optls, rest, post, kwargs, kwargRest, block] = - path.getValue().body; - let parts: Plugin.Doc[] = []; - - if (reqs) { - path.each( - (reqPath) => { - // For some very strange reason, if you have a comment attached to a - // rest_param, it shows up here in the list of required params. - if ((reqPath.getValue().type as any) !== "rest_param") { - parts.push(print(reqPath)); - } - }, - "body", - 0 - ); - } - - if (optls) { - parts = parts.concat( - path.map((optlPath) => join(" = ", optlPath.map(print)), "body", 1) - ); - } - - if (rest && rest.type !== "excessed_comma") { - parts.push(path.call(print, "body", 2)); - } - - if (post) { - parts = parts.concat(path.map(print, "body", 3)); - } - - if (kwargs) { - parts = parts.concat( - path.map( - (kwargPath) => { - if (!kwargPath.getValue()[1]) { - return kwargPath.call(print, 0); - } - return group(join(" ", kwargPath.map(print))); - }, - "body", - 4 - ) - ); - } - - if (kwargRest) { - parts.push(kwargRest === "nil" ? "**nil" : path.call(print, "body", 5)); - } - - if (block) { - parts.push(path.call(print, "body", 6)); - } - - const contents: Plugin.Doc[] = [join([",", line], parts)]; - - // You can put an extra comma at the end of block args between pipes to - // change what it does. Below is the difference: - // - // [[1, 2], [3, 4]].each { |x| p x } # prints [1, 2] then [3, 4] - // [[1, 2], [3, 4]].each { |x,| p x } # prints 1 then 3 - // - // In ruby 2.5, the excessed comma is indicated by having a 0 in the rest - // param position. In ruby 2.6+ it's indicated by having an "excessed_comma" - // node in the rest position. Seems odd, but it's true. - if ((rest as any) === 0 || (rest && rest.type === "excessed_comma")) { - contents.push(","); - } - - // If the parent node is a paren then we skipped printing the parentheses so - // that we could handle them here and get nicer formatting. - const parentNode = path.getParentNode(); - - if (["lambda", "paren"].includes(parentNode.type)) { - const parts: Plugin.Doc[] = ["("]; - - // If the parent node is a paren and the paren has comments that are - // attached to the left paren, then we need to print those out explicitly - // here. - if (parentNode.type === "paren" && parentNode.lparen.comments) { - const comments: Plugin.Doc[] = []; - - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - (parentNode as Ruby.Paren).lparen.comments!.forEach((comment, index) => { - comment.printed = true; - comments.push(lineSuffix(`${index === 0 ? " " : ""}#${comment.value}`)); - }); - - parts.push(join(hardline, comments)); - } - - return group([...parts, indent([softline, ...contents]), softline, ")"]); - } - - return group(contents); -}; - -export const printArgsForward = literal("..."); -export const printKeywordRestParam = printRestParamSymbol("**"); -export const printRestParam = printRestParamSymbol("*"); diff --git a/src/ruby/nodes/patterns.ts b/src/ruby/nodes/patterns.ts deleted file mode 100644 index 252ecd7e..00000000 --- a/src/ruby/nodes/patterns.ts +++ /dev/null @@ -1,169 +0,0 @@ -import type { Plugin, Ruby } from "../../types"; -import prettier from "../../prettier"; - -const { align, group, hardline, indent, join, line } = prettier; - -const patterns = ["aryptn", "binary", "fndptn", "hshptn", "rassign"]; - -const printPatternArg: Plugin.Printer = (path, opts, print) => { - // Pinning is a really special syntax in pattern matching that's not really - // all that well supported in ripper. Here we're just going to the original - // source to see if the variable is pinned. - if ( - opts.originalText && - opts.originalText[opts.locStart(path.getValue()) - 1] === "^" - ) { - return ["^", path.call(print)]; - } - - return path.call(print); -}; - -export const printAryPtn: Plugin.Printer = (path, opts, print) => { - const [constant, preargs, splatarg, postargs] = path.getValue().body; - let argDocs: Plugin.Doc[] = []; - - if (preargs) { - argDocs = argDocs.concat( - path.map((argPath) => printPatternArg(argPath, opts, print), "body", 1) - ); - } - - if (splatarg) { - argDocs.push(["*", path.call(print, "body", 2)]); - } - - if (postargs) { - argDocs = argDocs.concat(path.map(print, "body", 3)); - } - - let argDoc: Plugin.Doc = group(join([",", line], argDocs)); - - // There are a couple of cases where we _must_ use brackets. They include: - // - // * When the number of arguments inside the array pattern is one 1, then we - // have to include them, otherwise it matches the whole array. Consider the - // difference between `in [elem]` and `in elem`. - // * If we have a wrapping constant, then we definitely need the brackets. - // Consider the difference between `in Const[elem]` and `in Const elem` - // * If we're nested inside a parent pattern, then we have to have brackets. - // Consider the difference between `in key: first, second` and - // `in key: [first, second]`. - if ( - argDocs.length === 1 || - constant || - patterns.includes(path.getParentNode().type) - ) { - argDoc = ["[", argDoc, "]"]; - } - - if (constant) { - return [path.call(print, "body", 0), argDoc]; - } - - return argDoc; -}; - -export const printFndPtn: Plugin.Printer = (path, opts, print) => { - const [constant] = path.getValue().body; - const docs = [ - "[", - group( - join( - [",", line], - [ - ["*", path.call(print, "body", 1)], - ...path.map(print, "body", 2), - ["*", path.call(print, "body", 3)] - ] - ) - ), - "]" - ]; - - if (constant) { - return [path.call(print, "body", 0), docs]; - } - - return docs; -}; - -export const printHshPtn: Plugin.Printer = (path, opts, print) => { - const [constant, keyValuePairs, keyValueRest] = path.getValue().body; - let args: Plugin.Doc | Plugin.Doc[] = []; - - if (keyValuePairs.length > 0) { - const printPair = (pairPath: Plugin.Path<[Ruby.Label, Ruby.AnyNode]>) => { - const parts = [pairPath.call(print, 0)]; - - if (pairPath.getValue()[1]) { - parts.push( - " ", - pairPath.call( - (pairValuePath) => printPatternArg(pairValuePath, opts, print), - 1 - ) - ); - } - - return parts; - }; - - args = args.concat(path.map(printPair, "body", 1)); - } - - if (keyValueRest) { - args.push(["**", path.call(print, "body", 2)]); - } - - args = group(join([",", line], args)); - - if (constant) { - args = ["[", args, "]"]; - } else if (patterns.includes(path.getParentNode().type)) { - args = ["{ ", args, " }"]; - } - - if (constant) { - return [path.call(print, "body", 0), args]; - } - - return args; -}; - -export const printIn: Plugin.Printer = (path, opts, print) => { - const keyword = "in "; - const parts: Plugin.Doc[] = [ - keyword, - align( - keyword.length, - path.call( - (valuePath) => printPatternArg(valuePath, opts, print), - "body", - 0 - ) - ), - indent([hardline, path.call(print, "body", 1)]) - ]; - - if (path.getValue().body[2]) { - parts.push(hardline, path.call(print, "body", 2)); - } - - return group(parts); -}; - -export const printRAssign: Plugin.Printer = ( - path, - opts, - print -) => { - const { keyword } = path.getValue(); - const [leftDoc, rightDoc] = path.map(print, "body"); - - return group([ - leftDoc, - keyword ? " in" : " =>", - group(indent([line, rightDoc])) - ]); -}; diff --git a/src/ruby/nodes/regexp.ts b/src/ruby/nodes/regexp.ts deleted file mode 100644 index 4570aee7..00000000 --- a/src/ruby/nodes/regexp.ts +++ /dev/null @@ -1,57 +0,0 @@ -import type { Plugin, Ruby } from "../../types"; -import { hasAncestor } from "../../utils"; - -function hasContent(node: Ruby.RegexpLiteral, pattern: RegExp) { - return node.body.some( - (child) => child.type === "@tstring_content" && pattern.test(child.body) - ); -} - -// If the first part of this regex is plain string content, we have a space -// or an =, and we're contained within a command or command_call node, then we -// want to use braces because otherwise we could end up with an ambiguous -// operator, e.g. foo / bar/ or foo /=bar/ -function forwardSlashIsAmbiguous(path: Plugin.Path) { - const node = path.getValue(); - const firstChildNode = node.body[0]; - - return ( - firstChildNode && - firstChildNode.type === "@tstring_content" && - [" ", "="].includes(firstChildNode.body[0]) && - hasAncestor(path, ["command", "command_call"]) - ); -} - -// This function is responsible for printing out regexp_literal nodes. They can -// either use the special %r literal syntax or they can use forward slashes. At -// the end of either of those they can have modifiers like m or x that have -// special meaning for the regex engine. -// -// We favor the use of forward slashes unless the regex contains a forward slash -// itself. In that case we switch over to using %r with braces. -export const printRegexpLiteral: Plugin.Printer = ( - path, - opts, - print -) => { - const node = path.getValue(); - const docs = path.map(print, "body"); - - // We should use braces if using a forward slash would be ambiguous in the - // current context or if there's a forward slash in the content of the regexp. - const useBraces = forwardSlashIsAmbiguous(path) || hasContent(node, /\//); - - // If we should be using braces but we have braces in the body of the regexp, - // then we're just going to resort to using whatever the original content was. - if (useBraces && hasContent(node, /[{}]/)) { - return [node.beging, ...docs, node.ending]; - } - - return [ - useBraces ? "%r{" : "/", - ...docs, - useBraces ? "}" : "/", - node.ending.slice(1) - ]; -}; diff --git a/src/ruby/nodes/rescue.ts b/src/ruby/nodes/rescue.ts deleted file mode 100644 index 7f3f42a7..00000000 --- a/src/ruby/nodes/rescue.ts +++ /dev/null @@ -1,100 +0,0 @@ -import type { Plugin, Ruby } from "../../types"; -import prettier from "../../prettier"; -import { literal } from "../../utils"; - -const { align, group, hardline, indent, join, line } = prettier; - -export const printBegin: Plugin.Printer = (path, opts, print) => { - return [ - "begin", - indent([hardline, path.map(print, "body")]), - hardline, - "end" - ]; -}; - -export const printEnsure: Plugin.Printer = (path, opts, print) => { - return [ - path.call(print, "body", 0), - indent([hardline, path.call(print, "body", 1)]) - ]; -}; - -export const printRescue: Plugin.Printer = (path, opts, print) => { - const parts: Plugin.Doc[] = ["rescue"]; - - if (path.getValue().body[0]) { - parts.push(align("rescue ".length, path.call(print, "body", 0))); - } else { - // If you don't specify an error to rescue in a `begin/rescue` block, then - // implicitly you're rescuing from `StandardError`. In this case, we're - // just going to explicitly add it. - parts.push(" StandardError"); - } - - const bodystmt = path.call(print, "body", 1) as Plugin.Doc[]; - - if (bodystmt.length > 0) { - parts.push(indent([hardline, bodystmt])); - } - - // This is the next clause on the `begin` statement, either another - // `rescue`, and `ensure`, or an `else` clause. - if (path.getValue().body[2]) { - parts.push([hardline, path.call(print, "body", 2)]); - } - - return group(parts); -}; - -// This is a container node that we're adding into the AST that isn't present in -// Ripper solely so that we have a nice place to attach inline comments. -export const printRescueEx: Plugin.Printer = ( - path, - opts, - print -) => { - const [exception, variable] = path.getValue().body; - const parts: Plugin.Doc[] = []; - - if (exception) { - // If there's just one exception being rescued, then it's just going to be a - // single doc node. - let exceptionDoc = path.call(print, "body", 0); - - // If there are multiple exceptions being rescued, then we're going to have - // multiple doc nodes returned as an array that we need to join together. - if (["mrhs_add_star", "mrhs_new_from_args"].includes(exception.type)) { - exceptionDoc = group(join([",", line], exceptionDoc)); - } - - parts.push(" ", exceptionDoc); - } - - if (variable) { - parts.push(" => ", path.call(print, "body", 1)); - } - - return group(parts); -}; - -export const printRescueMod: Plugin.Printer = ( - path, - opts, - print -) => { - const [statementDoc, valueDoc] = path.map(print, "body"); - - return [ - "begin", - indent([hardline, statementDoc]), - hardline, - "rescue StandardError", - indent([hardline, valueDoc]), - hardline, - "end" - ]; -}; - -export const printRedo = literal("redo"); -export const printRetry = literal("retry"); diff --git a/src/ruby/nodes/return.ts b/src/ruby/nodes/return.ts deleted file mode 100644 index ba99eb14..00000000 --- a/src/ruby/nodes/return.ts +++ /dev/null @@ -1,88 +0,0 @@ -import type { Plugin, Ruby } from "../../types"; -import prettier from "../../prettier"; -import { literal } from "../../utils"; - -const { group, ifBreak, indent, line, join, softline } = prettier; - -// You can't skip the parentheses if you have comments or certain operators with -// lower precedence than the return keyword. -function canSkipParens(args: Ruby.Args | Ruby.ArgsAddStar) { - const stmts = (args.body[0] as any).body[0] as Ruby.Stmts; - - // return( - // # a - // b - // ) - if (stmts.comments) { - return false; - } - - const stmt = stmts.body[0]; - - // return (a or b) - if (stmt.type === "binary" && ["and", "or"].includes(stmt.body[1])) { - return false; - } - - // return (not a) - if (stmt.type === "unary" && stmt.oper === "not") { - return false; - } - - return true; -} - -export const printReturn: Plugin.Printer = (path, opts, print) => { - let args = path.getValue().body[0].body[0] as Ruby.Args | Ruby.ArgsAddStar; - let steps = ["body", 0, "body", 0]; - - if (args.body.length === 1) { - // If the body of the return contains parens, then just skip directly to the - // content of the parens so that we can skip printing parens if we don't - // want them. - if (args.body[0] && args.body[0].type === "paren" && canSkipParens(args)) { - args = args.body[0].body[0] as any as Ruby.Args | Ruby.ArgsAddStar; - steps = steps.concat("body", 0, "body", 0); - } - - // If we're returning an array literal that isn't a special array, single - // element array, or an empty array, then we want to grab the arguments so - // that we can print them out as if they were normal return arguments. - if ( - args.body[0] && - args.body[0].type === "array" && - args.body[0].body[0] && - args.body[0].body[0].body.length > 1 && - ["args", "args_add_star"].includes(args.body[0].body[0].type) - ) { - steps = steps.concat("body", 0, "body", 0); - } - } - - // Now that we've established which actual node is the arguments to return, - // we grab it out of the path by diving down the steps that we've set up. - const parts = (path as any).call(print, ...steps) as - | Plugin.Doc - | Plugin.Doc[]; - const useBrackets = Array.isArray(parts) && parts.length > 1; - - // If we got the value straight out of the parens, then `parts` would only - // be a singular doc as opposed to an array. - const value = Array.isArray(parts) ? join([",", line], parts) : parts; - - // We only get here if we have comments somewhere that would prevent us from - // skipping the parentheses. - if (args.body.length === 1 && args.body[0].type === "paren") { - return ["return", value]; - } - - return group([ - "return", - ifBreak(useBrackets ? " [" : "(", " "), - indent([softline, value]), - softline, - ifBreak(useBrackets ? "]" : ")", "") - ]); -}; - -export const printReturn0 = literal("return"); diff --git a/src/ruby/nodes/statements.ts b/src/ruby/nodes/statements.ts deleted file mode 100644 index a5ec65e5..00000000 --- a/src/ruby/nodes/statements.ts +++ /dev/null @@ -1,159 +0,0 @@ -import type { Plugin, Ruby } from "../../types"; -import prettier from "../../prettier"; -import { isEmptyStmts } from "../../utils"; - -const { - breakParent, - dedent, - group, - hardline, - indent, - join, - line, - literalline, - softline, - trim -} = prettier; - -export const printBodyStmt: Plugin.Printer = ( - path, - opts, - print -) => { - const [stmts, rescue, elseClause, ensure] = path.getValue().body; - const parts = []; - - if (!isEmptyStmts(stmts)) { - parts.push(path.call(print, "body", 0)); - } - - if (rescue) { - parts.push(dedent([hardline, path.call(print, "body", 1)])); - } - - if (elseClause) { - // Before Ruby 2.6, this piece of bodystmt was an explicit "else" node - /* istanbul ignore next */ - const stmts = - (elseClause as any).type === "else" - ? path.call(print, "body", 2, "body", 0) - : path.call(print, "body", 2); - - parts.push([dedent([hardline, "else"]), hardline, stmts]); - } - - if (ensure) { - parts.push(dedent([hardline, path.call(print, "body", 3)])); - } - - return group(parts); -}; - -const argNodeTypes = ["args", "args_add_star", "args_add_block"]; - -export const printParen: Plugin.Printer = (path, opts, print) => { - const contentNode = path.getValue().body[0]; - - if (!contentNode) { - return [path.call(print, "lparen"), ")"]; - } - - let contentDoc = path.call(print, "body", 0); - - // If the content is params, we're going to let it handle its own parentheses - // so that it breaks nicely. - if (contentNode.type === "params") { - return contentDoc; - } - - // If we have an arg type node as the contents, then it's going to return an - // array, so we need to explicitly join that content here. - if (argNodeTypes.includes(contentNode.type)) { - contentDoc = join([",", line], contentDoc); - } - - return group([ - path.call(print, "lparen"), - indent([softline, contentDoc]), - softline, - ")" - ]); -}; - -export const printEndContent: Plugin.Printer = (path) => { - const { body } = path.getValue(); - return [trim, "__END__", literalline, body]; -}; - -export const printComment: Plugin.Printer = (path, opts) => { - return opts.printer.printComment(path, opts); -}; - -export const printProgram: Plugin.Printer = ( - path, - opts, - print -) => { - return [join(hardline, path.map(print, "body")), hardline]; -}; - -type StmtsVoidWithComments = Ruby.Stmts & { - body: [{ type: "void_stmt"; comments: Ruby.Comment[] }]; -}; - -export const printStmts: Plugin.Printer = (path, opts, print) => { - const stmts = path.getValue().body; - - // This is a special case where we have only comments inside a statement - // list. In this case we want to avoid doing any kind of line number - // tracking and just print out the comments. - if ( - stmts.length === 1 && - stmts[0].type === "void_stmt" && - stmts[0].comments - ) { - const nodePath = path as Plugin.Path; - const comments = nodePath.map( - (commentPath) => { - commentPath.getValue().printed = true; - return opts.printer.printComment(commentPath, opts); - }, - "body", - 0, - "comments" - ); - - return [breakParent, join(hardline, comments)]; - } - - const parts: Plugin.Doc[] = []; - let lineNo: null | number = null; - - stmts.forEach((stmt, index) => { - if (stmt.type === "void_stmt") { - return; - } - - const printed = path.call(print, "body", index); - - if (lineNo === null) { - parts.push(printed); - } else if ( - stmt.sl - lineNo > 1 || - [stmt.type, stmts[index - 1].type].includes("access_ctrl") - ) { - parts.push(hardline, hardline, printed); - } else if ( - stmt.sl !== lineNo || - path.getParentNode().type !== "string_embexpr" - ) { - parts.push(hardline, printed); - } else { - parts.push("; ", printed); - } - - lineNo = stmt.el; - }); - - return parts; -}; diff --git a/src/ruby/nodes/strings.ts b/src/ruby/nodes/strings.ts deleted file mode 100644 index 950991cb..00000000 --- a/src/ruby/nodes/strings.ts +++ /dev/null @@ -1,292 +0,0 @@ -import type { Plugin, Ruby } from "../../types"; -import prettier from "../../prettier"; - -const { group, hardline, indent, literalline, removeLines, softline, join } = - prettier; - -// If there is some part of this string that matches an escape sequence or that -// contains the interpolation pattern ("#{"), then we are locked into whichever -// quote the user chose. (If they chose single quotes, then double quoting -// would activate the escape sequence, and if they chose double quotes, then -// single quotes would deactivate it.) -function isQuoteLocked(node: Ruby.DynaSymbol | Ruby.StringLiteral) { - return node.body.some( - (part) => - part.type === "@tstring_content" && - (part.body.includes("#{") || part.body.includes("\\")) - ); -} - -// A string is considered to be able to use single quotes if it contains only -// plain string content and that content does not contain a single quote. -function isSingleQuotable(node: Ruby.DynaSymbol | Ruby.StringLiteral) { - return node.body.every( - (part) => part.type === "@tstring_content" && !part.body.includes("'") - ); -} - -const quotePattern = new RegExp("\\\\([\\s\\S])|(['\"])", "g"); - -function normalizeQuotes(content: string, enclosingQuote: string) { - // Escape and unescape single and double quotes as needed to be able to - // enclose `content` with `enclosingQuote`. - return content.replace(quotePattern, (match, escaped, quote) => { - if (quote === enclosingQuote) { - return `\\${quote}`; - } - - if (quote) { - return quote; - } - - return `\\${escaped}`; - }); -} - -const quotePairs = { - "(": ")", - "[": "]", - "{": "}", - "<": ">" -}; - -type Quote = keyof typeof quotePairs; - -function getClosingQuote(quote: string) { - if (!quote.startsWith("%")) { - return quote; - } - - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - const boundary = /%[Qq]?(.)/.exec(quote)![1]; - if (boundary in quotePairs) { - return quotePairs[boundary as Quote]; - } - - return boundary; -} - -// Prints a @CHAR node. @CHAR nodes are special character strings that usually -// are strings of length 1. If they're any longer than we'll try to apply the -// correct quotes. -export const printChar: Plugin.Printer = (path, opts) => { - const { body } = path.getValue(); - - if (body.length !== 2) { - return body; - } - - const quote = opts.rubySingleQuote ? "'" : '"'; - return [quote, body.slice(1), quote]; -}; - -const printPercentSDynaSymbol: Plugin.Printer = ( - path, - opts, - print -) => { - const node = path.getValue(); - const parts = []; - - // Push on the quote, which includes the opening character. - parts.push(node.quote); - - path.each((childPath) => { - const childNode = childPath.getValue(); - - if (childNode.type !== "@tstring_content") { - // Here we are printing an embedded variable or expression. - parts.push(print(childPath)); - } else { - // Here we are printing plain string content. - parts.push(join(literalline, childNode.body.split("\n"))); - } - }, "body"); - - // Push on the closing character, which is the opposite of the third - // character from the opening. - parts.push(quotePairs[node.quote[2] as Quote]); - - return parts; -}; - -// We don't actually want to print %s symbols, as they're much more rarely seen -// in the wild. But we're going to be forced into it if it's a multi-line symbol -// or if the quoting would get super complicated. -function shouldPrintPercentSDynaSymbol(node: Ruby.DynaSymbol) { - // We shouldn't print a %s dyna symbol if it was not already that way in the - // original source. - if (node.quote[0] !== "%") { - return false; - } - - // Here we're going to check if there is a closing character, a new line, or a - // quote in the content of the dyna symbol. If there is, then quoting could - // get weird, so just bail out and stick to the original bounds in the source. - const closing = quotePairs[node.quote[2] as Quote]; - - return node.body.some( - (child) => - child.type === "@tstring_content" && - (child.body.includes("\n") || - child.body.includes(closing) || - child.body.includes("'") || - child.body.includes('"')) - ); -} - -// Prints a dynamic symbol. Assumes there's a quote property attached to the -// node that will tell us which quote to use when printing. We're just going to -// use whatever quote was provided. -// -// In the case of a plain dyna symbol, node.quote will be either :" or :' -// For %s dyna symbols, node.quote will be %s[, %s(, %s{, or %s< -export const printDynaSymbol: Plugin.Printer = ( - path, - opts, - print -) => { - const node = path.getValue(); - - if (shouldPrintPercentSDynaSymbol(node)) { - return printPercentSDynaSymbol(path, opts, print); - } - - const parts = []; - let quote: string; - - if (isQuoteLocked(node)) { - if (node.quote.startsWith("%")) { - quote = opts.rubySingleQuote ? "'" : '"'; - } else if (node.quote.startsWith(":")) { - quote = node.quote.slice(1); - } else { - quote = node.quote; - } - } else { - quote = opts.rubySingleQuote && isSingleQuotable(node) ? "'" : '"'; - } - - parts.push(quote); - - path.each((childPath) => { - const child = childPath.getValue() as Ruby.StringContent; - - if (child.type !== "@tstring_content") { - parts.push(print(childPath)); - } else { - parts.push( - join(literalline, normalizeQuotes(child.body, quote).split("\n")) - ); - } - }, "body"); - - parts.push(quote); - - // If we're inside of an assoc_new node as the key, then it will handle - // printing the : on its own since it could change sides. - const parentNode = path.getParentNode(); - if (parentNode.type !== "assoc_new" || parentNode.body[0] !== node) { - parts.unshift(":"); - } - - return parts; -}; - -export const printStringConcat: Plugin.Printer = ( - path, - opts, - print -) => { - const [leftDoc, rightDoc] = path.map(print, "body"); - - return group([leftDoc, " \\", indent([hardline, rightDoc])]); -}; - -// Prints out an interpolated variable in the string by converting it into an -// embedded expression. -export const printStringDVar: Plugin.Printer = ( - path, - opts, - print -) => { - return ["#{", path.call(print, "body", 0), "}"]; -}; - -export const printStringEmbExpr: Plugin.Printer = ( - path, - opts, - print -) => { - const node = path.getValue(); - const parts = path.call(print, "body", 0); - - // If the contents of this embedded expression were originally on the same - // line in the source, then we're going to leave them in place and assume - // that's the way the developer wanted this expression represented. - if (node.sl === node.el) { - return ["#{", removeLines(parts), "}"]; - } - - return group(["#{", indent([softline, parts]), [softline, "}"]]); -}; - -// Prints out a literal string. This function does its best to respect the -// wishes of the user with regards to single versus double quotes, but if the -// string contains any escape expressions then it will just keep the original -// quotes. -export const printStringLiteral: Plugin.Printer = ( - path, - { rubySingleQuote }, - print -) => { - const node = path.getValue(); - - // If the string is empty, it will not have any parts, so just print out the - // quotes corresponding to the config - if (node.body.length === 0) { - return rubySingleQuote ? "''" : '""'; - } - - // Determine the quote that should enclose the new string - let quote: string; - if (isQuoteLocked(node)) { - quote = node.quote; - } else { - quote = rubySingleQuote && isSingleQuotable(node) ? "'" : '"'; - } - - const parts = path.map((partPath) => { - const part = partPath.getValue(); - - // In this case, the part of the string is an embedded expression - if (part.type !== "@tstring_content") { - return print(partPath); - } - - // In this case, the part of the string is just regular string content - return join(literalline, normalizeQuotes(part.body, quote).split("\n")); - }, "body"); - - return [quote, ...parts, getClosingQuote(quote)]; -}; - -// Prints out a symbol literal. Its child will always be the ident that -// represents the string content of the symbol. -export const printSymbolLiteral: Plugin.Printer = ( - path, - opts, - print -) => { - return [":", path.call(print, "body", 0)]; -}; - -// Prints out an xstring literal. Its child is an array of string parts, -// including plain string content and interpolated content. -export const printXStringLiteral: Plugin.Printer = ( - path, - opts, - print -) => { - return ["`", ...path.map(print, "body"), "`"]; -}; diff --git a/src/ruby/nodes/super.ts b/src/ruby/nodes/super.ts deleted file mode 100644 index db349c51..00000000 --- a/src/ruby/nodes/super.ts +++ /dev/null @@ -1,31 +0,0 @@ -import type { Plugin, Ruby } from "../../types"; -import prettier from "../../prettier"; -import { literal } from "../../utils"; - -const { align, group, join, line } = prettier; - -export const printSuper: Plugin.Printer = (path, opts, print) => { - const args = path.getValue().body[0]; - - if (args.type === "arg_paren") { - // In case there are explicitly no arguments but they are using parens, - // we assume they are attempting to override the initializer and pass no - // arguments up. - if (args.body[0] === null) { - return "super()"; - } - - return ["super", path.call(print, "body", 0)]; - } - - const keyword = "super "; - const argsDocs = path.call(print, "body", 0); - - return group([ - keyword, - align(keyword.length, group(join([",", line], argsDocs))) - ]); -}; - -// Version of super without any parens or args. -export const printZSuper = literal("super"); diff --git a/src/ruby/nodes/undef.ts b/src/ruby/nodes/undef.ts deleted file mode 100644 index 17cf8aa2..00000000 --- a/src/ruby/nodes/undef.ts +++ /dev/null @@ -1,33 +0,0 @@ -import type { Plugin, Ruby } from "../../types"; -import prettier from "../../prettier"; - -const { addTrailingComment, align, group, join, line } = prettier; - -const printUndefSymbol: Plugin.Printer = ( - path, - opts, - print -) => { - const node = path.getValue(); - - // Since we're going to descend into the symbol literal to grab out the ident - // node, then we need to make sure we copy over any comments as well, - // otherwise we could accidentally skip printing them. - if (node.comments) { - node.comments.forEach((comment) => { - addTrailingComment(node.body[0], comment); - }); - } - - return path.call(print, "body", 0); -}; - -export const printUndef: Plugin.Printer = (path, opts, print) => { - const keyword = "undef "; - const argNodes = path.map( - (symbolPath) => printUndefSymbol(symbolPath, opts, print), - "body" - ); - - return group([keyword, align(keyword.length, join([",", line], argNodes))]); -}; diff --git a/src/ruby/parser.rb b/src/ruby/parser.rb deleted file mode 100644 index 691998e9..00000000 --- a/src/ruby/parser.rb +++ /dev/null @@ -1,3636 +0,0 @@ -# frozen_string_literal: true - -# We implement our own version checking here instead of using Gem::Version so -# that we can use the --disable-gems flag. -RUBY_MAJOR, RUBY_MINOR, RUBY_PATCH, * = RUBY_VERSION.split('.').map(&:to_i) - -if (RUBY_MAJOR < 2) || ((RUBY_MAJOR == 2) && (RUBY_MINOR < 5)) - warn( - "Ruby version #{RUBY_VERSION} not supported. " \ - 'Please upgrade to 2.5.0 or above.' - ) - - exit 1 -end - -require 'json' unless defined?(JSON) -require 'ripper' - -# Ensure the module is already defined. This is mostly so that we don't have to -# indent the Parser definition one more time. -module Prettier -end - -class Prettier::Parser < Ripper - # Represents a line in the source. If this class is being used, it means that - # every character in the string is 1 byte in length, so we can just return the - # start of the line + the index. - class SingleByteString - def initialize(start) - @start = start - end - - def [](byteindex) - @start + byteindex - end - end - - # Represents a line in the source. If this class is being used, it means that - # there are characters in the string that are multi-byte, so we will build up - # an array of indices, such that array[byteindex] will be equal to the index - # of the character within the string. - class MultiByteString - def initialize(start, line) - @indices = [] - - line - .each_char - .with_index(start) do |char, index| - char.bytesize.times { @indices << index } - end - end - - def [](byteindex) - @indices[byteindex] - end - end - - # This is a small wrapper around the value of a node for those specific events - # that need extra handling. (For example: statement, body statement, and - # rescue nodes which all need extra information to determine their character - # boundaries.) - class Node - attr_reader :parser, :value - - def initialize(parser, value) - @parser = parser - @value = value - end - - def [](key) - value[key] - end - - def dig(*keys) - value.dig(*keys) - end - - def to_json(*opts) - value.to_json(*opts) - end - - def pretty_print(q) - q.pp_hash(self) - end - end - - # A special parser error so that we can get nice syntax displays on the error - # message when prettier prints out the results. - class ParserError < StandardError - attr_reader :lineno, :column - - def initialize(error, lineno, column) - super(error) - @lineno = lineno - @column = column - end - end - - attr_reader :source, :lines, :scanner_events - - # This is an attr_accessor so Stmts objects can grab comments out of this - # array and attach them to themselves. - attr_accessor :comments - - def initialize(source, *args) - super(source, *args) - - # We keep the source around so that we can refer back to it when we're - # generating the AST. Sometimes it's easier to just reference the source - # string when you want to check if it contains a certain character, for - # example. - @source = source - - # Similarly, we keep the lines of the source string around to be able to - # check if certain lines contain certain characters. For example, we'll use - # this to generate the content that goes after the __END__ keyword. Or we'll - # use this to check if a comment has other content on its line. - @lines = source.split("\n") - - # This is the full set of comments that have been found by the parser. It's - # a running list. At the end of every block of statements, they will go in - # and attempt to grab any comments that are on their own line and turn them - # into regular statements. So at the end of parsing the only comments left - # in here will be comments on lines that also contain code. - @comments = [] - - # This is the current embdoc (comments that start with =begin and end with - # =end). Since they can't be nested, there's no need for a stack here, as - # there can only be one active. These end up getting dumped into the - # comments list before getting picked up by the statements that surround - # them. - @embdoc = nil - - # This is an optional node that can be present if the __END__ keyword is - # used in the file. In that case, this will represent the content after that - # keyword. - @__end__ = nil - - # Heredocs can actually be nested together if you're using interpolation, so - # this is a stack of heredoc nodes that are currently being created. When we - # get to the scanner event that finishes off a heredoc node, we pop the top - # one off. If there are others surrounding it, then the body events will now - # be added to the correct nodes. - @heredocs = [] - - # This is a running list of scanner events that have fired. It's useful - # mostly for maintaining location information. For example, if you're inside - # the handle of a def event, then in order to determine where the AST node - # started, you need to look backward in the scanner events to find a def - # keyword. Most of the time, when a parser event consumes one of these - # events, it will be deleted from the list. So ideally, this list stays - # pretty short over the course of parsing a source string. - @scanner_events = [] - - # Here we're going to build up a list of SingleByteString or MultiByteString - # objects. They're each going to represent a string in the source. They are - # used by the `char_pos` method to determine where we are in the source - # string. - @line_counts = [] - last_index = 0 - - @source.lines.each do |line| - if line.size == line.bytesize - @line_counts << SingleByteString.new(last_index) - else - @line_counts << MultiByteString.new(last_index, line) - end - - last_index += line.size - end - end - - def self.parse(source) - builder = new(source) - - response = builder.parse - response unless builder.error? - end - - private - - # This represents the current place in the source string that we've gotten to - # so far. We have a memoized line_counts object that we can use to get the - # number of characters that we've had to go through to get to the beginning of - # this line, then we add the number of columns into this line that we've gone - # through. - def char_pos - @line_counts[lineno - 1][column] - end - - # As we build up a list of scanner events, we'll periodically need to go - # backwards and find the ones that we've already hit in order to determine the - # location information for nodes that use them. For example, if you have a - # module node then you'll look backward for a @module scanner event to - # determine your start location. - # - # This works with nesting since we're deleting scanner events from the list - # once they've been used up. For example if you had nested module declarations - # then the innermost declaration would grab the last @module event (which - # would happen to be the innermost keyword). Then the outer one would only be - # able to grab the first one. In this way all of the scanner events act as - # their own stack. - def find_scanner_event(type, body = :any, consume: true) - index = - scanner_events.rindex do |scanner_event| - scanner_event[:type] == type && - (body == :any || (scanner_event[:body] == body)) - end - - if consume - # If we're expecting to be able to find a scanner event and consume it, - # but can't actually find it, then we need to raise an error. This is - # _usually_ caused by a syntax error in the source that we're printing. It - # could also be caused by accidentally attempting to consume a scanner - # event twice by two different parser event handlers. - unless index - message = "Cannot find expected #{body == :any ? type : body}" - raise ParserError.new(message, lineno, column) - end - - scanner_events.delete_at(index) - elsif index - scanner_events[index] - end - end - - # A helper function to find a :: operator. We do special handling instead of - # using find_scanner_event here because we don't pop off all of the :: - # operators so you could end up getting the wrong information if you have for - # instance ::X::Y::Z. - def find_colon2_before(const) - index = - scanner_events.rindex do |event| - event[:type] == :@op && event[:body] == '::' && event[:sc] < const[:sc] - end - - scanner_events[index] - end - - # Finds the next position in the source string that begins a statement. This - # is used to bind statements lists and make sure they don't include a - # preceding comment. For example, we want the following comment to be attached - # to the class node and not the statement node: - # - # class Foo # :nodoc: - # ... - # end - # - # By finding the next non-space character, we can make sure that the bounds of - # the statement list are correct. - def find_next_statement_start(position) - remaining = source[position..-1] - - if remaining.sub(/\A +/, '')[0] == '#' - return position + remaining.index("\n") - end - - position - end - - # BEGIN is a parser event that represents the use of the BEGIN keyword, which - # hooks into the lifecycle of the interpreter. Whatever is inside the "block" - # will get executed when the program starts. The syntax looks like the - # following: - # - # BEGIN { - # # execute stuff here - # } - # - def on_BEGIN(stmts) - beging = find_scanner_event(:@lbrace) - ending = find_scanner_event(:@rbrace) - - stmts.bind(find_next_statement_start(beging[:ec]), ending[:sc]) - - find_scanner_event(:@kw, 'BEGIN').merge!( - type: :BEGIN, - body: [beging, stmts], - el: ending[:el], - ec: ending[:ec] - ) - end - - # CHAR is a parser event that represents a single codepoint in the script - # encoding. For example: - # - # ?a - # - # is a representation of the string literal "a". You can use control - # characters with this as well, as in ?\C-a. - # - def on_CHAR(value) - start_line = lineno - start_char = char_pos - - node = { - type: :@CHAR, - body: value, - sl: start_line, - el: start_line, - sc: start_char, - ec: start_char + value.size - } - - scanner_events << node - node - end - - # END is a parser event that represents the use of the END keyword, which - # hooks into the lifecycle of the interpreter. Whatever is inside the "block" - # will get executed when the program ends. The syntax looks like the - # following: - # - # END { - # # execute stuff here - # } - # - def on_END(stmts) - beging = find_scanner_event(:@lbrace) - ending = find_scanner_event(:@rbrace) - - stmts.bind(find_next_statement_start(beging[:ec]), ending[:sc]) - - find_scanner_event(:@kw, 'END').merge!( - type: :END, - body: [beging, stmts], - el: ending[:el], - ec: ending[:ec] - ) - end - - # __END__ is a scanner event that represents __END__ syntax, which allows - # individual scripts to keep content after the main ruby code that can be read - # through the DATA constant. It looks like: - # - # puts DATA.read - # - # __END__ - # some other content that isn't executed by the program - # - def on___end__(value) - start_line = lineno - start_char = char_pos - - @__end__ = { - type: :@__end__, - body: lines[lineno..-1].join("\n"), - sl: start_line, - el: start_line, - sc: start_char, - ec: start_char + value.size - } - end - - # alias is a parser event that represents the use of the alias keyword with - # regular arguments. This can be either symbol literals or bare words. You can - # optionally use parentheses with this keyword, so we either track the - # location information based on those or the final argument to the alias - # method. - def on_alias(left, right) - beging = find_scanner_event(:@kw, 'alias') - - paren = source[beging[:ec]...left[:sc]].include?('(') - ending = paren ? find_scanner_event(:@rparen) : right - - { - type: :alias, - body: [left, right], - sl: beging[:sl], - sc: beging[:sc], - el: ending[:el], - ec: ending[:ec] - } - end - - # aref is a parser event when you're pulling a value out of a collection at a - # specific index. Put another way, it's any time you're calling the method - # #[]. As an example: - # - # foo[index] - # - # The nodes usually contains two children, the collection and the index. - # In some cases, you don't necessarily have the second child node, because - # you can call procs with a pretty esoteric syntax. In the following - # example, you wouldn't have a second child, and "foo" would be the first - # child: - # - # foo[] - # - def on_aref(collection, index) - find_scanner_event(:@lbracket) - ending = find_scanner_event(:@rbracket) - - { - type: :aref, - body: [collection, index], - sl: collection[:sl], - sc: collection[:sc], - el: ending[:el], - ec: ending[:ec] - } - end - - # aref_field is a parser event that is very similar to aref except that it - # is being used inside of an assignment. - def on_aref_field(collection, index) - find_scanner_event(:@lbracket) - ending = find_scanner_event(:@rbracket) - - { - type: :aref_field, - body: [collection, index], - sl: collection[:sl], - sc: collection[:sc], - el: ending[:el], - ec: ending[:ec] - } - end - - # arg_ambiguous is a parser event that represents when the parser sees an - # argument as ambiguous. For example, in the following snippet: - # - # foo // - # - # the question becomes if the forward slash is being used as a division - # operation or if it's the start of a regular expression. We don't need to - # track this event in the AST that we're generating, so we're not going to - # define an explicit handler for it. - # - # def on_arg_ambiguous(value) - # value - # end - - # arg_paren is a parser event that represents wrapping arguments to a method - # inside a set of parentheses. For example, in the follow snippet: - # - # foo(bar) - # - # there would be an arg_paren node around the args_add_block node that - # represents the set of arguments being sent to the foo method. The args child - # node can be nil if no arguments were passed, as in: - # - # foo() - # - def on_arg_paren(args) - beging = find_scanner_event(:@lparen) - rparen = find_scanner_event(:@rparen) - - # If the arguments exceed the ending of the parentheses, then we know we - # have a heredoc in the arguments, and we need to use the bounds of the - # arguments to determine how large the arg_paren is. - ending = (args && args[:el] > rparen[:el]) ? args : rparen - - { - type: :arg_paren, - body: [args], - sl: beging[:sl], - sc: beging[:sc], - el: ending[:el], - ec: ending[:ec] - } - end - - # args_add is a parser event that represents a single argument inside a list - # of arguments to any method call or an array. It accepts as arguments the - # parent args node as well as an arg which can be anything that could be - # passed as an argument. - def on_args_add(args, arg) - if args[:body].empty? - # If this is the first argument being passed into the list of arguments, - # then we're going to use the bounds of the argument to override the - # parent node's location since this will be more accurate. - arg.merge(type: :args, body: [arg]) - else - args.merge!(body: args[:body] << arg, el: arg[:el], ec: arg[:ec]) - end - end - - # args_add_block is a parser event that represents a list of arguments and - # potentially a block argument. If no block is passed, then the second - # argument will be the literal false. - def on_args_add_block(args, block) - ending = block || args - - args.merge( - type: :args_add_block, - body: [args, block], - el: ending[:el], - ec: ending[:ec] - ) - end - - # args_add_star is a parser event that represents adding a splat of values - # to a list of arguments. If accepts as arguments the parent args node as - # well as the part that is being splatted. - def on_args_add_star(args, part) - beging = find_scanner_event(:@op, '*') - ending = part || beging - - { - type: :args_add_star, - body: [args, part], - sl: beging[:sl], - sc: beging[:sc], - el: ending[:el], - ec: ending[:ec] - } - end - - # args_forward is a parser event that represents forwarding all kinds of - # arguments onto another method call. - def on_args_forward - find_scanner_event(:@op, '...').merge!(type: :args_forward) - end - - # args_new is a parser event that represents the beginning of a list of - # arguments to any method call or an array. It can be followed by any - # number of args_add events, which we'll append onto an array body. - def on_args_new - { - type: :args, - body: [], - sl: lineno, - sc: char_pos, - el: lineno, - ec: char_pos - } - end - - # Array nodes can contain a myriad of subnodes because of the special - # array literal syntax like %w and %i. As a result, we may be looking for - # an left bracket, or we may be just looking at the children to get the - # bounds. - def on_array(contents) - if !contents || %i[args args_add_star].include?(contents[:type]) - beging = find_scanner_event(:@lbracket) - ending = find_scanner_event(:@rbracket) - - { - type: :array, - body: [contents], - sl: beging[:sl], - sc: beging[:sc], - el: ending[:el], - ec: ending[:ec] - } - else - ending = find_scanner_event(:@tstring_end) - contents[:ec] = ending[:ec] - - ending.merge!( - type: :array, - body: [contents], - sl: contents[:sl], - sc: contents[:sc] - ) - end - end - - # aryptn is a parser event that represents matching against an array pattern - # using the Ruby 2.7+ pattern matching syntax. - def on_aryptn(const, preargs, splatarg, postargs) - pieces = [const, *preargs, splatarg, *postargs].compact - - { - type: :aryptn, - body: [const, preargs, splatarg, postargs], - sl: pieces[0][:sl], - sc: pieces[0][:sc], - el: pieces[-1][:el], - ec: pieces[-1][:ec] - } - end - - # assign is a parser event that represents assigning something to a - # variable or constant. It accepts as arguments the left side of the - # expression before the equals sign and the right side of the expression. - def on_assign(left, right) - left.merge( - type: :assign, - body: [left, right], - el: right[:el], - ec: right[:ec] - ) - end - - # assoc_new is a parser event that contains a key-value pair within a - # hash. It is a child event of either an assoclist_from_args or a - # bare_assoc_hash. - def on_assoc_new(key, value) - { - type: :assoc_new, - body: [key, value], - sl: key[:sl], - sc: key[:sc], - el: value[:el], - ec: value[:ec] - } - end - - # assoc_splat is a parser event that represents splatting a value into a - # hash (either a hash literal or a bare hash in a method call). - def on_assoc_splat(contents) - find_scanner_event(:@op, '**').merge!( - type: :assoc_splat, - body: [contents], - el: contents[:el], - ec: contents[:ec] - ) - end - - # assoclist_from_args is a parser event that contains a list of all of the - # associations inside of a hash literal. Its parent node is always a hash. - # It accepts as an argument an array of assoc events (either assoc_new or - # assoc_splat). - def on_assoclist_from_args(assocs) - { - type: :assoclist_from_args, - body: assocs, - sl: assocs[0][:sl], - sc: assocs[0][:sc], - el: assocs[-1][:el], - ec: assocs[-1][:ec] - } - end - - # backref is a scanner event that represents a global variable referencing a - # matched value. It comes in the form of a $ followed by a positive integer. - def on_backref(value) - start_line = lineno - start_char = char_pos - - node = { - type: :@backref, - body: value, - sl: start_line, - el: start_line, - sc: start_char, - ec: start_char + value.size - } - - scanner_events << node - node - end - - # backtick is a scanner event that represents the use of the ` operator. It's - # usually found being used for an xstring, but could also be found as the name - # of a method being defined. - def on_backtick(value) - start_line = lineno - start_char = char_pos - - node = { - type: :@backtick, - body: value, - sl: start_line, - el: start_line, - sc: start_char, - ec: start_char + value.size - } - - scanner_events << node - node - end - - # bare_assoc_hash is a parser event that represents a hash of contents - # being passed as a method argument (and therefore has omitted braces). It - # accepts as an argument an array of assoc events (either assoc_new or - # assoc_splat). - def on_bare_assoc_hash(assoc_news) - { - type: :bare_assoc_hash, - body: assoc_news, - sl: assoc_news[0][:sl], - sc: assoc_news[0][:sc], - el: assoc_news[-1][:el], - ec: assoc_news[-1][:ec] - } - end - - # begin is a parser event that represents the beginning of a begin..end chain. - # It includes a bodystmt event that has all of the consequent clauses. - def on_begin(bodystmt) - beging = find_scanner_event(:@kw, 'begin') - ec = - if bodystmt[:body][1..-1].any? - bodystmt[:ec] - else - find_scanner_event(:@kw, 'end')[:ec] - end - - bodystmt.bind(beging[:ec], ec) - - beging.merge!( - type: :begin, - body: [bodystmt], - el: bodystmt[:el], - ec: bodystmt[:ec] - ) - end - - # binary is a parser event that represents a binary operation between two - # values. - def on_binary(left, oper, right) - # On most Ruby implementations, oper is a Symbol that represents that - # operation being performed. For instance in the example `1 < 2`, the `oper` - # object would be `:<`. However, on JRuby, it's an `@op` node, so here we're - # going to explicitly convert it into the same normalized form. - oper = scanner_events.delete(oper)[:body] unless oper.is_a?(Symbol) - - { - type: :binary, - body: [left, oper, right], - sl: left[:sl], - sc: left[:sc], - el: right[:el], - ec: right[:ec] - } - end - - # block_var is a parser event that represents the parameters being passed to - # block. Effectively they're everything contained within the pipes. - def on_block_var(params, locals) - index = - scanner_events.rindex do |event| - event[:type] == :@op && %w[| ||].include?(event[:body]) && - event[:sc] < params[:sc] - end - - beging = scanner_events[index] - ending = scanner_events[-1] - - { - type: :block_var, - body: [params, locals], - sl: beging[:sl], - sc: beging[:sc], - el: ending[:el], - ec: ending[:ec] - } - end - - # blockarg is a parser event that represents defining a block variable on - # a method definition. - def on_blockarg(ident) - find_scanner_event(:@op, '&').merge!( - type: :blockarg, - body: [ident], - el: ident[:el], - ec: ident[:ec] - ) - end - - # bodystmt can't actually determine its bounds appropriately because it - # doesn't necessarily know where it started. So the parent node needs to - # report back down into this one where it goes. - class BodyStmt < Node - def bind(sc, ec) - value.merge!(sc: sc, ec: ec) - parts = value[:body] - - # Here we're going to determine the bounds for the stmts - consequent = parts[1..-1].compact.first - value[:body][0].bind(sc, consequent ? consequent[:sc] : ec) - - # Next we're going to determine the rescue clause if there is one - if parts[1] - consequent = parts[2..-1].compact.first - value[:body][1].bind_end(consequent ? consequent[:sc] : ec) - end - end - end - - # bodystmt is a parser event that represents all of the possible combinations - # of clauses within the body of a method or block. - def on_bodystmt(stmts, rescued, ensured, elsed) - BodyStmt.new( - self, - type: :bodystmt, - body: [stmts, rescued, ensured, elsed], - sl: lineno, - sc: char_pos, - el: lineno, - ec: char_pos - ) - end - - # brace_block is a parser event that represents passing a block to a - # method call using the {..} operators. It accepts as arguments an - # optional block_var event that represents any parameters to the block as - # well as a stmts event that represents the statements inside the block. - def on_brace_block(block_var, stmts) - beging = find_scanner_event(:@lbrace) - ending = find_scanner_event(:@rbrace) - - stmts.bind( - find_next_statement_start((block_var || beging)[:ec]), - ending[:sc] - ) - - { - type: :brace_block, - body: [block_var, stmts], - beging: beging, - sl: beging[:sl], - sc: beging[:sc], - el: [ending[:el], stmts[:el]].max, - ec: ending[:ec] - } - end - - # break is a parser event that represents using the break keyword. It - # accepts as an argument an args or args_add_block event that contains all - # of the arguments being passed to the break. - def on_break(args_add_block) - beging = find_scanner_event(:@kw, 'break') - - # You can hit this if you are passing no arguments to break but it has a - # comment right after it. In that case we can just use the location - # information straight from the keyword. - if args_add_block[:type] == :args - return beging.merge!(type: :break, body: [args_add_block]) - end - - beging.merge!( - type: :break, - body: [args_add_block], - el: args_add_block[:el], - ec: args_add_block[:ec] - ) - end - - # call is a parser event representing a method call with no arguments. It - # accepts as arguments the receiver of the method, the operator being used - # to send the method (., ::, or &.), and the value that is being sent to - # the receiver (which can be another nested call as well). - # - # There is one esoteric syntax that comes into play here as well. If the - # sending argument to this method is the symbol :call, then it represents - # calling a lambda in a very odd looking way, as in: - # - # foo.(1, 2, 3) - # - def on_call(receiver, oper, sending) - ending = sending - - if sending == :call - ending = oper - - # Special handling here for Ruby <= 2.5 because the oper argument to this - # method wasn't a parser event here it was just a plain symbol. - ending = receiver if RUBY_MAJOR <= 2 && RUBY_MINOR <= 5 - end - - { - type: :call, - body: [receiver, oper, sending], - sl: receiver[:sl], - sc: receiver[:sc], - el: [ending[:el], receiver[:el]].max, - ec: ending[:ec] - } - end - - # case is a parser event that represents the beginning of a case chain. - # It accepts as arguments the switch of the case and the consequent - # clause. - def on_case(switch, consequent) - beging = - if event = find_scanner_event(:@kw, 'case', consume: false) - scanner_events.delete(event).merge!(type: :case) - else - keyword = find_scanner_event(:@kw, 'in', consume: false) - switch.merge(type: :rassign, keyword: keyword) - end - - beging.merge!( - body: [switch, consequent], - el: consequent[:el], - ec: consequent[:ec] - ) - end - - # class is a parser event that represents defining a class. It accepts as - # arguments the name of the class, the optional name of the superclass, - # and the bodystmt event that represents the statements evaluated within - # the context of the class. - def on_class(const, superclass, bodystmt) - beging = find_scanner_event(:@kw, 'class') - ending = find_scanner_event(:@kw, 'end') - - bodystmt.bind( - find_next_statement_start((superclass || const)[:ec]), - ending[:sc] - ) - - { - type: :class, - body: [const, superclass, bodystmt], - sl: beging[:sl], - sc: beging[:sc], - el: ending[:el], - ec: ending[:ec] - } - end - - # comma is a scanner event that represents the use of the comma operator. - def on_comma(value) - start_line = lineno - start_char = char_pos - - node = { - type: :@comma, - body: value, - sl: start_line, - el: start_line, - sc: start_char, - ec: start_char + value.size - } - - scanner_events << node - node - end - - # command is a parser event representing a method call with arguments and - # no parentheses. It accepts as arguments the name of the method and the - # arguments being passed to the method. - def on_command(ident, args) - { - type: :command, - body: [ident, args], - sl: ident[:sl], - sc: ident[:sc], - el: args[:el], - ec: args[:ec] - } - end - - # command_call is a parser event representing a method call on an object - # with arguments and no parentheses. It accepts as arguments the receiver - # of the method, the operator being used to send the method, the name of - # the method, and the arguments being passed to the method. - def on_command_call(receiver, oper, ident, args) - ending = args || ident - - { - type: :command_call, - body: [receiver, oper, ident, args], - sl: receiver[:sl], - sc: receiver[:sc], - el: ending[:el], - ec: ending[:ec] - } - end - - # We keep track of each comment as it comes in and then eventually add - # them to the top of the generated AST so that prettier can start adding - # them back into the final representation. Comments come in including - # their starting pound sign and the newline at the end, so we also chop - # those off. - def on_comment(value) - # If there is an encoding magic comment at the top of the file, ripper - # will actually change into that encoding for the storage of the string. - # This will break everything when we attempt to print as JSON, so we need to - # force the encoding back into UTF-8 so that it won't break. - body = value[1..-1].chomp.force_encoding('UTF-8') - - start_line = lineno - start_char = char_pos - - @comments << { - type: :@comment, - value: body, - inline: value.strip != lines[lineno - 1], - sl: start_line, - el: start_line, - sc: start_char, - ec: start_char + value.length - 1 - } - end - - # const is a scanner event that represents a literal value that _looks like_ - # a constant. This could actually be a reference to a constant. It could also - # be something that looks like a constant in another context, as in a method - # call to a capitalized method, a symbol that starts with a capital letter, - # etc. - def on_const(value) - start_line = lineno - start_char = char_pos - - node = { - type: :@const, - body: value, - sl: start_line, - el: start_line, - sc: start_char, - ec: start_char + value.size - } - - scanner_events << node - node - end - - # A const_path_field is a parser event that is always the child of some - # kind of assignment. It represents when you're assigning to a constant - # that is being referenced as a child of another variable. For example: - # - # foo::X = 1 - # - def on_const_path_field(left, const) - { - type: :const_path_field, - body: [left, const], - sl: left[:sl], - sc: left[:sc], - el: const[:el], - ec: const[:ec] - } - end - - # A const_path_ref is a parser event that is a very similar to - # const_path_field except that it is not involved in an assignment. It - # looks like the following example: foo::Bar, where left is foo and const is - # Bar. - def on_const_path_ref(left, const) - { - type: :const_path_ref, - body: [left, const], - sl: left[:sl], - sc: left[:sc], - el: const[:el], - ec: const[:ec] - } - end - - # A const_ref is a parser event that represents the name of the constant - # being used in a class or module declaration. In the following example it - # is the @const scanner event that has the contents of Foo. - # - # class Foo; end - # - def on_const_ref(const) - const.merge(type: :const_ref, body: [const]) - end - - # cvar is a scanner event that represents the use of a class variable. - def on_cvar(value) - start_line = lineno - start_char = char_pos - - node = { - type: :@cvar, - body: value, - sl: start_line, - el: start_line, - sc: start_char, - ec: start_char + value.size - } - - scanner_events << node - node - end - - # A def is a parser event that represents defining a regular method on the - # current self object. It accepts as arguments the ident (the name of the - # method being defined), the params (the parameter declaration for the - # method), and a bodystmt node which represents the statements inside the - # method. As an example, here are the parts that go into this: - # - # def foo(bar) do baz end - # │ │ │ - # │ │ └> bodystmt - # │ └> params - # └> ident - # - # You can also have single-line methods since Ruby 3.0+, which have slightly - # different syntax but still flow through this method. Those look like: - # - # def foo = bar - # | | - # | └> stmt - # └> ident - # - def on_def(ident, params, bodystmt) - # Make sure to delete this scanner event in case you're defining something - # like def class which would lead to this being a kw and causing all kinds - # of trouble - scanner_events.delete(ident) - - # Find the beginning of the method definition, which works for single-line - # and normal method definitions. - beging = find_scanner_event(:@kw, 'def') - - # If we don't have a bodystmt node, then we have a single-line method - if bodystmt[:type] != :bodystmt - return( - { - type: :defsl, - body: [ident, params, bodystmt], - sl: beging[:sl], - sc: beging[:sc], - el: bodystmt[:el], - ec: bodystmt[:ec] - } - ) - end - - if params[:type] == :params && !params[:body].any? - location = ident[:ec] - params.merge!(sc: location, ec: location) - end - - ending = find_scanner_event(:@kw, 'end') - - bodystmt.bind(find_next_statement_start(params[:ec]), ending[:sc]) - - { - type: :def, - body: [ident, params, bodystmt], - sl: beging[:sl], - sc: beging[:sc], - el: ending[:el], - ec: ending[:ec] - } - end - - # A defs is a parser event that represents defining a singleton method on - # an object. It accepts the same arguments as the def event, as well as - # the target and operator that on which this method is being defined. As - # an example, here are the parts that go into this: - # - # def foo.bar(baz) do baz end - # │ │ │ │ │ - # │ │ │ │ │ - # │ │ │ │ └> bodystmt - # │ │ │ └> params - # │ │ └> ident - # │ └> oper - # └> target - # - def on_defs(target, oper, ident, params, bodystmt) - # Make sure to delete this scanner event in case you're defining something - # like def class which would lead to this being a kw and causing all kinds - # of trouble - scanner_events.delete(ident) - - if params[:type] == :params && !params[:body].any? - location = ident[:ec] - params.merge!(sc: location, ec: location) - end - - beging = find_scanner_event(:@kw, 'def') - ending = find_scanner_event(:@kw, 'end') - - bodystmt.bind(find_next_statement_start(params[:ec]), ending[:sc]) - - { - type: :defs, - body: [target, oper, ident, params, bodystmt], - sl: beging[:sl], - sc: beging[:sc], - el: ending[:el], - ec: ending[:ec] - } - end - - # A defined node represents the rather unique defined? operator. It can be - # used with and without parentheses. If they're present, we use them to - # determine our bounds, otherwise we use the value that's being passed to - # the operator. - def on_defined(value) - beging = find_scanner_event(:@kw, 'defined?') - - paren = source[beging[:ec]...value[:sc]].include?('(') - ending = paren ? find_scanner_event(:@rparen) : value - - beging.merge!( - type: :defined, - body: [value], - el: ending[:el], - ec: ending[:ec] - ) - end - - # do_block is a parser event that represents passing a block to a method - # call using the do..end keywords. It accepts as arguments an optional - # block_var event that represents any parameters to the block as well as - # a bodystmt event that represents the statements inside the block. - def on_do_block(block_var, bodystmt) - beging = find_scanner_event(:@kw, 'do') - ending = find_scanner_event(:@kw, 'end') - - bodystmt.bind( - find_next_statement_start((block_var || beging)[:ec]), - ending[:sc] - ) - - { - type: :do_block, - body: [block_var, bodystmt], - beging: beging, - sl: beging[:sl], - sc: beging[:sc], - el: ending[:el], - ec: ending[:ec] - } - end - - # dot2 is a parser event that represents using the .. operator between two - # expressions. Usually this is to create a range object but sometimes it's to - # use the flip-flop operator. - def on_dot2(left, right) - operator = find_scanner_event(:@op, '..') - - beging = left || operator - ending = right || operator - - { - type: :dot2, - body: [left, right], - sl: beging[:sl], - sc: beging[:sc], - el: ending[:el], - ec: ending[:ec] - } - end - - # dot3 is a parser event that represents using the ... operator between two - # expressions. Usually this is to create a range object but sometimes it's to - # use the flip-flop operator. - def on_dot3(left, right) - operator = find_scanner_event(:@op, '...') - - beging = left || operator - ending = right || operator - - { - type: :dot3, - body: [left, right], - sl: beging[:sl], - sc: beging[:sc], - el: ending[:el], - ec: ending[:ec] - } - end - - # A dyna_symbol is a parser event that represents a symbol literal that - # uses quotes to interpolate its value. For example, if you had a variable - # foo and you wanted a symbol that contained its value, you would write: - # - # :"#{foo}" - # - # As such, they accept as one argument a string node, which is the same - # node that gets accepted into a string_literal (since we're basically - # talking about a string literal with a : character at the beginning). - # - # They can also come in another flavor which is a dynamic symbol as a hash - # key. This is kind of an interesting syntax which results in us having to - # look for a @label_end scanner event instead to get our bearings. That - # kind of code would look like: - # - # { "#{foo}": bar } - # - # which would be the same symbol as above. - def on_dyna_symbol(string) - if find_scanner_event(:@symbeg, consume: false) - # A normal dynamic symbol - beging = find_scanner_event(:@symbeg) - ending = find_scanner_event(:@tstring_end) - - beging.merge( - type: :dyna_symbol, - quote: beging[:body], - body: string[:body], - el: ending[:el], - ec: ending[:ec] - ) - else - # A dynamic symbol as a hash key - beging = find_scanner_event(:@tstring_beg) - ending = find_scanner_event(:@label_end) - - string.merge!( - type: :dyna_symbol, - quote: ending[:body][0], - sl: beging[:sl], - sc: beging[:sc], - el: ending[:el], - ec: ending[:ec] - ) - end - end - - # else is a parser event that represents the end of a if, unless, or begin - # chain. It accepts as an argument the statements that are contained - # within the else clause. - def on_else(stmts) - beging = find_scanner_event(:@kw, 'else') - - # else can either end with an end keyword (in which case we'll want to - # consume that event) or it can end with an ensure keyword (in which case - # we'll leave that to the ensure to handle). - index = - scanner_events.rindex do |event| - event[:type] == :@kw && %w[end ensure].include?(event[:body]) - end - - event = scanner_events[index] - ending = event[:body] == 'end' ? scanner_events.delete_at(index) : event - - stmts.bind(beging[:ec], ending[:sc]) - - { - type: :else, - body: [stmts], - sl: beging[:sl], - sc: beging[:sc], - el: ending[:el], - ec: ending[:ec] - } - end - - # elsif is a parser event that represents another clause in an if chain. - # It accepts as arguments the predicate of the else if, the statements - # that are contained within the else if clause, and the optional - # consequent clause. - def on_elsif(predicate, stmts, consequent) - beging = find_scanner_event(:@kw, 'elsif') - ending = consequent || find_scanner_event(:@kw, 'end') - - stmts.bind(predicate[:ec], ending[:sc]) - - { - type: :elsif, - body: [predicate, stmts, consequent], - sl: beging[:sl], - sc: beging[:sc], - el: ending[:el], - ec: ending[:ec] - } - end - - # This is a scanner event that gets hit when we're inside an embdoc and - # receive a new line of content. Here we are guaranteed to already have - # initialized the @embdoc variable so we can just append the new line onto - # the existing content. - def on_embdoc(value) - @embdoc[:value] << value - end - - # embdocs are long comments that are surrounded by =begin..=end. They - # cannot be nested, so we don't need to worry about keeping a stack around - # like we do with heredocs. Instead we can just track the current embdoc - # and add to it as we get content. It always starts with this scanner - # event, so here we'll initialize the current embdoc. - def on_embdoc_beg(value) - @embdoc = { type: :@embdoc, value: value, sl: lineno, sc: char_pos } - end - - # This is the final scanner event for embdocs. It receives the =end. Here - # we can finalize the embdoc with its location information and the final - # piece of the string. We then add it to the list of comments so that - # prettier can place it into the final source string. - def on_embdoc_end(value) - @comments << - @embdoc.merge!( - value: @embdoc[:value] << value.chomp, - el: lineno, - ec: char_pos + value.length - 1 - ) - - @embdoc = nil - end - - # embexpr_beg is a scanner event that represents using interpolation inside of - # a string, xstring, heredoc, or regexp. Its value is the string literal "#{". - def on_embexpr_beg(value) - start_line = lineno - start_char = char_pos - - node = { - type: :@embexpr_beg, - body: value, - sl: start_line, - el: start_line, - sc: start_char, - ec: start_char + value.size - } - - scanner_events << node - node - end - - # embexpr_end is a scanner event that represents the end of an interpolated - # expression in a string, xstring, heredoc, or regexp. Its value is the string - # literal "}". - def on_embexpr_end(value) - start_line = lineno - start_char = char_pos - - node = { - type: :@embexpr_end, - body: value, - sl: start_line, - el: start_line, - sc: start_char, - ec: start_char + value.size - } - - scanner_events << node - node - end - - # embvar is a scanner event that represents the use of shorthand interpolation - # for an instance, class, or global variable into a string, xstring, heredoc, - # or regexp. Its value is the string literal "#". For example, in the - # following snippet: - # - # "#@foo" - # - # the embvar would be triggered by the "#", then an ivar event for the @foo - # instance variable. That would all get bound up into a string_dvar node in - # the final AST. - def on_embvar(value) - start_line = lineno - start_char = char_pos - - node = { - type: :@embvar, - body: value, - sl: start_line, - el: start_line, - sc: start_char, - ec: start_char + value.size - } - - scanner_events << node - node - end - - # ensure is a parser event that represents the use of the ensure keyword - # and its subsequent statements. - def on_ensure(stmts) - beging = find_scanner_event(:@kw, 'ensure') - - # Specifically not using find_scanner_event here because we don't want to - # consume the :@end event, because that would break def..ensure..end chains. - index = - scanner_events.rindex do |scanner_event| - scanner_event[:type] == :@kw && scanner_event[:body] == 'end' - end - - ending = scanner_events[index] - stmts.bind(find_next_statement_start(beging[:ec]), ending[:sc]) - - { - type: :ensure, - body: [beging, stmts], - sl: beging[:sl], - sc: beging[:sc], - el: ending[:el], - ec: ending[:ec] - } - end - - # An excessed_comma is a special kind of parser event that represents a comma - # at the end of a list of parameters. It's a very strange node. It accepts a - # different number of arguments depending on Ruby version, which is why we - # have the anonymous splat there. - def on_excessed_comma(*) - find_scanner_event(:@comma).merge!(type: :excessed_comma) - end - - # An fcall is a parser event that represents the piece of a method call - # that comes before any arguments (i.e., just the name of the method). - def on_fcall(ident) - ident.merge(type: :fcall, body: [ident]) - end - - # A field is a parser event that is always the child of an assignment. It - # accepts as arguments the left side of operation, the operator (. or ::), - # and the right side of the operation. For example: - # - # foo.x = 1 - # - def on_field(left, oper, right) - { - type: :field, - body: [left, oper, right], - sl: left[:sl], - sc: left[:sc], - el: right[:el], - ec: right[:ec] - } - end - - # float is a scanner event that represents a floating point value literal. - def on_float(value) - start_line = lineno - start_char = char_pos - - node = { - type: :@float, - body: value, - sl: start_line, - el: start_line, - sc: start_char, - ec: start_char + value.size - } - - scanner_events << node - node - end - - # fndptn is a parser event that represents matching against a pattern where - # you find a pattern in an array using the Ruby 3.0+ pattern matching syntax. - def on_fndptn(const, presplat, args, postsplat) - beging = const || find_scanner_event(:@lbracket) - ending = find_scanner_event(:@rbracket) - - { - type: :fndptn, - body: [const, presplat, args, postsplat], - sl: beging[:sl], - sc: beging[:sc], - el: ending[:el], - ec: ending[:ec] - } - end - - # for is a parser event that represents using the somewhat esoteric for - # loop. It accepts as arguments an ident which is the iterating variable, - # an enumerable for that which is being enumerated, and a stmts event that - # represents the statements inside the for loop. - def on_for(ident, enum, stmts) - beging = find_scanner_event(:@kw, 'for') - ending = find_scanner_event(:@kw, 'end') - - # Consume the do keyword if it exists so that it doesn't get confused for - # some other block - do_event = find_scanner_event(:@kw, 'do', consume: false) - if do_event && do_event[:sc] > enum[:ec] && do_event[:ec] < ending[:sc] - scanner_events.delete(do_event) - end - - stmts.bind((do_event || enum)[:ec], ending[:sc]) - - { - type: :for, - body: [ident, enum, stmts], - sl: beging[:sl], - sc: beging[:sc], - el: ending[:el], - ec: ending[:ec] - } - end - - # gvar is a scanner event that represents a global variable literal. - def on_gvar(value) - start_line = lineno - start_char = char_pos - - node = { - type: :@gvar, - body: value, - sl: start_line, - el: start_line, - sc: start_char, - ec: start_char + value.size - } - - scanner_events << node - node - end - - # hash is a parser event that represents a hash literal. It accepts as an - # argument an optional assoclist_from_args event which contains the - # contents of the hash. - def on_hash(assoclist_from_args) - beging = find_scanner_event(:@lbrace) - ending = find_scanner_event(:@rbrace) - - if assoclist_from_args - # Here we're going to expand out the location information for the assocs - # node so that it can grab up any remaining comments inside the hash. - assoclist_from_args.merge!(sc: beging[:ec], ec: ending[:sc]) - end - - { - type: :hash, - body: [assoclist_from_args], - sl: beging[:sl], - sc: beging[:sc], - el: ending[:el], - ec: ending[:ec] - } - end - - # This is a scanner event that represents the beginning of the heredoc. It - # includes the declaration (which we call beging here, which is just short - # for beginning). The declaration looks something like <<-HERE or <<~HERE. - # If the downcased version of the declaration actually matches an existing - # prettier parser, we'll later attempt to print it using that parser and - # printer through our embed function. - def on_heredoc_beg(beging) - location = { - sl: lineno, - el: lineno, - sc: char_pos, - ec: char_pos + beging.length + 1 - } - - # Here we're going to artificially create an extra node type so that if - # there are comments after the declaration of a heredoc, they get printed. - location - .merge( - type: :heredoc, - beging: location.merge(type: :@heredoc_beg, body: beging) - ) - .tap { |node| @heredocs << node } - end - - # This is a parser event that occurs when you're using a heredoc with a - # tilde. These are considered `heredoc_dedent` nodes, whereas the hyphen - # heredocs show up as string literals. - def on_heredoc_dedent(string, _width) - @heredocs[-1].merge!(body: string[:body]) - end - - # This is a scanner event that represents the end of the heredoc. - def on_heredoc_end(ending) - @heredocs[-1].merge!(ending: ending.chomp, el: lineno, ec: char_pos) - end - - # hshptn is a parser event that represents matching against a hash pattern - # using the Ruby 2.7+ pattern matching syntax. - def on_hshptn(const, kw, kwrest) - pieces = [const, kw, kwrest].flatten(2).compact - - { - type: :hshptn, - body: [const, kw, kwrest], - sl: pieces[0][:sl], - sc: pieces[0][:sc], - el: pieces[-1][:el], - ec: pieces[-1][:ec] - } - end - - # ident is a scanner event that represents an identifier anywhere in code. It - # can actually represent a whole bunch of stuff, depending on where it is in - # the AST. Like comments, we need to force the encoding here so JSON doesn't - # break. - def on_ident(value) - start_line = lineno - start_char = char_pos - - node = { - type: :@ident, - body: value.force_encoding('UTF-8'), - sl: start_line, - el: start_line, - sc: start_char, - ec: start_char + value.size - } - - scanner_events << node - node - end - - # if is a parser event that represents the first clause in an if chain. - # It accepts as arguments the predicate of the if, the statements that are - # contained within the if clause, and the optional consequent clause. - def on_if(predicate, stmts, consequent) - beging = find_scanner_event(:@kw, 'if') - ending = consequent || find_scanner_event(:@kw, 'end') - - stmts.bind(predicate[:ec], ending[:sc]) - - { - type: :if, - body: [predicate, stmts, consequent], - sl: beging[:sl], - sc: beging[:sc], - el: ending[:el], - ec: ending[:ec] - } - end - - # ifop is a parser event that represents a ternary operator. It accepts as - # arguments the predicate to the ternary, the truthy clause, and the falsy - # clause. - def on_ifop(predicate, truthy, falsy) - predicate.merge( - type: :ifop, - body: [predicate, truthy, falsy], - el: falsy[:el], - ec: falsy[:ec] - ) - end - - # if_mod is a parser event that represents the modifier form of an if - # statement. It accepts as arguments the predicate of the if and the - # statement that are contained within the if clause. - def on_if_mod(predicate, statement) - find_scanner_event(:@kw, 'if') - - { - type: :if_mod, - body: [predicate, statement], - sl: statement[:sl], - sc: statement[:sc], - el: predicate[:el], - ec: predicate[:ec] - } - end - - # ignored_nl is a special kind of scanner event that passes nil as the value. - # You can trigger the ignored_nl event with the following snippet: - # - # foo.bar - # .baz - # - # We don't need to track this event in the AST that we're generating, so we're - # not going to define an explicit handler for it. - # - # def on_ignored_nl(value) - # value - # end - - # ignored_sp is a scanner event that represents the space before the content - # of each line of a squiggly heredoc that will be removed from the string - # before it gets transformed into a string literal. For example, in the - # following snippet: - # - # <<~HERE - # foo - # bar - # HERE - # - # You would have two ignored_sp events, the first with two spaces and the - # second with four. We don't need to track this event in the AST that we're - # generating, so we're not going to define an explicit handler for it. - # - # def on_ignored_sp(value) - # value - # end - - # imaginary is a scanner event that represents an imaginary number literal. - # They become instances of the Complex class. - def on_imaginary(value) - start_line = lineno - start_char = char_pos - - node = { - type: :@imaginary, - body: value, - sl: start_line, - el: start_line, - sc: start_char, - ec: start_char + value.size - } - - scanner_events << node - node - end - - # in is a parser event that represents using the in keyword within the - # Ruby 2.7+ pattern matching syntax. Alternatively in Ruby 3+ it is also used - # to handle rightward assignment for pattern matching. - def on_in(pattern, stmts, consequent) - # Here we have a rightward assignment - return pattern unless stmts - - beging = find_scanner_event(:@kw, 'in') - ending = consequent || find_scanner_event(:@kw, 'end') - - stmts.bind(beging[:ec], ending[:sc]) - - beging.merge!( - type: :in, - body: [pattern, stmts, consequent], - el: ending[:el], - ec: ending[:ec] - ) - end - - # int is a scanner event the represents a number literal. - def on_int(value) - start_line = lineno - start_char = char_pos - - node = { - type: :@int, - body: value, - sl: start_line, - el: start_line, - sc: start_char, - ec: start_char + value.size - } - - scanner_events << node - node - end - - # ivar is a scanner event the represents an instance variable literal. - def on_ivar(value) - start_line = lineno - start_char = char_pos - - node = { - type: :@ivar, - body: value, - sl: start_line, - el: start_line, - sc: start_char, - ec: start_char + value.size - } - - scanner_events << node - node - end - - # kw is a scanner event the represents the use of a keyword. It can be - # anywhere in the AST, so you end up seeing it quite a lot. - def on_kw(value) - start_line = lineno - start_char = char_pos - - node = { - type: :@kw, - body: value, - sl: start_line, - el: start_line, - sc: start_char, - ec: start_char + value.size - } - - scanner_events << node - node - end - - # kwrest_param is a parser event that represents defining a parameter in a - # method definition that accepts all remaining keyword parameters. - def on_kwrest_param(ident) - oper = find_scanner_event(:@op, '**') - return oper.merge!(type: :kwrest_param, body: [nil]) unless ident - - oper.merge!( - type: :kwrest_param, - body: [ident], - el: ident[:el], - ec: ident[:ec] - ) - end - - # label is a scanner event that represents the use of an identifier to - # associate with an object. You can find it in a hash key, as in: - # - # { foo: bar } - # - # in this case "foo:" would be the body of the label. You can also find it in - # pattern matching, as in: - # - # case foo - # in bar: - # bar - # end - # - # in this case "bar:" would be the body of the label. - def on_label(value) - start_line = lineno - start_char = char_pos - - node = { - type: :@label, - body: value, - sl: start_line, - el: start_line, - sc: start_char, - ec: start_char + value.size - } - - scanner_events << node - node - end - - # label_end is a scanner event that represents the end of a dynamic symbol. If - # for example you had the following hash: - # - # { "foo": bar } - # - # then the string "\":" would be the value of this label_end. It's useful for - # determining the type of quote being used by the label. - def on_label_end(value) - start_line = lineno - start_char = char_pos - - node = { - type: :@label_end, - body: value, - sl: start_line, - el: start_line, - sc: start_char, - ec: start_char + value.size - } - - scanner_events << node - node - end - - # lambda is a parser event that represents using a "stabby" lambda - # literal. It accepts as arguments a params event that represents any - # parameters to the lambda and a stmts event that represents the - # statements inside the lambda. - # - # It can be wrapped in either {..} or do..end so we look for either of - # those combinations to get our bounds. - def on_lambda(params, stmts) - beging = find_scanner_event(:@tlambda) - - if event = find_scanner_event(:@tlambeg, consume: false) - opening = scanner_events.delete(event) - closing = find_scanner_event(:@rbrace) - else - opening = find_scanner_event(:@kw, 'do') - closing = find_scanner_event(:@kw, 'end') - end - - stmts.bind(opening[:ec], closing[:sc]) - - { - type: :lambda, - body: [params, stmts], - sl: beging[:sl], - sc: beging[:sc], - el: closing[:el], - ec: closing[:ec] - } - end - - # lbrace is a scanner event representing the use of a left brace, i.e., "{". - def on_lbrace(value) - start_line = lineno - start_char = char_pos - - node = { - type: :@lbrace, - body: value, - sl: start_line, - el: start_line, - sc: start_char, - ec: start_char + value.size - } - - scanner_events << node - node - end - - # lbracket is a scanner event representing the use of a left bracket, i.e., - # "[". - def on_lbracket(value) - start_line = lineno - start_char = char_pos - - node = { - type: :@lbracket, - body: value, - sl: start_line, - el: start_line, - sc: start_char, - ec: start_char + value.size - } - - scanner_events << node - node - end - - # lparen is a scanner event representing the use of a left parenthesis, i.e., - # "(". - def on_lparen(value) - start_line = lineno - start_char = char_pos - - node = { - type: :@lparen, - body: value, - sl: start_line, - el: start_line, - sc: start_char, - ec: start_char + value.size - } - - scanner_events << node - node - end - - # magic_comment is a scanner event that represents the use of a pragma at the - # beginning of the file. Usually it will inside something like - # frozen_string_literal (the key) with a value of true (the value). Both - # children come is a string literals. We're going to leave these alone as they - # come in all kinds of shapes and sizes. - # - # def on_magic_comment(key, value) - # @magic_comment = { value: " #{key}: #{value}" } - # end - - # massign is a parser event that is a parent node of any kind of multiple - # assignment. This includes splitting out variables on the left like: - # - # a, b, c = foo - # - # as well as splitting out variables on the right, as in: - # - # foo = a, b, c - # - # Both sides support splats, as well as variables following them. There's - # also slightly odd behavior that you can achieve with the following: - # - # a, = foo - # - # In this case a would receive only the first value of the foo enumerable, - # in which case we need to explicitly track the comma and add it onto the - # child node. - def on_massign(left, right) - left[:comma] = true if source[left[:ec]...right[:sc]].strip.start_with?(',') - - { - type: :massign, - body: [left, right], - sl: left[:sl], - sc: left[:sc], - el: right[:el], - ec: right[:ec] - } - end - - # method_add_arg is a parser event that represents a method call with - # arguments and parentheses. It accepts as arguments the method being called - # and the arg_paren event that contains the arguments to the method. - def on_method_add_arg(fcall, arg_paren) - # You can hit this if you are passing no arguments to a method that ends in - # a question mark. Because it knows it has to be a method and not a local - # variable. In that case we can just use the location information straight - # from the fcall. - if arg_paren[:type] == :args - return fcall.merge(type: :method_add_arg, body: [fcall, arg_paren]) - end - - { - type: :method_add_arg, - body: [fcall, arg_paren], - sl: fcall[:sl], - sc: fcall[:sc], - el: arg_paren[:el], - ec: arg_paren[:ec] - } - end - - # method_add_block is a parser event that represents a method call with a - # block argument. It accepts as arguments the method being called and the - # block event. - def on_method_add_block(method_add_arg, block) - { - type: :method_add_block, - body: [method_add_arg, block], - sl: method_add_arg[:sl], - sc: method_add_arg[:sc], - el: block[:el], - ec: block[:ec] - } - end - - # An mlhs_new is a parser event that represents the beginning of the left - # side of a multiple assignment. It is followed by any number of mlhs_add - # nodes that each represent another variable being assigned. - def on_mlhs_new - { - type: :mlhs, - body: [], - sl: lineno, - sc: char_pos, - el: lineno, - ec: char_pos - } - end - - # An mlhs_add is a parser event that represents adding another variable - # onto a list of assignments. It accepts as arguments the parent mlhs node - # as well as the part that is being added to the list. - def on_mlhs_add(mlhs, part) - if mlhs[:body].empty? - part.merge(type: :mlhs, body: [part]) - else - mlhs.merge!(body: mlhs[:body] << part, el: part[:el], ec: part[:ec]) - end - end - - # An mlhs_add_post is a parser event that represents adding another set of - # variables onto a list of assignments after a splat variable. It accepts - # as arguments the previous mlhs_add_star node that represented the splat - # as well another mlhs node that represents all of the variables after the - # splat. - def on_mlhs_add_post(mlhs_add_star, mlhs) - mlhs_add_star.merge( - type: :mlhs_add_post, - body: [mlhs_add_star, mlhs], - el: mlhs[:el], - ec: mlhs[:ec] - ) - end - - # An mlhs_add_star is a parser event that represents a splatted variable - # inside of a multiple assignment on the left hand side. It accepts as - # arguments the parent mlhs node as well as the part that represents the - # splatted variable. - def on_mlhs_add_star(mlhs, part) - beging = find_scanner_event(:@op, '*') - ending = part || beging - - { - type: :mlhs_add_star, - body: [mlhs, part], - sl: beging[:sl], - sc: beging[:sc], - el: ending[:el], - ec: ending[:ec] - } - end - - # An mlhs_paren is a parser event that represents parentheses being used - # to deconstruct values in a multiple assignment on the left hand side. It - # accepts as arguments the contents of the inside of the parentheses, - # which is another mlhs node. - def on_mlhs_paren(contents) - beging = find_scanner_event(:@lparen) - ending = find_scanner_event(:@rparen) - - if source[beging[:ec]...ending[:sc]].strip.end_with?(',') - contents[:comma] = true - end - - { - type: :mlhs_paren, - body: [contents], - sl: beging[:sl], - sc: beging[:sc], - el: ending[:el], - ec: ending[:ec] - } - end - - # module is a parser event that represents defining a module. It accepts - # as arguments the name of the module and the bodystmt event that - # represents the statements evaluated within the context of the module. - def on_module(const, bodystmt) - beging = find_scanner_event(:@kw, 'module') - ending = find_scanner_event(:@kw, 'end') - - bodystmt.bind(find_next_statement_start(const[:ec]), ending[:sc]) - - { - type: :module, - body: [const, bodystmt], - sl: beging[:sl], - sc: beging[:sc], - el: ending[:el], - ec: ending[:ec] - } - end - - # An mrhs_new is a parser event that represents the beginning of a list of - # values that are being assigned within a multiple assignment node. It can - # be followed by any number of mrhs_add nodes that we'll build up into an - # array body. - def on_mrhs_new - { - type: :mrhs, - body: [], - sl: lineno, - sc: char_pos, - el: lineno, - ec: char_pos - } - end - - # An mrhs_add is a parser event that represents adding another value onto - # a list on the right hand side of a multiple assignment. - def on_mrhs_add(mrhs, part) - if mrhs[:body].empty? - part.merge(type: :mrhs, body: [part]) - else - mrhs.merge!(body: mrhs[:body] << part, el: part[:el], ec: part[:ec]) - end - end - - # An mrhs_add_star is a parser event that represents using the splat - # operator to expand out a value on the right hand side of a multiple - # assignment. - def on_mrhs_add_star(mrhs, part) - beging = find_scanner_event(:@op, '*') - ending = part || beging - - { - type: :mrhs_add_star, - body: [mrhs, part], - sl: beging[:sl], - sc: beging[:sc], - el: ending[:el], - ec: ending[:ec] - } - end - - # An mrhs_new_from_args is a parser event that represents the shorthand - # of a multiple assignment that allows you to assign values using just - # commas as opposed to assigning from an array. For example, in the - # following segment the right hand side of the assignment would trigger - # this event: - # - # foo = 1, 2, 3 - # - def on_mrhs_new_from_args(args) - args.merge(type: :mrhs_new_from_args, body: [args]) - end - - # next is a parser event that represents using the next keyword. It - # accepts as an argument an args or args_add_block event that contains all - # of the arguments being passed to the next. - def on_next(args_add_block) - find_scanner_event(:@kw, 'next').merge!( - type: :next, - body: [args_add_block], - el: args_add_block[:el], - ec: args_add_block[:ec] - ) - end - - # nl is a scanner event representing a newline in the source. As you can - # imagine, it will typically get triggered quite a few times. We don't need to - # track this event in the AST that we're generating, so we're not going to - # define an explicit handler for it. - # - # def on_nl(value) - # value - # end - - # nokw_param is a parser event that represents the use of the special 2.7+ - # syntax to indicate a method should take no additional keyword arguments. For - # example in the following snippet: - # - # def foo(**nil) end - # - # this is saying that foo should not accept any keyword arguments. Its value - # is always nil. We don't need to track this event in the AST that we're - # generating, so we're not going to define an explicit handler for it. - # - # def on_nokw_param(value) - # value - # end - - # op is a scanner event representing an operator literal in the source. For - # example, in the following snippet: - # - # 1 + 2 - # - # the + sign is an operator. - def on_op(value) - start_line = lineno - start_char = char_pos - - node = { - type: :@op, - body: value, - sl: start_line, - el: start_line, - sc: start_char, - ec: start_char + value.size - } - - scanner_events << node - node - end - - # opassign is a parser event that represents assigning something to a - # variable or constant using an operator like += or ||=. It accepts as - # arguments the left side of the expression before the operator, the - # operator itself, and the right side of the expression. - def on_opassign(left, oper, right) - left.merge( - type: :opassign, - body: [left, oper, right], - el: right[:el], - ec: right[:ec] - ) - end - - # operator_ambiguous is a parser event that represents when the parsers sees - # an operator as ambiguous. For example, in the following snippet: - # - # foo %[] - # - # the question becomes if the percent sign is being used as a method call or - # if it's the start of a string literal. We don't need to track this event in - # the AST that we're generating, so we're not going to define an explicit - # handler for it. - # - # def on_operator_ambiguous(value) - # value - # end - - # params is a parser event that represents defining parameters on a - # method. They have a somewhat interesting structure in that they are an - # array of arrays where the position in the top-level array indicates the - # type of param and the subarray is the list of parameters of that type. - # We therefore have to flatten them down to get to the location. - def on_params(*types) - flattened = types.flatten(2).select { |type| type.is_a?(Hash) } - location = - if flattened.any? - { - sl: flattened[0][:sl], - sc: flattened[0][:sc], - el: flattened[-1][:el], - ec: flattened[-1][:ec] - } - else - { sl: lineno, sc: char_pos, el: lineno, ec: char_pos } - end - - location.merge!(type: :params, body: types) - end - - # A paren is a parser event that represents using parentheses pretty much - # anywhere in a Ruby program. It accepts as arguments the contents, which - # can be either params or statements. - def on_paren(contents) - lparen = find_scanner_event(:@lparen) - rparen = find_scanner_event(:@rparen) - - if contents && contents[:type] == :params - contents.merge!( - sc: find_next_statement_start(lparen[:ec]), - ec: rparen[:sc] - ) - end - - { - type: :paren, - lparen: lparen, - body: [contents], - sl: lparen[:sl], - sc: lparen[:sc], - el: rparen[:el], - ec: rparen[:ec] - } - end - - # If we encounter a parse error, just immediately bail out so that our runner - # can catch it. - def on_parse_error(error, *) - raise ParserError.new(error, lineno, column) - end - alias on_alias_error on_parse_error - alias on_assign_error on_parse_error - alias on_class_name_error on_parse_error - alias on_param_error on_parse_error - - # period is a scanner event that represents the use of the period operator. It - # is usually found in method calls. - def on_period(value) - start_line = lineno - start_char = char_pos - - { - type: :@period, - body: value, - sl: start_line, - el: start_line, - sc: start_char, - ec: start_char + value.size - } - end - - # The program node is the very top of the AST. Here we'll attach all of - # the comments that we've gathered up over the course of parsing the - # source string. We'll also attach on the __END__ content if there was - # some found at the end of the source string. - def on_program(stmts) - range = { sl: 1, el: lines.length, sc: 0, ec: source.length } - - stmts[:body] << @__end__ if @__end__ - stmts.bind(0, source.length) - - range.merge(type: :program, body: [stmts], comments: @comments) - end - - # qsymbols_beg is a scanner event that represents the beginning of a symbol - # literal array. For example in the following snippet: - # - # %i[foo bar baz] - # - # a qsymbols_beg would be triggered with the value of "%i[". - def on_qsymbols_beg(value) - start_line = lineno - start_char = char_pos - - node = { - type: :@qsymbols_beg, - body: value, - sl: start_line, - el: start_line, - sc: start_char, - ec: start_char + value.size - } - - scanner_events << node - node - end - - # qsymbols_new is a parser event that represents the beginning of a symbol - # literal array, like %i[one two three]. It can be followed by any number - # of qsymbols_add events, which we'll append onto an array body. - def on_qsymbols_new - find_scanner_event(:@qsymbols_beg).merge!(type: :qsymbols, body: []) - end - - # qsymbols_add is a parser event that represents an element inside of a - # symbol literal array like %i[one two three]. It accepts as arguments the - # parent qsymbols node as well as a tstring_content scanner event - # representing the bare words. - def on_qsymbols_add(qsymbols, tstring_content) - qsymbols.merge!( - body: qsymbols[:body] << tstring_content, - el: tstring_content[:el], - ec: tstring_content[:ec] - ) - end - - # qwords_beg is a scanner event that represents the beginning of a word - # literal array. For example in the following snippet: - # - # %w[foo bar baz] - # - # a qwords_beg would be triggered with the value of "%w[". - def on_qwords_beg(value) - start_line = lineno - start_char = char_pos - - node = { - type: :@qwords_beg, - body: value, - sl: start_line, - el: start_line, - sc: start_char, - ec: start_char + value.size - } - - scanner_events << node - node - end - - # qwords_new is a parser event that represents the beginning of a string - # literal array, like %w[one two three]. It can be followed by any number - # of qwords_add events, which we'll append onto an array body. - def on_qwords_new - find_scanner_event(:@qwords_beg).merge!(type: :qwords, body: []) - end - - # qsymbols_add is a parser event that represents an element inside of a - # symbol literal array like %i[one two three]. It accepts as arguments the - # parent qsymbols node as well as a tstring_content scanner event - # representing the bare words. - def on_qwords_add(qwords, tstring_content) - qwords.merge!( - body: qwords[:body] << tstring_content, - el: tstring_content[:el], - ec: tstring_content[:ec] - ) - end - - # rational is a scanner event that represents a rational number literal. - def on_rational(value) - start_line = lineno - start_char = char_pos - - node = { - type: :@rational, - body: value, - sl: start_line, - el: start_line, - sc: start_char, - ec: start_char + value.size - } - - scanner_events << node - node - end - - # rbrace is a scanner event that represents the use of a right brace, i.e., - # "}". - def on_rbrace(value) - start_line = lineno - start_char = char_pos - - node = { - type: :@rbrace, - body: value, - sl: start_line, - el: start_line, - sc: start_char, - ec: start_char + value.size - } - - scanner_events << node - node - end - - # rbracket is a scanner event that represents the use of a right bracket, - # i.e., "]". - def on_rbracket(value) - start_line = lineno - start_char = char_pos - - node = { - type: :@rbracket, - body: value, - sl: start_line, - el: start_line, - sc: start_char, - ec: start_char + value.size - } - - scanner_events << node - node - end - - # redo is a parser event that represents the bare redo keyword. It has no - # body as it accepts no arguments. - def on_redo - find_scanner_event(:@kw, 'redo').merge!(type: :redo) - end - - # regexp_add is a parser event that represents a piece of a regular expression - # body. It accepts as arguments the parent regexp node as well as a - # tstring_content scanner event representing string content, a - # string_embexpr parser event representing interpolated content, or a - # string_dvar parser event representing an interpolated variable. - def on_regexp_add(regexp, piece) - regexp.merge!( - body: regexp[:body] << piece, - el: regexp[:el], - ec: regexp[:ec] - ) - end - - # regexp_beg is a scanner event that represents the start of a regular - # expression. It can take a couple of forms since regexp can either start with - # a forward slash or a %r. - def on_regexp_beg(value) - start_line = lineno - start_char = char_pos - - node = { - type: :@regexp_beg, - body: value, - sl: start_line, - el: start_line, - sc: start_char, - ec: start_char + value.size - } - - scanner_events << node - node - end - - # regexp_end is a scanner event that represents the end of a regular - # expression. It will contain the closing brace or slash, as well as any flags - # being passed to the regexp. - def on_regexp_end(value) - start_line = lineno - start_char = char_pos - - { - type: :@regexp_end, - body: value, - sl: start_line, - el: start_line, - sc: start_char, - ec: start_char + value.size - } - end - - # regexp_literal is a parser event that represents a regular expression. - # It accepts as arguments a regexp node which is a built-up array of - # pieces that go into the regexp content, as well as the ending used to - # close out the regexp which includes any modifiers. - def on_regexp_literal(regexp, ending) - regexp.merge!( - type: :regexp_literal, - ending: ending[:body], - el: ending[:el], - ec: ending[:ec] - ) - end - - # regexp_new is a parser event that represents the beginning of a regular - # expression literal, like /foo/. It can be followed by any number of - # regexp_add events, which we'll append onto an array body. - def on_regexp_new - beging = find_scanner_event(:@regexp_beg) - beging.merge!(type: :regexp, body: [], beging: beging[:body]) - end - - # rescue is a special kind of node where you have a rescue chain but it - # doesn't really have all of the information that it needs in order to - # determine its ending. Therefore it relies on its parent bodystmt node to - # report its ending to it. - class Rescue < Node - def bind_end(ec) - value.merge!(ec: ec) - - stmts = value[:body][1] - consequent = value[:body][2] - - if consequent - consequent.bind_end(ec) - stmts.bind_end(consequent[:sc]) - else - stmts.bind_end(ec) - end - end - end - - # rescue is a parser event that represents the use of the rescue keyword - # inside of a bodystmt. - def on_rescue(exceptions, variable, stmts, consequent) - beging = find_scanner_event(:@kw, 'rescue') - exceptions = exceptions[0] if exceptions.is_a?(Array) - - last_node = variable || exceptions || beging - stmts.bind(find_next_statement_start(last_node[:ec]), char_pos) - - # We add an additional inner node here that ripper doesn't provide so that - # we have a nice place to attach inline comment. But we only need it if we - # have an exception or a variable that we're rescuing. - rescue_ex = - if exceptions || variable - { - type: :rescue_ex, - body: [exceptions, variable], - sl: beging[:sl], - sc: beging[:ec] + 1, - el: last_node[:el], - ec: last_node[:ec] - } - end - - Rescue.new( - self, - beging.merge!( - type: :rescue, - body: [rescue_ex, stmts, consequent], - el: lineno, - ec: char_pos - ) - ) - end - - # rescue_mod represents the modifier form of a rescue clause. It accepts as - # arguments the statement that may raise an error and the value that should - # be used if it does. - def on_rescue_mod(statement, rescued) - find_scanner_event(:@kw, 'rescue') - - { - type: :rescue_mod, - body: [statement, rescued], - sl: statement[:sl], - sc: statement[:sc], - el: rescued[:el], - ec: rescued[:ec] - } - end - - # rest_param is a parser event that represents defining a parameter in a - # method definition that accepts all remaining positional parameters. It - # accepts as an argument an optional identifier for the parameter. If it - # is omitted, then we're just using the plain operator. - def on_rest_param(ident) - oper = find_scanner_event(:@op, '*') - return oper.merge!(type: :rest_param, body: [nil]) unless ident - - oper.merge!( - type: :rest_param, - body: [ident], - el: ident[:el], - ec: ident[:ec] - ) - end - - # retry is a parser event that represents the bare retry keyword. It has - # no body as it accepts no arguments. - def on_retry - find_scanner_event(:@kw, 'retry').merge!(type: :retry) - end - - # return is a parser event that represents using the return keyword with - # arguments. It accepts as an argument an args_add_block event that - # contains all of the arguments being passed. - def on_return(args_add_block) - find_scanner_event(:@kw, 'return').merge!( - type: :return, - body: [args_add_block], - el: args_add_block[:el], - ec: args_add_block[:ec] - ) - end - - # return0 is a parser event that represents the bare return keyword. It - # has no body as it accepts no arguments. This is as opposed to the return - # parser event, which is the version where you're returning one or more - # values. - def on_return0 - find_scanner_event(:@kw, 'return').merge!(type: :return0) - end - - # rparen is a scanner event that represents the use of a right parenthesis, - # i.e., ")". - def on_rparen(value) - start_line = lineno - start_char = char_pos - - node = { - type: :@rparen, - body: value, - sl: start_line, - el: start_line, - sc: start_char, - ec: start_char + value.size - } - - scanner_events << node - node - end - - # sclass is a parser event that represents a block of statements that - # should be evaluated within the context of the singleton class of an - # object. It's frequently used to define singleton methods. It looks like - # the following example: - # - # class << self do foo end - # │ │ - # │ └> bodystmt - # └> target - # - def on_sclass(target, bodystmt) - beging = find_scanner_event(:@kw, 'class') - ending = find_scanner_event(:@kw, 'end') - - bodystmt.bind(find_next_statement_start(target[:ec]), ending[:sc]) - - { - type: :sclass, - body: [target, bodystmt], - sl: beging[:sl], - sc: beging[:sc], - el: ending[:el], - ec: ending[:ec] - } - end - - # semicolon is a scanner event that represents the use of a semicolon in the - # source. We don't need to track this event in the AST that we're generating, - # so we're not going to define an explicit handler for it. - # - # def on_semicolon(value) - # value - # end - - # sp is a scanner event that represents the use of a space in the source. As - # you can imagine, this event gets triggered quite often. We don't need to - # track this event in the AST that we're generating, so we're not going to - # define an explicit handler for it. - # - # def on_sp(value) - # value - # end - - # stmts_add is a parser event that represents a single statement inside a - # list of statements within any lexical block. It accepts as arguments the - # parent stmts node as well as an stmt which can be any expression in - # Ruby. - def on_stmts_add(stmts, stmt) - stmts << stmt - end - - # Everything that has a block of code inside of it has a list of statements. - # Normally we would just track those as a node that has an array body, but we - # have some special handling in order to handle empty statement lists. They - # need to have the right location information, so all of the parent node of - # stmts nodes will report back down the location information. We then - # propagate that onto void_stmt nodes inside the stmts in order to make sure - # all comments get printed appropriately. - class Stmts < Node - def bind(sc, ec) - value.merge!(sc: sc, ec: ec) - - if value[:body][0][:type] == :void_stmt - value[:body][0].merge!(sc: sc, ec: sc) - end - - attach_comments(sc, ec) - end - - def bind_end(ec) - value.merge!(ec: ec) - end - - def <<(statement) - if value[:body].any? - value.merge!(statement.slice(:el, :ec)) - else - value.merge!(statement.slice(:sl, :el, :sc, :ec)) - end - - value[:body] << statement - self - end - - private - - def attach_comments(sc, ec) - attachable = - parser.comments.select do |comment| - comment[:type] == :@comment && !comment[:inline] && - sc <= comment[:sc] && ec >= comment[:ec] && - !comment[:value].include?('prettier-ignore') - end - - return if attachable.empty? - - parser.comments -= attachable - value[:body] = (value[:body] + attachable).sort_by! { |node| node[:sc] } - end - end - - # stmts_new is a parser event that represents the beginning of a list of - # statements within any lexical block. It can be followed by any number of - # stmts_add events, which we'll append onto an array body. - def on_stmts_new - Stmts.new( - self, - type: :stmts, - body: [], - sl: lineno, - el: lineno, - sc: char_pos, - ec: char_pos - ) - end - - # string_add is a parser event that represents a piece of a string. It - # could be plain @tstring_content, string_embexpr, or string_dvar nodes. - # It accepts as arguments the parent string node as well as the additional - # piece of the string. - def on_string_add(string, piece) - string.merge!(body: string[:body] << piece, el: piece[:el], ec: piece[:ec]) - end - - # string_concat is a parser event that represents concatenating two - # strings together using a backward slash, as in the following example: - # - # 'foo' \ - # 'bar' - # - def on_string_concat(left, right) - { - type: :string_concat, - body: [left, right], - sl: left[:sl], - sc: left[:sc], - el: right[:el], - ec: right[:ec] - } - end - - # string_content is a parser event that represents the beginning of the - # contents of a string, which will either be embedded inside of a - # string_literal or a dyna_symbol node. It will have an array body so that - # we can build up a list of @tstring_content, string_embexpr, and - # string_dvar nodes. - def on_string_content - { - type: :string, - body: [], - sl: lineno, - el: lineno, - sc: char_pos, - ec: char_pos - } - end - - # string_dvar is a parser event that represents a very special kind of - # interpolation into string. It allows you to take an instance variable, - # class variable, or global variable and omit the braces when - # interpolating. For example, if you wanted to interpolate the instance - # variable @foo into a string, you could do "#@foo". - def on_string_dvar(var_ref) - find_scanner_event(:@embvar).merge!( - type: :string_dvar, - body: [var_ref], - el: var_ref[:el], - ec: var_ref[:ec] - ) - end - - # string_embexpr is a parser event that represents interpolated content. - # It can go a bunch of different parent nodes, including regexp, strings, - # xstrings, heredocs, dyna_symbols, etc. Basically it's anywhere you see - # the #{} construct. - def on_string_embexpr(stmts) - beging = find_scanner_event(:@embexpr_beg) - ending = find_scanner_event(:@embexpr_end) - - stmts.bind(beging[:ec], ending[:sc]) - - { - type: :string_embexpr, - body: [stmts], - sl: beging[:sl], - sc: beging[:sc], - el: ending[:el], - ec: ending[:ec] - } - end - - # String literals are either going to be a normal string or they're going - # to be a heredoc if we've just closed a heredoc. - def on_string_literal(string) - heredoc = @heredocs[-1] - - if heredoc && heredoc[:ending] - @heredocs.pop.merge!(body: string[:body]) - else - beging = find_scanner_event(:@tstring_beg) - ending = find_scanner_event(:@tstring_end) - - { - type: :string_literal, - body: string[:body], - quote: beging[:body], - sl: beging[:sl], - sc: beging[:sc], - el: ending[:el], - ec: ending[:ec] - } - end - end - - # A super is a parser event that represents using the super keyword with - # any number of arguments. It can optionally use parentheses (represented - # by an arg_paren node) or just skip straight to the arguments (with an - # args_add_block node). - def on_super(contents) - find_scanner_event(:@kw, 'super').merge!( - type: :super, - body: [contents], - el: contents[:el], - ec: contents[:ec] - ) - end - - # symbeg is a scanner event that represents the beginning of a symbol literal. - # In most cases it will contain just ":" as in the value, but if its a dynamic - # symbol being defined it will contain ":'" or ":\"". - def on_symbeg(value) - start_line = lineno - start_char = char_pos - - node = { - type: :@symbeg, - body: value, - sl: start_line, - el: start_line, - sc: start_char, - ec: start_char + value.size - } - - scanner_events << node - node - end - - # A symbol is a parser event that immediately descends from a symbol - # literal and contains an ident representing the contents of the symbol. - def on_symbol(ident) - # When ripper is lexing source text, it turns symbols into keywords if their - # contents match, which will mess up the location information of all of our - # other nodes. So for example instead of { type: :@ident, body: "class" } - # you would instead get { type: :@kw, body: "class" }. - # - # In order to take care of this, we explicitly delete this scanner event - # from the stack to make sure it doesn't screw things up. - scanner_events.pop - - ident.merge(type: :symbol, body: [ident]) - end - - # A symbol_literal represents a symbol in the system with no interpolation - # (as opposed to a dyna_symbol). As its only argument it accepts either a - # symbol node (for most cases) or an ident node (in the case that we're - # using bare words, as in an alias node like alias foo bar). - def on_symbol_literal(contents) - if scanner_events[-1] == contents - contents.merge(type: :symbol_literal, body: [contents]) - else - beging = find_scanner_event(:@symbeg) - contents.merge!(type: :symbol_literal, sc: beging[:sc]) - end - end - - # symbols_beg is a scanner event that represents the start of a symbol literal - # array with interpolation. For example, in the following snippet: - # - # %I[foo bar baz] - # - # symbols_beg would be triggered with the value of "%I". - def on_symbols_beg(value) - start_line = lineno - start_char = char_pos - - node = { - type: :@symbols_beg, - body: value, - sl: start_line, - el: start_line, - sc: start_char, - ec: start_char + value.size - } - - scanner_events << node - node - end - - # symbols_new is a parser event that represents the beginning of a symbol - # literal array that accepts interpolation, like %I[one #{two} three]. It - # can be followed by any number of symbols_add events, which we'll append - # onto an array body. - def on_symbols_new - find_scanner_event(:@symbols_beg).merge!(type: :symbols, body: []) - end - - # symbols_add is a parser event that represents an element inside of a - # symbol literal array that accepts interpolation, like - # %I[one #{two} three]. It accepts as arguments the parent symbols node as - # well as a word_add parser event. - def on_symbols_add(symbols, word_add) - symbols.merge!( - body: symbols[:body] << word_add, - el: word_add[:el], - ec: word_add[:ec] - ) - end - - # tlambda is a scanner event that represents the beginning of a lambda - # literal. It always has the value of "->". - def on_tlambda(value) - start_line = lineno - start_char = char_pos - - node = { - type: :@tlambda, - body: value, - sl: start_line, - el: start_line, - sc: start_char, - ec: start_char + value.size - } - - scanner_events << node - node - end - - # tlambeg is a scanner event that represents the beginning of the body of a - # lambda literal. It always has the value of "{". - def on_tlambeg(value) - start_line = lineno - start_char = char_pos - - node = { - type: :@tlambeg, - body: value, - sl: start_line, - el: start_line, - sc: start_char, - ec: start_char + value.size - } - - scanner_events << node - node - end - - # A top_const_field is a parser event that is always the child of some - # kind of assignment. It represents when you're assigning to a constant - # that is being referenced at the top level. For example: - # - # ::X = 1 - # - def on_top_const_field(const) - beging = find_colon2_before(const) - const.merge( - type: :top_const_field, - body: [const], - sl: beging[:sl], - sc: beging[:sc] - ) - end - - # A top_const_ref is a parser event that is a very similar to - # top_const_field except that it is not involved in an assignment. It - # looks like the following example: - # - # ::X - # - def on_top_const_ref(const) - beging = find_colon2_before(const) - const.merge( - type: :top_const_ref, - body: [const], - sl: beging[:sl], - sc: beging[:sc] - ) - end - - # tstring_beg is a scanner event that represents the beginning of a string - # literal. It can represent either of the quotes for its value, or it can have - # a %q/%Q with delimiter. - def on_tstring_beg(value) - start_line = lineno - start_char = char_pos - - node = { - type: :@tstring_beg, - body: value, - sl: start_line, - el: start_line, - sc: start_char, - ec: start_char + value.size - } - - scanner_events << node - node - end - - # tstring_content is a scanner event that represents plain characters inside - # of a string, heredoc, xstring, or regexp. Like comments, we need to force - # the encoding here so JSON doesn't break. - def on_tstring_content(value) - start_line = lineno - start_char = char_pos - - { - type: :@tstring_content, - body: value.force_encoding('UTF-8'), - sl: start_line, - el: start_line, - sc: start_char, - ec: start_char + value.size - } - end - - # tstring_end is a scanner event that represents the end of a string literal. - # It can either contain quotes, or it can have the end delimiter of a %q/%Q - # literal. - def on_tstring_end(value) - start_line = lineno - start_char = char_pos - - node = { - type: :@tstring_end, - body: value, - sl: start_line, - el: start_line, - sc: start_char, - ec: start_char + value.size - } - - scanner_events << node - node - end - - # A unary node represents a unary method being called on an expression, as - # in !, ~, or not. We have somewhat special handling of the not operator - # since if it has parentheses they don't get reported as a paren node for - # some reason. - def on_unary(oper, value) - if oper == :not - node = find_scanner_event(:@kw, 'not') - - paren = source[node[:ec]...value[:sc]].include?('(') - ending = paren ? find_scanner_event(:@rparen) : value - - node.merge!( - type: :unary, - oper: oper, - body: [value], - el: ending[:el], - ec: ending[:ec], - paren: paren - ) - else - # Special case instead of using find_scanner_event here. It turns out that - # if you have a range that goes from a negative number to a negative - # number then you can end up with a .. or a ... that's higher in the - # stack. So we need to explicitly disallow those operators. - index = - scanner_events.rindex do |scanner_event| - scanner_event[:type] == :@op && scanner_event[:sc] < value[:sc] && - !%w[.. ...].include?(scanner_event[:body]) - end - - beging = scanner_events.delete_at(index) - beging.merge!( - type: :unary, - oper: oper[0], - body: [value], - el: value[:el], - ec: value[:ec] - ) - end - end - - # undef nodes represent using the keyword undef. It accepts as an argument - # an array of symbol_literal nodes that represent each message that the - # user is attempting to undefine. We use the keyword to get the beginning - # location and the last symbol to get the ending. - def on_undef(symbol_literals) - last = symbol_literals.last - - find_scanner_event(:@kw, 'undef').merge!( - type: :undef, - body: symbol_literals, - el: last[:el], - ec: last[:ec] - ) - end - - # unless is a parser event that represents the first clause in an unless - # chain. It accepts as arguments the predicate of the unless, the - # statements that are contained within the unless clause, and the optional - # consequent clause. - def on_unless(predicate, stmts, consequent) - beging = find_scanner_event(:@kw, 'unless') - ending = consequent || find_scanner_event(:@kw, 'end') - - stmts.bind(predicate[:ec], ending[:sc]) - - { - type: :unless, - body: [predicate, stmts, consequent], - sl: beging[:sl], - sc: beging[:sc], - el: ending[:el], - ec: ending[:ec] - } - end - - # unless_mod is a parser event that represents the modifier form of an - # unless statement. It accepts as arguments the predicate of the unless - # and the statement that are contained within the unless clause. - def on_unless_mod(predicate, statement) - find_scanner_event(:@kw, 'unless') - - { - type: :unless_mod, - body: [predicate, statement], - sl: statement[:sl], - sc: statement[:sc], - el: predicate[:el], - ec: predicate[:ec] - } - end - - # until is a parser event that represents an until loop. It accepts as - # arguments the predicate to the until and the statements that are - # contained within the until clause. - def on_until(predicate, stmts) - beging = find_scanner_event(:@kw, 'until') - ending = find_scanner_event(:@kw, 'end') - - # Consume the do keyword if it exists so that it doesn't get confused for - # some other block - do_event = find_scanner_event(:@kw, 'do', consume: false) - if do_event && do_event[:sc] > predicate[:ec] && do_event[:ec] < ending[:sc] - scanner_events.delete(do_event) - end - - stmts.bind(predicate[:ec], ending[:sc]) - - { - type: :until, - body: [predicate, stmts], - sl: beging[:sl], - sc: beging[:sc], - el: ending[:el], - ec: ending[:ec] - } - end - - # until_mod is a parser event that represents the modifier form of an - # until loop. It accepts as arguments the predicate to the until and the - # statement that is contained within the until loop. - def on_until_mod(predicate, statement) - find_scanner_event(:@kw, 'until') - - { - type: :until_mod, - body: [predicate, statement], - sl: statement[:sl], - sc: statement[:sc], - el: predicate[:el], - ec: predicate[:ec] - } - end - - # var_alias is a parser event that represents when you're using the alias - # keyword with global variable arguments. You can optionally use - # parentheses with this keyword, so we either track the location - # information based on those or the final argument to the alias method. - def on_var_alias(left, right) - beging = find_scanner_event(:@kw, 'alias') - - paren = source[beging[:ec]...left[:sc]].include?('(') - ending = paren ? find_scanner_event(:@rparen) : right - - { - type: :var_alias, - body: [left, right], - sl: beging[:sl], - sc: beging[:sc], - el: ending[:el], - ec: ending[:ec] - } - end - - # var_ref is a parser event that represents using either a local variable, - # a nil literal, a true or false literal, or a numbered block variable. - def on_var_ref(contents) - contents.merge(type: :var_ref, body: [contents]) - end - - # var_field is a parser event that represents a variable that is being - # assigned a value. As such, it is always a child of an assignment type - # node. For example, in the following example foo is a var_field: - # - # foo = 1 - # - def on_var_field(ident) - if ident - ident.merge(type: :var_field, body: [ident]) - else - # You can hit this pattern if you're assigning to a splat using pattern - # matching syntax in Ruby 2.7+ - { type: :var_field, body: nil } - end - end - - # vcall nodes are any plain named thing with Ruby that could be either a - # local variable or a method call. They accept as an argument the ident - # scanner event that contains their content. - # - # Access controls like private, protected, and public are reported as - # vcall nodes since they're technically method calls. We want to be able - # add new lines around them as necessary, so here we're going to - # explicitly track those as a different node type. - def on_vcall(ident) - @controls ||= %w[private protected public].freeze - - body = ident[:body] - type = - if @controls.include?(body) && body == lines[lineno - 1].strip - :access_ctrl - else - :vcall - end - - ident.merge(type: type, body: [ident]) - end - - # void_stmt is a special kind of parser event that represents an empty lexical - # block of code. It often will have comments attached to it, so it requires - # some special handling. - def on_void_stmt - { type: :void_stmt, sl: lineno, el: lineno, sc: char_pos, ec: char_pos } - end - - # when is a parser event that represents another clause in a case chain. - # It accepts as arguments the predicate of the when, the statements that - # are contained within the else if clause, and the optional consequent - # clause. - def on_when(predicate, stmts, consequent) - beging = find_scanner_event(:@kw, 'when') - ending = consequent || find_scanner_event(:@kw, 'end') - - stmts.bind(predicate[:ec], ending[:sc]) - - { - type: :when, - body: [predicate, stmts, consequent], - sl: beging[:sl], - sc: beging[:sc], - el: ending[:el], - ec: ending[:ec] - } - end - - # while is a parser event that represents a while loop. It accepts as - # arguments the predicate to the while and the statements that are - # contained within the while clause. - def on_while(predicate, stmts) - beging = find_scanner_event(:@kw, 'while') - ending = find_scanner_event(:@kw, 'end') - - # Consume the do keyword if it exists so that it doesn't get confused for - # some other block - do_event = find_scanner_event(:@kw, 'do', consume: false) - if do_event && do_event[:sc] > predicate[:ec] && do_event[:ec] < ending[:sc] - scanner_events.delete(do_event) - end - - stmts.bind(predicate[:ec], ending[:sc]) - - { - type: :while, - body: [predicate, stmts], - sl: beging[:sl], - sc: beging[:sc], - el: ending[:el], - ec: ending[:ec] - } - end - - # while_mod is a parser event that represents the modifier form of an - # while loop. It accepts as arguments the predicate to the while and the - # statement that is contained within the while loop. - def on_while_mod(predicate, statement) - find_scanner_event(:@kw, 'while') - - { - type: :while_mod, - body: [predicate, statement], - sl: statement[:sl], - sc: statement[:sc], - el: predicate[:el], - ec: predicate[:ec] - } - end - - # word_new is a parser event that represents the beginning of a word - # within a special array literal (either strings or symbols) that accepts - # interpolation. For example, in the following array, there are three - # word nodes: - # - # %W[one a#{two}a three] - # - # Each word inside that array is represented as its own node, which is in - # terms of the parser a tree of word_new and word_add nodes. For our - # purposes, we're going to report this as a word node and build up an - # array body of our parts. - def on_word_new - { type: :word, body: [] } - end - - # word_add is a parser event that represents a piece of a word within a - # special array literal that accepts interpolation. It accepts as - # arguments the parent word node as well as the additional piece of the - # word, which can be either a @tstring_content node for a plain string - # piece or a string_embexpr for an interpolated piece. - def on_word_add(word, piece) - if word[:body].empty? - # Here we're making sure we get the correct bounds by using the - # location information from the first piece. - piece.merge(type: :word, body: [piece]) - else - word.merge!(body: word[:body] << piece, el: piece[:el], ec: piece[:ec]) - end - end - - # words_beg is a scanner event that represents the start of a word literal - # array with interpolation. For example, in the following snippet: - # - # %W[foo bar baz] - # - # words_beg would be triggered with the value of "%W". - def on_words_beg(value) - start_line = lineno - start_char = char_pos - - node = { - type: :@words_beg, - body: value, - sl: start_line, - el: start_line, - sc: start_char, - ec: start_char + value.size - } - - scanner_events << node - node - end - - # words_sep is a scanner event that represents the separate between two words - # inside of a word literal array. It contains any amount of whitespace - # characters that are used to delimit the words. For example, - # - # %w[ - # foo - # bar - # baz - # ] - # - # in the snippet above there would be two words_sep events triggered, one - # between foo and bar and one between bar and baz. We don't need to track this - # event in the AST that we're generating, so we're not going to define an - # explicit handler for it. - # - # def on_words_sep(value) - # value - # end - - # words_new is a parser event that represents the beginning of a string - # literal array that accepts interpolation, like %W[one #{two} three]. It - # can be followed by any number of words_add events, which we'll append - # onto an array body. - def on_words_new - find_scanner_event(:@words_beg).merge!(type: :words, body: []) - end - - # words_add is a parser event that represents an element inside of a - # string literal array that accepts interpolation, like - # %W[one #{two} three]. It accepts as arguments the parent words node as - # well as a word_add parser event. - def on_words_add(words, word_add) - words.merge!( - body: words[:body] << word_add, - el: word_add[:el], - ec: word_add[:ec] - ) - end - - # xstring_new is a parser event that represents the beginning of a string - # of commands that gets sent out to the terminal, like `ls`. It can - # optionally include interpolation much like a regular string, so we're - # going to build up an array body. - # - # If the xstring actually starts with a heredoc declaration, then we're - # going to let heredocs continue to do their thing and instead just use - # its location information. - def on_xstring_new - heredoc = @heredocs[-1] - - if heredoc && heredoc[:beging][3] = '`' - heredoc.merge(type: :xstring, body: []) - elsif RUBY_MAJOR <= 2 && RUBY_MINOR <= 5 && RUBY_PATCH < 7 - { type: :xstring, body: [] } - else - find_scanner_event(:@backtick).merge!(type: :xstring, body: []) - end - end - - # xstring_add is a parser event that represents a piece of a string of - # commands that gets sent out to the terminal, like `ls`. It accepts two - # arguments, the parent xstring node as well as the piece that is being - # added to the string. Because it supports interpolation this is either a - # tstring_content scanner event representing bare string content or a - # string_embexpr representing interpolated content. - def on_xstring_add(xstring, piece) - xstring.merge!( - body: xstring[:body] << piece, - el: piece[:el], - ec: piece[:ec] - ) - end - - # xstring_literal is a parser event that represents a string of commands - # that gets sent to the terminal, like `ls`. It accepts as its only - # argument an xstring node that is a built up array representation of all - # of the parts of the string (including the plain string content and the - # interpolated content). - # - # They can also use heredocs to present themselves, as in the example: - # - # <<-`SHELL` - # ls - # SHELL - # - # In this case we need to change the node type to be a heredoc instead of - # an xstring_literal in order to get the right formatting. - def on_xstring_literal(xstring) - heredoc = @heredocs[-1] - - if heredoc && heredoc[:beging][3] = '`' - heredoc.merge!(body: xstring[:body]) - else - ending = find_scanner_event(:@tstring_end) - xstring.merge!(type: :xstring_literal, el: ending[:el], ec: ending[:ec]) - end - end - - # yield is a parser event that represents using the yield keyword with - # arguments. It accepts as an argument an args_add_block event that - # contains all of the arguments being passed. - def on_yield(args_add_block) - find_scanner_event(:@kw, 'yield').merge!( - type: :yield, - body: [args_add_block], - el: args_add_block[:el], - ec: args_add_block[:ec] - ) - end - - # yield0 is a parser event that represents the bare yield keyword. It has - # no body as it accepts no arguments. This is as opposed to the yield - # parser event, which is the version where you're yielding one or more - # values. - def on_yield0 - find_scanner_event(:@kw, 'yield').merge!(type: :yield0) - end - - # zsuper is a parser event that represents the bare super keyword. It has - # no body as it accepts no arguments. This is as opposed to the super - # parser event, which is the version where you're calling super with one - # or more values. - def on_zsuper - find_scanner_event(:@kw, 'super').merge!(type: :zsuper) - end -end diff --git a/src/ruby/parser.ts b/src/ruby/parser.ts deleted file mode 100644 index dd79c93b..00000000 --- a/src/ruby/parser.ts +++ /dev/null @@ -1,32 +0,0 @@ -import type { Plugin, Ruby } from "../types"; -import parseSync from "../parser/parseSync"; - -const parser: Plugin.Parser = { - // This function is responsible for taking an input string of text and - // returning to prettier a JavaScript object that is the equivalent AST that - // represents the code stored in that string. We accomplish this by spawning a - // new Ruby process of parser.rb and reading JSON off STDOUT. - parse(text) { - return parseSync("ruby", text); - }, - astFormat: "ruby", - // This function handles checking whether or not the source string has the - // pragma for prettier. This is an optional workflow for incremental adoption. - hasPragma(text) { - return /^\s*#[^\S\n]*@(?:prettier|format)\s*?(?:\n|$)/m.test(text); - }, - // This function is critical for comments and cursor support, and is - // responsible for returning the index of the character within the source - // string that is the beginning of the given node. - locStart(node) { - return node.sc; - }, - // This function is critical for comments and cursor support, and is - // responsible for returning the index of the character within the source - // string that is the ending of the given node. - locEnd(node) { - return node.ec; - } -}; - -export default parser; diff --git a/src/ruby/printer.ts b/src/ruby/printer.ts deleted file mode 100644 index 1635dbe8..00000000 --- a/src/ruby/printer.ts +++ /dev/null @@ -1,153 +0,0 @@ -import type { Plugin, Ruby } from "../types"; -import prettier from "../prettier"; - -import embed from "./embed"; -import nodes from "./nodes"; - -const { trim } = prettier; - -const noComments = [ - "args", - "args_add_block", - "args_add_star", - "mlhs", - "mlhs_add_post", - "mlhs_add_star", - "mlhs_paren" -]; - -const printer: Plugin.PrinterConfig = { - // Certain nodes are used more for organizational purposed than for actually - // displaying content, so we tell prettier that we don't want comments - // attached to them. - canAttachComment(node) { - return !noComments.includes(node.type); - }, - embed, - // This function tells prettier how to recurse down our AST so that it can - // find where it needs to attach the comments. The types on this are a little - // abysmal, but we're going to leave it as is to get this out. - getCommentChildNodes(node) { - switch (node.type) { - case "heredoc": - return [node.beging]; - case "aryptn": - return [node.body[0]] - .concat(node.body[1]) - .concat(node.body[2]) - .concat(node.body[3]); - case "hshptn": { - const pairs = node.body[1]; - const values = pairs.reduce( - (left: any, right: any) => left.concat(right), - [] - ); - - return [node.body[0]].concat(values).concat(node.body[2]); - } - case "params": { - const [reqs, optls, rest, post, kwargs, kwargRest, block] = node.body; - let parts = reqs || []; - - (optls || []).forEach((optl: any) => { - parts = parts.concat(optl); - }); - - if (rest) { - parts.push(rest); - } - - parts = parts.concat(post || []); - - (kwargs || []).forEach((kwarg: any) => { - if (kwarg[1]) { - parts = parts.concat(kwarg); - } else { - parts.push(kwarg[0]); - } - }); - - if (kwargRest && kwargRest !== "nil") { - parts.push(kwargRest); - } - - if (block) { - parts.push(block); - } - - return parts; - } - case "brace_block": - return [node.body[0], node.body[1], node.beging]; - case "do_block": - return [node.body[0], node.body[1], node.beging]; - case "paren": - return [node.lparen, node.body[0]]; - default: { - if (Array.isArray(node.body)) { - return node.body.filter( - (child: any) => child && typeof child === "object" - ); - } - return []; - } - } - }, - // This is an escape-hatch to ignore nodes in the tree. If you have a comment - // that includes this pattern, then the entire node will be ignored and just - // the original source will be printed out. - hasPrettierIgnore(path) { - const node = path.getValue(); - - return ( - (node.comments && - node.comments.some((comment) => - comment.value.includes("prettier-ignore") - )) || - false - ); - }, - // To be honest I'm not 100% sure this function is actually necessary, but it - // *feels* like a block comment equivalent in JavaScript so I'm going to leave - // it in place for now. - isBlockComment(comment) { - return comment.type === "@embdoc"; - }, - // This function handles adding the format pragma to a source string. This is - // an optional workflow for incremental adoption. - insertPragma(text) { - const boundary = text.startsWith("#") ? "\n" : "\n\n"; - - return `# @format${boundary}${text}`; - }, - // This is the generic node print function, used to convert any node in the - // AST into its equivalent Doc representation. - print(path, opts, print) { - const node = path.getValue(); - const printer = nodes[node.type]; - - if (printer) { - return printer(path, opts, print); - } - - if (node.type[0] === "@") { - return (node as any).body; - } - - throw new Error(`Unsupported node encountered: ${node.type}`); - }, - // This is the generic print function for any comment in the AST. It handles - // both regular comments that begin with a # and embdoc comments, which are - // surrounded by =begin..=end. - printComment(path) { - const comment = (path as any as Plugin.Path).getValue(); - - if (comment.type === "@comment") { - return `#${comment.value}`; - } - - return [trim, comment.value]; - } -}; - -export default printer; diff --git a/src/ruby/toProc.ts b/src/ruby/toProc.ts deleted file mode 100644 index ddbd189f..00000000 --- a/src/ruby/toProc.ts +++ /dev/null @@ -1,118 +0,0 @@ -import type { Plugin, Ruby } from "../types"; - -function isCall(node: Ruby.CallOperator) { - // Older versions of Ruby didn't have a @period ripper event, so we need to - // explicitly cast to any here. - if (node === "::" || (node as any) === ".") { - return true; - } - - return node.type === "@period"; -} - -// If you have a simple block that only calls a method on the single required -// parameter that is passed to it, then you can replace that block with the -// simpler `Symbol#to_proc`. Meaning, it would go from: -// -// [1, 2, 3].map { |i| i.to_s } -// -// to: -// -// [1, 2, 3].map(&:to_s) -// -// This works with `do` blocks as well. -function toProc( - path: Plugin.Path, - node: Ruby.BraceBlock | Ruby.DoBlock -) { - const [variables, blockContents] = node.body; - - // Ensure that there are variables being passed to this block. - const params = variables && variables.body[0]; - if (!params) { - return null; - } - - // Ensure there is one and only one parameter, and that it is required. - const reqParams = params.body[0]; - const otherParams = params.body.slice(1); - if ( - !Array.isArray(reqParams) || - reqParams.length !== 1 || - otherParams.some(Boolean) - ) { - return null; - } - - let statements: Ruby.Stmts; - if (blockContents.type === "bodystmt") { - // We’re in a `do` block - const blockStatements = blockContents.body[0]; - const rescueElseEnsure = blockContents.body.slice(1); - - // You can’t use the to_proc shortcut if you’re rescuing - if (rescueElseEnsure.some(Boolean)) { - return null; - } - - statements = blockStatements; - } else { - // We’re in a brace block - statements = blockContents; - } - - // Ensure the block contains only one statement - if (statements.body.length !== 1) { - return null; - } - - // Ensure that statement is a call and that it has no comments attached - const [statement] = statements.body; - if (statement.type !== "call" || statement.comments) { - return null; - } - - // Ensure the call is a method of the block argument - const [varRef, call, method] = statement.body; - - if ( - varRef.type !== "var_ref" || - varRef.body[0].body !== reqParams[0].body || - !isCall(call) || - method === "call" || - method.type !== "@ident" - ) { - return null; - } - - // Ensure that we're not inside of a hash that is being passed to a key that - // corresponds to `:if` or `:unless` to avoid problems with callbacks with - // Rails. For more context, see: - // https://github.com/prettier/plugin-ruby/issues/449 - let assocNode = null; - - if (path.getValue().type === "method_add_block") { - assocNode = path.getParentNode(); - } else { - assocNode = path.getParentNode(2); - } - - if (assocNode && assocNode.type === "assoc_new") { - const [key] = assocNode.body; - - if (key.type === "@label" && ["if:", "unless:"].includes(key.body)) { - return null; - } - - if ( - key.type === "symbol_literal" && - ["if", "unless"].includes(key.body[0].body) - ) { - return null; - } - } - - return `&:${method.body}`; -} - -export default toProc; diff --git a/src/server.rb b/src/server.rb new file mode 100644 index 00000000..d5876cf7 --- /dev/null +++ b/src/server.rb @@ -0,0 +1,167 @@ +# frozen_string_literal: true + +require "bundler/setup" +require "json" +require "socket" + +require "syntax_tree" + +# Optional dependencies +%W[syntax_tree/rbs syntax_tree/haml prettier_print].each do |dep| + begin + require dep + rescue LoadError + end +end + +# First, require all of the plugins that the user specified. +ARGV.shift[/^--plugins=(.*)$/, 1] + .split(",") + .each { |plugin| require "syntax_tree/#{plugin}" } + +# Next, get the file where we should write our connection information. +connection_filepath = ARGV.shift + +# Make sure we trap these signals to be sure we get the quit command coming from +# the parent node process +quit = false +trap(:INT) { quit = true } +trap(:TERM) { quit = true } + +if Signal.list.key?("QUIT") && RUBY_ENGINE != "jruby" + trap(:QUIT) { quit = true } +end + +connection_information = + if Gem.win_platform? + # If we're on windows, we're going to start up a TCP server. The 0 here + # means to bind to some available port. + server = TCPServer.new(0) + address = server.local_address + + # Ensure that we close the server when this process exits. + at_exit { server.close } + + # Return the connection information. + { address: address.ip_address, port: address.ip_port } + else + # If we're not on windows, then we're going to assume we can use unix socket + # files (since they're faster than a TCP server). + filepath = "/tmp/prettier-ruby-parser-#{Process.pid}.sock" + server = UNIXServer.new(filepath) + + # Ensure that we close the server and delete the socket file when this + # process exits. + at_exit do + server.close + File.unlink(filepath) + end + + # Return the connection information. + { path: server.local_address.unix_path } + end + +# This is the actual listening thread that will be acting as our server. We have +# to start it in another thread in order to properly trap the signals in this +# parent thread. +listener = + Thread.new do + loop do + break if quit + + # Start up a new thread that will handle each successive connection. + Thread.new(server.accept_nonblock) do |socket| + request = JSON.parse(socket.read.force_encoding("UTF-8")) + source = request["source"] + + source.each_line do |line| + case line + when /^\s*#.+?coding/ + # If we've found an encoding comment, then we're going to take that + # into account and reclassify the encoding for the source. + encoding = Ripper.new(line).tap(&:parse).encoding + source = source.force_encoding(encoding) + break + when /^\s*#/ + # continue + else + break + end + end + + # At the moment, we're not going to support odd tabwidths. It's going to + # have to be a multiple of 2, because of the way that the prettyprint + # gem functions. So we're going to just use integer division here. + scalar = request["tabwidth"].to_i / 2 + genspace = ->(n) { " " * n * scalar } + + maxwidth = request["maxwidth"].to_i + response = + case request["parser"] + when "ruby" + formatter = + SyntaxTree::Formatter.new(source, [], maxwidth, "\n", &genspace) + SyntaxTree.parse(source).format(formatter) + formatter.flush + formatter.output.join + when "rbs" + formatter = + SyntaxTree::RBS::Formatter.new( + source, + [], + maxwidth, + "\n", + &genspace + ) + SyntaxTree::RBS.parse(source).format(formatter) + formatter.flush + formatter.output.join + when "haml" + formatter = + if defined?(SyntaxTree::Haml::Format::Formatter) + SyntaxTree::Haml::Format::Formatter.new( + source, + +"", + maxwidth, + "\n", + &genspace + ) + else + PrettierPrint.new(+"", maxwidth, "\n", &genspace) + end + + SyntaxTree::Haml.parse(source).format(formatter) + formatter.flush + formatter.output + end + + if response + socket.write(JSON.fast_generate(response.force_encoding("UTF-8"))) + else + socket.write("{ \"error\": true }") + end + rescue SyntaxTree::Parser::ParseError => error + loc = { start: { line: error.lineno, column: error.column } } + socket.write(JSON.fast_generate(error: error.message, loc: loc)) + rescue StandardError => error + begin + socket.write(JSON.fast_generate(error: error.message)) + rescue Errno::EPIPE + # Do nothing, the pipe has been closed by the parent process so we + # don't actually care about writing to it anymore. + end + ensure + socket.close + end + rescue IO::WaitReadable, Errno::EINTR + # Wait for select(2) to give us a connection that has content for 1 + # second. Otherwise timeout and continue on (so that we hit our + # "break if quit" pretty often). + IO.select([server], nil, nil, 1) + + retry unless quit + end + end + +File.write(connection_filepath, JSON.fast_generate(connection_information)) +listener.join diff --git a/src/types.ts b/src/types.ts deleted file mode 100644 index a42a842b..00000000 --- a/src/types.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * as HAML from "./types/haml"; -export * as Plugin from "./types/plugin"; -export * as RBS from "./types/rbs"; -export * as Ruby from "./types/ruby"; -export * from "./types/utils"; diff --git a/src/types/haml.ts b/src/types/haml.ts deleted file mode 100644 index 6184c870..00000000 --- a/src/types/haml.ts +++ /dev/null @@ -1,81 +0,0 @@ -// This file contains all of the types that represent objects being returned -// from the HAML parser. - -export type AnyNode = ( - | Comment - | DocType - | Filter - | HAMLComment - | Plain - | Root - | Script - | SilentScript - | Tag -); - -export type Comment = { - type: "comment", - value: { revealed: boolean, conditional?: string, text?: string }, - children: AnyNode[] -}; - -export type DocType = { - type: "doctype", - value: { type: string, version?: string, encoding?: string } -}; - -export type Filter = { - type: "filter", - value: { name: string, text: string } -}; - -export type HAMLComment = { - type: "haml_comment", - value: { text?: string }, - line: number -}; - -export type Plain = { - type: "plain", - value: { text: string } -}; - -export type Root = { - type: "root", - children: AnyNode[], - supports_multiline: boolean -}; - -export type Script = { - type: "script", - value: { - escape_html: boolean, - preserve: boolean, - interpolate: boolean, - text: string - }, - children: AnyNode[] -}; - -export type SilentScript = { - type: "silent_script", - value: { text: string, keyword: string }, - children: AnyNode[] -}; - -export type TagAttrs = string | { [property: string]: TagAttrs } -export type Tag = { - type: "tag", - value: { - name: string, - attributes: { class?: string, id?: string } & Record, - dynamic_attributes: { new?: string, old?: TagAttrs }, - object_ref?: string, - nuke_outer_whitespace: boolean, - nuke_inner_whitespace: boolean, - self_closing: boolean, - value?: string, - parse: boolean - }, - children: AnyNode[] -}; diff --git a/src/types/plugin.ts b/src/types/plugin.ts deleted file mode 100644 index 2de62dc6..00000000 --- a/src/types/plugin.ts +++ /dev/null @@ -1,97 +0,0 @@ -import type * as Prettier from "prettier"; -import type { ArrayElement, ArrayProperties, IndexProperties, IndexValue, RequiredKeys } from "./utils"; - -type CallProperties = T extends any[] ? IndexProperties : keyof T; -type IterProperties = T extends any[] ? IndexProperties : ArrayProperties; - -type CallCallback = (path: Path, index: number, value: any) => U; -type EachCallback = (path: Path>, index: number, value: any) => void; -type MapCallback = (path: Path>, index: number, value: any) => U; - -// This path interface is going to override a bunch of functions on the regular -// prettier AstPath interface. This is because we want stricter types than the -// current version of @types/prettier provides. -// -// For each of the tree walk functions (call, each, and map) this provides 5 -// strict type signatures, along with a fallback at the end if you end up -// calling more than 5 properties deep (we don't do that but I've included it -// for completeness). -// -// getParentNode is being overridden because previously it was restricted to the -// type T of the given AST, but it's very unlikely you're going to be receiving -// a parent node that exactly matches your current node. So for now just -// returning any. -interface StrictPath { - call(callback: CallCallback): U; - call>(callback: CallCallback, U>, prop1: P1): U; - call>(callback: CallCallback, P2>, U>, prop1: P1, prop2: P2): U; - call, P3 extends CallProperties>>(callback: CallCallback, P2>, P3>, U>, prop1: P1, prop2: P2, prop3: P3): U; - call, P3 extends CallProperties>, P4 extends CallProperties, P3>>>(callback: CallCallback, P2>, P3>, P4>, U>, prop1: P1, prop2: P2, prop3: P3, prop4: P4): U; - call(callback: CallCallback, prop1: P, prop2: P, prop3: P, prop4: P, ...props: P[]): U; - - each(callback: EachCallback): void; - each>(callback: EachCallback>, prop1: P1): void; - each>(callback: EachCallback, P2>>, prop1: P1, prop2: P2): void; - each, P3 extends IterProperties>>(callback: EachCallback, P2>, P3>>, prop1: P1, prop2: P2, prop3: P3): void; - each, P3 extends IterProperties>, P4 extends IterProperties, P3>>>(callback: EachCallback, P2>, P3>, P4>>, prop1: P1, prop2: P2, prop3: P3, prop4: P4): void; - each

(callback: EachCallback, prop1: P, prop2: P, prop3: P, prop4: P, ...props: P[]): void; - - getParentNode: (count?: number | undefined) => any | null, - - map(callback: MapCallback): U[]; - map>(callback: MapCallback, U>, prop1: P1): U[]; - map>(callback: MapCallback, P2>, U>, prop1: P1, prop2: P2): U[]; - map, P3 extends IterProperties>>(callback: MapCallback, P2>, P3>, U>, prop1: P1, prop2: P2, prop3: P3): U[]; - map, P3 extends IterProperties>, P4 extends IterProperties, P3>>>(callback: MapCallback, P2>, P3>, P4>, U>, prop1: P1, prop2: P2, prop3: P3, prop4: P4): U[]; - map(callback: MapCallback, prop1: P, prop2: P, prop3: P, prop4: P, ...props: P[]): U[]; -}; - -// Reexporting the Doc type mostly because it's annoying to have to reference -// type so deeply in the Prettier namespace. Also because we only really want to -// be pulling in types from this file as they're less likely to change. -export type Doc = Prettier.doc.builders.Doc; - -// This is the same embed as is present in prettier, except that it's required. -export type Embed = Required>["embed"]; - -// These are the regular options from prettier except they also include all of -// the options we defined in our plugin configuration. -export type Options = Prettier.ParserOptions & { - printer: RequiredKeys, - rubyArrayLiteral: boolean, - rubyHashLabel: boolean, - rubyModifier: boolean, - rubySingleQuote: boolean, - rubyToProc: boolean -}; - -// hasPragma was not required, but since we're testing it explicitly we're going -// to add that into the parser object as being required. Additionally we're -// going to change the signature of our parse function to accept our options as -// opposed to the generic options that don't contain the options we defined in -// our plugin configuration. -export type Parser = Omit, "hasPragma" | "parse"> & Required, "hasPragma">> & { - parse: (text: string, parsers: { [name: string]: Prettier.Parser }, options: Options) => any -}; - -// We're overwriting a bunch of function here that walk around the tree here -// because if you restrict the AST for the main path then presumably you're -// printing a lower node in the tree that won't match the current AST type. -export type Path = Omit, keyof StrictPath> & StrictPath; - -// The printer from prettier is missing a couple of keys. We should presumably -// upstream this so that it's accurate in all plugins. -export type PrinterConfig = Omit, "insertPragma" | "print"> & Required, "insertPragma">> & { - getCommentChildNodes?: (node: any) => any[], - isBlockComment?: (comment: any, options: Options) => boolean, - print: Printer -}; - -// This is the regular print node, except it's not restricted by the AST that -// is passed to the parent AST. That's because when you're using it, you are not -// typically printing the same node type again. -export type Print = (path: Path) => Doc; - -// This is the regular printer, except it uses our overridden options and print -// types. -export type Printer = (path: Path, options: Options, print: Print) => Doc; diff --git a/src/types/rbs.ts b/src/types/rbs.ts deleted file mode 100644 index 58aa5e0a..00000000 --- a/src/types/rbs.ts +++ /dev/null @@ -1,107 +0,0 @@ -// This file contains all of the types that represent objects being returned -// from the RBS parser. - -export type MethodParam = { - name?: string - escaped: boolean, - type: Type -}; - -export type MethodParams = { - required_positionals: MethodParam[], - optional_positionals: MethodParam[], - rest_positionals?: MethodParam, - trailing_positionals: MethodParam[] - required_keywords: Record, - optional_keywords: Record, - rest_keywords?: MethodParam -}; - -export type MethodSignature = { - type_params: string[], - type: MethodParams & { return_type: Type }, - block: { required: boolean } & MethodSignature -}; - -export type Type = { location: Location } & ( - | { class: "literal", literal: string } - | { class: "optional", type: Type } - | { class: "tuple", types: Type[] } - | { class: "union", types: Type[] } - | { class: "intersection", types: Type[] } - | { class: "class_singleton", name: string } - | { class: "proc" } & MethodSignature - | { class: "record", fields: Record } - | { class: "class_instance" } & NameAndArgs - | { class: "interface" } & NameAndArgs - | { class: "alias", name: string } - | { class: "variable", name: string } - | { class: "bool" } - | { class: "bot" } - | { class: "class" } - | { class: "instance" } - | { class: "nil" } - | { class: "self" } - | { class: "top" } - | { class: "untyped" } - | { class: "void" } -); - -export type Literal = Type & { class: "literal" }; - -export type NameAndArgs = { name: string, args: Type[] }; - -export type Location = { - start: { line: number, column: number }, - end: { line: number, column: number }, - start_pos: number, - end_pos: number -}; - -export type Member = { location: Location } & ( - | { member: "alias", new_name: string, old_name: string, kind: "instance" | "singleton" } - | { member: "attr_accessor" | "attr_reader" | "attr_writer", name: string, ivar_name?: string | false, kind: "instance" | "singleton", type: Type } - | { member: "class_variable" | "class_instance_variable" | "instance_variable", name: string, type: Type } - | { member: "include" } & NameAndArgs - | { member: "extend" } & NameAndArgs - | { member: "prepend" } & NameAndArgs - | { member: "public" } - | { member: "private" } - | { member: "method_definition", overload: boolean, name: string, types: MethodSignature[], kind: "instance" | "singleton" | "singleton_instance" } -); - -export type MethodDefinition = Member & { member: "method_definition" }; - -export type Param = { - name: string, - skip_validation: boolean, - variance: "invariant" | "covariant" | "contravariant" -}; - -export type NameAndTypeParams = { - name: string, - type_params: { params: Param[] } -}; - -export type Class = { declaration: "class", super_class?: NameAndArgs, members: Member[] } & NameAndTypeParams; -export type Interface = { declaration: "interface", members: Member[] } & NameAndTypeParams; -export type Module = { declaration: "module", self_types: NameAndArgs[], members: Member[] } & NameAndTypeParams; - -type Declaration = { location: Location } & ( - | { declaration: "alias", name: string, type: Type } - | Class - | { declaration: "constant", name: string, type: Type } - | { declaration: "global", name: string, type: Type } - | Interface - | Module -); - -type Root = { declarations: Declaration[], location: Location }; - -export type Annotation = { string: string, location: Location }; - -export type AnyNode = { comment?: { string: string }, annotations?: Annotation[] } & ( - | ({ declaration: undefined, member: undefined } & Root) - | ({ declarations: undefined, member: undefined } & Declaration) - | ({ declaration: undefined, declarations: undefined } & Member) -); diff --git a/src/types/ruby.ts b/src/types/ruby.ts deleted file mode 100644 index e545494e..00000000 --- a/src/types/ruby.ts +++ /dev/null @@ -1,225 +0,0 @@ -// This file contains all of the types that represent objects being returned -// from our ripper-based parser. - -// These are common additions to the various node types. -type Comments = { comments?: Comment[] }; -type Location = { sl: number, el: number, sc: number, ec: number }; - -// These are utility types used to construct the various node types. -type ScannerEvent = { type: `@${T}`, body: string } & Comments & Location; -type ParserEvent0 = { type: T, body: string } & Comments & Location; -type ParserEvent> = { type: T } & Comments & Location & V; - -// This is the main expression type that goes in places where the AST will -// accept just about anything. -// eslint-disable-next-line @typescript-eslint/ban-types -export type AnyNode = AccessCtrl | Alias | Aref | ArefField | ArgParen | Args | ArgsAddBlock | ArgsAddStar | ArgsForward | Array | Aryptn | Assign | AssocNew | AssocSplat | AssoclistFromArgs | BEGIN | Backref | Backtick | BareAssocHash | Begin | Binary | BlockVar | Blockarg | Bodystmt | BraceBlock | Break | CVar | Call | Case | Char | Class | Command | CommandCall | Const | ConstPathField | ConstPathRef | ConstRef | Def | Defined | Defs | Defsl | DoBlock | Dot2 | Dot3 | DynaSymbol | END | Else | Elsif | EndContent | Ensure | ExcessedComma | Fcall | Field | Float | FndPtn | For | GVar | Hash | Heredoc | HeredocBegin | Hshptn | IVar | Identifier | If | IfModifier | Imaginary | In | Int | Keyword | KeywordRestParam | Label | Lambda | Lbrace | Massign | MethodAddArg | MethodAddBlock | Mlhs | MlhsAddPost | MlhsAddStar | MlhsParen | Module | Mrhs | MrhsAddStar | MrhsNewFromArgs | Next | Op | Opassign | Params | Paren | Period | Program | Qsymbols | Qwords | Rassign | Rational | Redo | RegexpLiteral | Rescue | RescueEx | RescueModifier | RestParam | Retry | Return | Return0 | Sclass | Stmts | String | StringConcat | StringDVar | StringEmbExpr | StringLiteral | Super | SymbolLiteral | Symbols | TStringContent | Ternary | TopConstField | TopConstRef | Unary | Undef | Unless | UnlessModifier | Until | UntilModifier | VCall | VarAlias | VarField | VarRef | VoidStmt | When | While | WhileModifier | Word | Words | XStringLiteral | Yield | Yield0 | Zsuper - -// This is a special scanner event that contains a comment. It can be attached -// to almost any kind of node, which is why it's pulled out here separately. -type UndecoratedComment = { type: "@comment", value: string, inline: boolean } & Location; - -// Prettier will attach various metadata to comment nodes, which we're adding in -// to the type here. -type CommentDecorations = { leading: boolean, printed: boolean }; -export type Comment = UndecoratedComment & CommentDecorations; - -// These are the scanner events that contain only a single string. They're -// always leaves in the tree. Ignored ones that can't show up in the tree but -// are present in ripper include: -// -// comma, embdoc, embdoc_beg, embdoc_end, embexpr_beg, embexpr_end, embvar, -// heredoc_end, ignored_nl, ignored_sp, label_end, lbracket, nl, qsymbols_beg, -// qwords_beg, rbrace, rbracket, regexp_beg, regexp_end, rparen, semicolon, sp, -// symbbeg, symbols_beg, tlambda, tlambeg, tstring_beg, tstring_nd, words_beg, -// words_sep -// -export type Backref = ScannerEvent<"backref">; -export type Backtick = ScannerEvent<"backtick">; -export type Char = ScannerEvent<"CHAR">; -export type Const = ScannerEvent<"const">; -export type CVar = ScannerEvent<"cvar">; -export type EndContent = ScannerEvent<"__end__">; -export type Float = ScannerEvent<"float">; -export type GVar = ScannerEvent<"gvar">; -export type HeredocBegin = ScannerEvent<"heredoc_beg">; -export type Identifier = ScannerEvent<"ident">; -export type Imaginary = ScannerEvent<"imaginary">; -export type Int = ScannerEvent<"int">; -export type IVar = ScannerEvent<"ivar">; -export type Keyword = ScannerEvent<"kw">; -export type Label = ScannerEvent<"label">; -export type Lbrace = ScannerEvent<"lbrace">; -export type Lparen = ScannerEvent<"lparen">; -export type Op = ScannerEvent<"op">; -export type Period = ScannerEvent<"period">; -export type Rational = ScannerEvent<"rational">; -export type TStringContent = ScannerEvent<"tstring_content">; - -// These are the parser events that don't receive any arguments. (In earlier -// versions of ripper they were scanner events, now they're parser events with -// arity 0.) Ignored ones that can't show up in the tree but are present in -// ripper include: -// -// args_new, mlhs_new, mrhs_new, qsymbols_new, qwords_new, regexp_new, -// stmts_new, string_content, symbols_new, word_new, words_new, xstring_new -// -export type ArgsForward = ParserEvent0<"args_forward">; -export type ExcessedComma = ParserEvent0<"excessed_comma">; -export type Redo = ParserEvent0<"redo">; -export type Retry = ParserEvent0<"retry">; -export type Return0 = ParserEvent0<"return0">; -export type VoidStmt = ParserEvent<"void_stmt">; -export type Yield0 = ParserEvent0<"yield0">; -export type Zsuper = ParserEvent0<"zsuper">; - -// Below are various parser events grouped by their relative functionality. -// The grouping is pretty loose, but it should convey a certain sense of the -// area of Ruby that it's related to. It does not include certain events that -// are present in ripper that we remove from tree before they get to this -// form, including: -// -// heredoc_dedent, magic_comment, nokw_param, symbol -// - -// These are various parser events that have to do with string or string-like -// nodes. -export type StringContent = StringDVar | StringEmbExpr | TStringContent; -export type DynaSymbol = ParserEvent<"dyna_symbol", { body: StringContent[], quote: string }>; -export type Heredoc = ParserEvent<"heredoc", { beging: HeredocBegin, ending: string, body: StringContent[] }>; -export type RegexpLiteral = ParserEvent<"regexp_literal", { body: StringContent[], beging: string, ending: string }>; -export type String = ParserEvent<"string", { body: [TStringContent] }>; -export type StringConcat = ParserEvent<"string_concat", { body: [StringConcat | StringLiteral, StringLiteral] }>; -export type StringDVar = ParserEvent<"string_dvar", { body: [Backref | VarRef] }>; -export type StringEmbExpr = ParserEvent<"string_embexpr", { body: [Stmts] }>; -export type StringLiteral = ParserEvent<"string_literal", { body: StringContent[], quote: string }>; -export type SymbolLiteral = ParserEvent<"symbol_literal", { body: [Backtick | Const | CVar | GVar | Identifier | IVar | Keyword | Op] }>; -export type XStringLiteral = ParserEvent<"xstring_literal", { body: StringContent[] }>; - -// These are various parser events that have to do with arrays. -export type Array = ParserEvent<"array", { body: [null | Args | ArgsAddStar | Qsymbols | Qwords | Symbols | Words] }>; -export type Qsymbols = ParserEvent<"qsymbols", { body: TStringContent[] }>; -export type Qwords = ParserEvent<"qwords", { body: TStringContent[] }>; -export type Symbols = ParserEvent<"symbols", { body: Word[] }>; -export type Word = ParserEvent<"word", { body: StringContent[] }>; -export type Words = ParserEvent<"words", { body: Word[] }>; - -// These are various parser events that have to do with hashes. -type HashContent = AssocNew | AssocSplat; -export type AssocNew = ParserEvent<"assoc_new", { body: [AnyNode, AnyNode] }>; -export type AssocSplat = ParserEvent<"assoc_splat", { body: [AnyNode] }>; -export type AssoclistFromArgs = ParserEvent<"assoclist_from_args", { body: HashContent[] }>; -export type BareAssocHash = ParserEvent<"bare_assoc_hash", { body: HashContent[] }>; -export type Hash = ParserEvent<"hash", { body: [null | AssoclistFromArgs] }>; - -// These are various parser events for assignment. -type Assignable = ArefField | ConstPathField | Field | TopConstField | VarField; -export type ArefField = ParserEvent<"aref_field", { body: [AnyNode, ArgsAddBlock | null] }>; -export type Assign = ParserEvent<"assign", { body: [Assignable, AnyNode] }>; -export type ConstPathField = ParserEvent<"const_path_field", { body: [ConstPathRef | Paren | TopConstRef | VarRef, Const] }>; -export type Field = ParserEvent<"field", { body: [AnyNode, CallOperator, Const | Identifier] }>; -export type Opassign = ParserEvent<"opassign", { body: [Assignable, Op, AnyNode] }>; -export type TopConstField = ParserEvent<"top_const_field", { body: [Const] }>; -export type VarField = ParserEvent<"var_field", { body: [null | Const | CVar | GVar | Identifier | IVar] }>; - -// These are various parser events that have to do with multiple assignment. -export type Massign = ParserEvent<"massign", { body: [Mlhs | MlhsAddPost | MlhsAddStar | MlhsParen, AnyNode] }>; -export type Mlhs = ParserEvent<"mlhs", { body: (ArefField | Field | Identifier | MlhsParen | VarField)[], comma: undefined | true }>; -export type MlhsAddPost = ParserEvent<"mlhs_add_post", { body: [MlhsAddStar, Mlhs] }>; -export type MlhsAddStar = ParserEvent<"mlhs_add_star", { body: [Mlhs, null | ArefField | Field | Identifier | VarField] }>; -export type MlhsParen = ParserEvent<"mlhs_paren", { body: [Mlhs | MlhsAddPost | MlhsAddStar | MlhsParen] }>; -export type Mrhs = ParserEvent<"mrhs", { body: [] }>; -export type MrhsAddStar = ParserEvent<"mrhs_add_star", { body: [Mrhs | MrhsNewFromArgs, AnyNode] }>; -export type MrhsNewFromArgs = ParserEvent<"mrhs_new_from_args", { body: [Args | ArgsAddStar, AnyNode], oper: string }>; - -// These are various parser events for control flow constructs. -export type Case = ParserEvent<"case", { body: [AnyNode, In | When] }>; -export type Else = ParserEvent<"else", { body: [Stmts] }>; -export type Elsif = ParserEvent<"elsif", { body: [AnyNode, Stmts, null | Elsif | Else] }>; -export type Ensure = ParserEvent<"ensure", { body: [Keyword, Stmts] }>; -export type For = ParserEvent<"for", { body: [Mlhs | MlhsAddStar | VarField, AnyNode, Stmts] }>; -export type If = ParserEvent<"if", { body: [AnyNode, Stmts, null | Elsif | Else] }>; -export type IfModifier = ParserEvent<"if_mod", { body: [AnyNode, AnyNode] }>; -export type In = ParserEvent<"in", { body: [AnyNode, Stmts, null | In | Else] }>; -export type Rescue = ParserEvent<"rescue", { body: [null | RescueEx, Stmts, null | Stmts] }>; -export type RescueEx = ParserEvent<"rescue_ex", { body: [AnyNode, null | Field | VarField] }>; -export type RescueModifier = ParserEvent<"rescue_mod", { body: [AnyNode, AnyNode] }>; -export type Ternary = ParserEvent<"ifop", { body: [AnyNode, AnyNode, AnyNode] }>; -export type Unless = ParserEvent<"unless", { body: [AnyNode, Stmts, null | Elsif | Else] }>; -export type UnlessModifier = ParserEvent<"unless_mod", { body: [AnyNode, AnyNode] }>; -export type Until = ParserEvent<"until", { body: [AnyNode, Stmts] }>; -export type UntilModifier = ParserEvent<"until_mod", { body: [AnyNode, AnyNode] }>; -export type When = ParserEvent<"when", { body: [Args | ArgsAddStar, Stmts, null | Else | When] }>; -export type While = ParserEvent<"while", { body: [AnyNode, Stmts] }>; -export type WhileModifier = ParserEvent<"while_mod", { body: [AnyNode, AnyNode] }>; - -// These are various parser events for control flow keywords. -export type Break = ParserEvent<"break", { body: [Args | ArgsAddBlock] }>; -export type Next = ParserEvent<"next", { body: [Args | ArgsAddBlock] }>; -export type Return = ParserEvent<"return", { body: [Args | ArgsAddBlock] }>; -export type Super = ParserEvent<"super", { body: [Args | ArgParen | ArgsAddBlock] }>; -export type Yield = ParserEvent<"yield", { body: [ArgsAddBlock | Paren] }>; - -// These are various parser events for pattern matching. -export type Aryptn = ParserEvent<"aryptn", { body: [null | VarRef, AnyNode[], null | VarField, null | AnyNode[]] }>; -export type FndPtn = ParserEvent<"fndptn", { body: [null | AnyNode, VarField, AnyNode[], VarField] }>; -export type Hshptn = ParserEvent<"hshptn", { body: [null | AnyNode, [Label, AnyNode][], null | VarField] }>; -export type Rassign = ParserEvent<"rassign", { body: [AnyNode, AnyNode], keyword: boolean }>; - -// These are various parser events for method declarations. -type ParenAroundParams = Omit & { body: [Params] }; -export type Blockarg = ParserEvent<"blockarg", { body: [Identifier] }>; -export type Def = ParserEvent<"def", { body: [Backtick | Const | Identifier | Keyword | Op, Params | Paren, Bodystmt] }>; -export type Defs = ParserEvent<"defs", { body: [AnyNode, Op | Period, Const | Op | Identifier | Keyword, Params | Paren, Bodystmt] }>; -export type Defsl = ParserEvent<"defsl", { body: [Identifier, null | ParenAroundParams, AnyNode] }>; -export type KeywordRestParam = ParserEvent<"kwrest_param", { body: [null | Identifier] }>; -export type Lambda = ParserEvent<"lambda", { body: [Params | ParenAroundParams, Bodystmt | Stmts] }>; -export type Params = ParserEvent<"params", { body: [Identifier[], null | [Identifier, AnyNode][], null | ArgsForward | ExcessedComma | RestParam, Identifier[], null | [Label, AnyNode][], null | "nil" | KeywordRestParam, null | Blockarg] }>; -export type RestParam = ParserEvent<"rest_param", { body: [null | Identifier] }>; - -// These are various parser events for method calls. -export type CallOperator = Op | Period | "::"; -export type ArgParen = ParserEvent<"arg_paren", { body: [Args | ArgsAddBlock | ArgsForward | null] }>; -export type Args = ParserEvent<"args", { body: AnyNode[] }>; -export type ArgsAddBlock = ParserEvent<"args_add_block", { body: [Args | ArgsAddStar, false | AnyNode] }>; -export type ArgsAddStar = ParserEvent<"args_add_star", { body: [Args | ArgsAddStar, ...AnyNode[]] }>; -export type BlockVar = ParserEvent<"block_var", { body: [Params, false | Identifier[]] }>; -export type BraceBlock = ParserEvent<"brace_block", { body: [null | BlockVar, Stmts], beging: Lbrace }>; -export type Call = ParserEvent<"call", { body: [AnyNode, CallOperator, Backtick | Op | Identifier | Const | "call"] }>; -export type Command = ParserEvent<"command", { body: [Const | Identifier, Args | ArgsAddBlock] }>; -export type CommandCall = ParserEvent<"command_call", { body: [AnyNode, CallOperator, Op | Identifier | Const, Args | ArgsAddBlock] }>; -export type DoBlock = ParserEvent<"do_block", { body: [null | BlockVar, Bodystmt], beging: Keyword }>; -export type Fcall = ParserEvent<"fcall", { body: [Const | Identifier] }>; -export type MethodAddArg = ParserEvent<"method_add_arg", { body: [Call | Fcall, Args | ArgParen | ArgsAddBlock] }>; -export type MethodAddBlock = ParserEvent<"method_add_block", { body: [AnyNode, BraceBlock | DoBlock] }>; -export type VCall = ParserEvent<"vcall", { body: [Identifier] }>; - -// These are various parser events for statements you would find in a method body. -export type Aref = ParserEvent<"aref", { body: [AnyNode, Args | ArgsAddBlock | null] }>; -export type BEGIN = ParserEvent<"BEGIN", { body: [Lbrace, Stmts] }>; -export type Binary = ParserEvent<"binary", { body: [AnyNode, string, AnyNode] }>; -export type ConstPathRef = ParserEvent<"const_path_ref", { body: [AnyNode, Const] }>; -export type ConstRef = ParserEvent<"const_ref", { body: [Const] }>; -export type Defined = ParserEvent<"defined", { body: [AnyNode] }>; -export type Dot2 = ParserEvent<"dot2", { body: [AnyNode, null] | [null, AnyNode] | [AnyNode, AnyNode] }>; -export type Dot3 = ParserEvent<"dot3", { body: [AnyNode, null] | [null, AnyNode] | [AnyNode, AnyNode] }>; -export type END = ParserEvent<"END", { body: [Lbrace, Stmts] }>; -export type Paren = ParserEvent<"paren", { body: [AnyNode], lparen: Lparen }>; -export type TopConstRef = ParserEvent<"top_const_ref", { body: [Const] }>; -export type Unary = ParserEvent<"unary", { body: [AnyNode], oper: string, paren: boolean | undefined }>; -export type VarRef = ParserEvent<"var_ref", { body: [Const | CVar | GVar | Identifier | IVar | Keyword] }>; - -// These are various parser events for statements you would find in a class definition body. -export type AccessCtrl = ParserEvent<"access_ctrl", { body: [Identifier] }>; -export type Alias = ParserEvent<"alias", { body: [DynaSymbol | SymbolLiteral, DynaSymbol | SymbolLiteral] }>; -export type Class = ParserEvent<"class", { body: [ConstPathRef | ConstRef | TopConstRef, null | AnyNode, Bodystmt] }>; -export type Module = ParserEvent<"module", { body: [ConstPathRef | ConstRef | TopConstRef, Bodystmt] }>; -export type Sclass = ParserEvent<"sclass", { body: [AnyNode, Bodystmt] }>; -export type VarAlias = ParserEvent<"var_alias", { body: [GVar, Backref | GVar] }>; -export type Undef = ParserEvent<"undef", { body: (DynaSymbol | SymbolLiteral)[] }>; - -// These are various parser events for statement containers, generally pretty high in the tree. -export type Begin = ParserEvent<"begin", { body: [Bodystmt] }>; -export type Bodystmt = ParserEvent<"bodystmt", { body: [Stmts, null | Rescue, null | Stmts, null | Ensure] }>; -export type Program = ParserEvent<"program", { body: [Stmts] }>; -export type Stmts = ParserEvent<"stmts", { body: AnyNode[] }>; diff --git a/src/types/utils.ts b/src/types/utils.ts deleted file mode 100644 index cdd68a5e..00000000 --- a/src/types/utils.ts +++ /dev/null @@ -1,24 +0,0 @@ -// The type of elements that make up the given array T. -export type ArrayElement = T extends (infer E)[] ? E : never; - -// A union of the properties of the given object that are arrays. -export type ArrayProperties = { [K in keyof T]: T[K] extends any[] ? K : never }[keyof T]; - -// A union of the properties of the given array T that can be used to index it. -// If the array is a tuple, then that's going to be the explicit indices of the -// array, otherwise it's going to just be number. -export type IndexProperties = IsTuple extends true ? Exclude["length"], T["length"]> : number; - -// Effectively performing T[P], except that it's telling TypeScript that it's -// safe to do this for tuples, arrays, or objects. -export type IndexValue = T extends any[] ? P extends number ? T[P] : never : P extends keyof T ? T[P] : never; - -// Determines if an object T is an array like string[] (in which case this -// evaluates to false) or a tuple like [string] (in which case this evaluates to -// true). -// eslint-disable-next-line @typescript-eslint/no-unused-vars -type IsTuple = T extends [] ? true : T extends [infer First, ...infer Remain] ? IsTuple : false; - -// The same object T as currently exists, except the keys provided by P are -// required instead of optional. -export type RequiredKeys = T & Required>; diff --git a/src/utils.ts b/src/utils.ts deleted file mode 100644 index 55fec0f2..00000000 --- a/src/utils.ts +++ /dev/null @@ -1,12 +0,0 @@ -export { default as containsAssignment } from "./utils/containsAssignment"; -export { default as getTrailingComma } from "./utils/getTrailingComma"; -export { default as isEmptyBodyStmt } from "./utils/isEmptyBodyStmt"; -export { default as isEmptyStmts } from "./utils/isEmptyStmts"; -export { default as hasAncestor } from "./utils/hasAncestor"; -export { default as inlineEnsureParens } from "./utils/inlineEnsureParens"; -export { default as literal } from "./utils/literal"; -export { default as literallineWithoutBreakParent } from "./utils/literallineWithoutBreakParent"; -export { default as makeCall } from "./utils/makeCall"; -export { default as noIndent } from "./utils/noIndent"; -export { default as printEmptyCollection } from "./utils/printEmptyCollection"; -export { default as skipAssignIndent } from "./utils/skipAssignIndent"; diff --git a/src/utils/containsAssignment.ts b/src/utils/containsAssignment.ts deleted file mode 100644 index ee760501..00000000 --- a/src/utils/containsAssignment.ts +++ /dev/null @@ -1,18 +0,0 @@ -import type { Ruby } from "../types"; - -// If the node is a type of assignment or if the node is a paren and nested -// inside that paren is a node that is a type of assignment. -function containsAssignment(node: Ruby.AnyNode | Ruby.Stmts) { - if (!node) { - return false; - } - - if (["assign", "massign", "opassign"].includes(node.type)) { - return true; - } - - const anyNode = node as any; - return Array.isArray(anyNode.body) && anyNode.body.some(containsAssignment); -} - -export default containsAssignment; diff --git a/src/utils/getTrailingComma.ts b/src/utils/getTrailingComma.ts deleted file mode 100644 index 41e17724..00000000 --- a/src/utils/getTrailingComma.ts +++ /dev/null @@ -1,7 +0,0 @@ -import type { Plugin } from "../types"; - -function getTrailingComma(opts: Plugin.Options) { - return ["all", "es5"].includes(opts.trailingComma); -} - -export default getTrailingComma; diff --git a/src/utils/hasAncestor.ts b/src/utils/hasAncestor.ts deleted file mode 100644 index 6cf917e6..00000000 --- a/src/utils/hasAncestor.ts +++ /dev/null @@ -1,19 +0,0 @@ -import type { Plugin } from "../types"; - -function hasAncestor(path: Plugin.Path<{ type: string }>, types: string[]) { - let parent = 0; - let parentNode = path.getParentNode(); - - while (parentNode) { - if (types.includes(parentNode.type)) { - return true; - } - - parent += 1; - parentNode = path.getParentNode(parent); - } - - return false; -} - -export default hasAncestor; diff --git a/src/utils/inlineEnsureParens.ts b/src/utils/inlineEnsureParens.ts deleted file mode 100644 index d5cb1557..00000000 --- a/src/utils/inlineEnsureParens.ts +++ /dev/null @@ -1,55 +0,0 @@ -import type { Plugin, Ruby } from "../types"; - -const needsParens = [ - "args", - "assign", - "assoc_new", - "binary", - "call", - "massign", - "opassign" -]; - -// If you have a modifier statement (for instance an inline if statement or an -// inline while loop) there are times when you need to wrap the entire statement -// in parentheses. This occurs when you have something like: -// -// foo[:foo] = -// if bar? -// baz -// end -// -// Normally we would shorten this to an inline version, which would result in: -// -// foo[:foo] = baz if bar? -// -// but this actually has different semantic meaning. The first example will -// result in a nil being inserted into the hash for the :foo key, whereas the -// second example will result in an empty hash because the if statement applies -// to the entire assignment. -// -// We can fix this in a couple of ways. We can use the then keyword, as in: -// -// foo[:foo] = if bar? then baz end -// -// but I haven't actually seen this anywhere. We can also just leave it as is -// with the multi-line version, but for a short predicate and short value it -// looks pretty silly. The last option and the one I've selected here is to add -// parentheses on both sides of the expression, as in: -// -// foo[:foo] = (baz if bar?) -// -// This approach maintains the nice conciseness of the inline version, while -// keeping the correct semantic meaning. -function inlineEnsureParens( - path: Plugin.Path, - parts: Plugin.Doc[] -) { - if (needsParens.includes(path.getParentNode().type)) { - return ["(", ...parts, ")"]; - } - - return parts; -} - -export default inlineEnsureParens; diff --git a/src/utils/isEmptyBodyStmt.ts b/src/utils/isEmptyBodyStmt.ts deleted file mode 100644 index ad7743c0..00000000 --- a/src/utils/isEmptyBodyStmt.ts +++ /dev/null @@ -1,8 +0,0 @@ -import type { Ruby } from "../types"; -import isEmptyStmts from "./isEmptyStmts"; - -function isEmptyBodyStmt(node: Ruby.Bodystmt) { - return isEmptyStmts(node.body[0]) && !node.body.slice(1).some(Boolean); -} - -export default isEmptyBodyStmt; diff --git a/src/utils/isEmptyStmts.ts b/src/utils/isEmptyStmts.ts deleted file mode 100644 index cd95e7b4..00000000 --- a/src/utils/isEmptyStmts.ts +++ /dev/null @@ -1,13 +0,0 @@ -import type { Ruby } from "../types"; - -function isEmptyStmts(node: Ruby.AnyNode | Ruby.Stmts) { - return ( - node && - node.type === "stmts" && - node.body.length === 1 && - node.body[0].type === "void_stmt" && - !node.body[0].comments - ); -} - -export default isEmptyStmts; diff --git a/src/utils/literal.ts b/src/utils/literal.ts deleted file mode 100644 index 845cf4cb..00000000 --- a/src/utils/literal.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { Plugin } from "../types"; - -function literal(value: string): Plugin.Printer> { - return function printLiteral() { - return value; - }; -} - -export default literal; diff --git a/src/utils/literallineWithoutBreakParent.ts b/src/utils/literallineWithoutBreakParent.ts deleted file mode 100644 index 4262f364..00000000 --- a/src/utils/literallineWithoutBreakParent.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { Plugin } from "../types"; - -const literallineWithoutBreakParent = { - type: "line", - hard: true, - literal: true -} as Plugin.Doc; - -export default literallineWithoutBreakParent; diff --git a/src/utils/makeCall.ts b/src/utils/makeCall.ts deleted file mode 100644 index 27f0297b..00000000 --- a/src/utils/makeCall.ts +++ /dev/null @@ -1,20 +0,0 @@ -import type { Plugin, Ruby } from "../types"; - -type Callable = { - body: [any, Ruby.CallOperator, ...any[]]; -}; - -const makeCall: Plugin.Printer = (path, opts, print) => { - const operation = path.getValue().body[1]; - - // Ignoring the next block for coverage information because it's only relevant - // in Ruby 2.5 and below. - /* istanbul ignore next */ - if ([".", "&."].includes(operation as any)) { - return operation as Plugin.Doc; - } - - return operation === "::" ? "." : path.call(print, "body", 1); -}; - -export default makeCall; diff --git a/src/utils/noIndent.ts b/src/utils/noIndent.ts deleted file mode 100644 index defbd741..00000000 --- a/src/utils/noIndent.ts +++ /dev/null @@ -1,10 +0,0 @@ -const noIndent = [ - "array", - "hash", - "heredoc", - "if", - "unless", - "xstring_literal" -]; - -export default noIndent; diff --git a/src/utils/printEmptyCollection.ts b/src/utils/printEmptyCollection.ts deleted file mode 100644 index 2c13fb78..00000000 --- a/src/utils/printEmptyCollection.ts +++ /dev/null @@ -1,54 +0,0 @@ -import type { Plugin, Ruby, RequiredKeys } from "../types"; -import prettier from "../prettier"; - -const { group, hardline, indent, join, line } = prettier; - -function containedWithin(node: Ruby.Array | Ruby.Hash) { - return function containedWithinNode(comment: Ruby.Comment) { - return comment.sc >= node.sc && comment.ec <= node.ec; - }; -} - -// Empty collections are array or hash literals that do not contain any -// contents. They can, however, have comments inside the body. You can solve -// this by having a child node inside the array that gets the comments attached -// to it, but that requires modifying the parser. Instead, we can just manually -// print out the non-leading comments here. -function printEmptyCollection( - path: Plugin.Path, - opts: Plugin.Options, - startToken: string, - endToken: string -) { - const node = path.getValue(); - const containedWithinNode = containedWithin(node); - - // If there are no comments or only leading comments, then we can just print - // out the start and end token and be done, as there are no comments inside - // the body of this node. - if (!node.comments || !node.comments.some(containedWithinNode)) { - return `${startToken}${endToken}`; - } - - const comments: Plugin.Doc[] = []; - const nodePath = path as Plugin.Path>; - - // For each comment, go through its path and print it out manually. - nodePath.each((commentPath) => { - const comment = commentPath.getValue(); - - if (containedWithinNode(comment)) { - comment.printed = true; - comments.push(opts.printer.printComment(commentPath, opts)); - } - }, "comments"); - - return group([ - startToken, - indent([hardline, join(hardline, comments)]), - line, - endToken - ]); -} - -export default printEmptyCollection; diff --git a/src/utils/skipAssignIndent.ts b/src/utils/skipAssignIndent.ts deleted file mode 100644 index e9a3f8b7..00000000 --- a/src/utils/skipAssignIndent.ts +++ /dev/null @@ -1,19 +0,0 @@ -import type { Ruby } from "../types"; - -const skippable = [ - "array", - "dyna_symbol", - "hash", - "heredoc", - "lambda", - "regexp_literal" -]; - -function skipAssignIndent(node: Ruby.AnyNode): boolean { - return ( - skippable.includes(node.type) || - (node.type === "call" && skipAssignIndent(node.body[0])) - ); -} - -export default skipAssignIndent; diff --git a/test/js/files.test.js b/test/js/files.test.js new file mode 100644 index 00000000..05b239bd --- /dev/null +++ b/test/js/files.test.js @@ -0,0 +1,15 @@ +import { getFileInfo } from "prettier"; +import url from "url"; +import plugin from "../../src/plugin.js"; + +describe("files", () => { + const cases = ["files/Gemfile", "files/shebang", "files/test.rake"]; + + test.each(cases)("infers Ruby parser from %s", async (filename) => { + const filepath = url.fileURLToPath(new URL(filename, import.meta.url)); + const fileInfoOptions = { plugins: [plugin] }; + + const { inferredParser } = await getFileInfo(filepath, fileInfoOptions); + expect(inferredParser).toEqual("ruby"); + }); +}); diff --git a/test/js/files.test.ts b/test/js/files.test.ts deleted file mode 100644 index 4ecb7eca..00000000 --- a/test/js/files.test.ts +++ /dev/null @@ -1,22 +0,0 @@ -import path from "path"; -import { FileInfoOptions, getFileInfo } from "prettier"; - -// eslint-disable-next-line @typescript-eslint/no-var-requires -const plugin = require("../../src/plugin"); - -function getInferredParser(filename: string) { - const filepath = path.join(__dirname, filename); - const fileInfoOptions = { plugins: [plugin] } as any as FileInfoOptions; - - return getFileInfo(filepath, fileInfoOptions).then( - ({ inferredParser }) => inferredParser - ); -} - -describe("files", () => { - const cases = ["files/Gemfile", "files/shebang", "files/test.rake"]; - - test.each(cases)("infers Ruby parser from %s", (filename) => - expect(getInferredParser(filename)).resolves.toBe("ruby") - ); -}); diff --git a/test/js/globalSetup.js b/test/js/globalSetup.js new file mode 100644 index 00000000..72c9be34 --- /dev/null +++ b/test/js/globalSetup.js @@ -0,0 +1,30 @@ +import { spawnSync } from "child_process"; +import { spawnServer } from "../../src/plugin.js"; + +// This is somewhat similar to the spawnServer function in parseSync but +// slightly different in that it logs its information into environment variables +// so that it can be reused across the test suite. +async function globalSetup() { + // Set a RUBY_VERSION environment variable because certain tests will only run + // for certain versions of Ruby. + const args = ["--disable-gems", "-e", "puts RUBY_VERSION"]; + process.env.RUBY_VERSION = spawnSync("ruby", args) + .stdout.toString("utf-8") + .trim(); + + const { serverPID, connectionFilepath, connectionOptions } = + await spawnServer( + { + rubyPlugins: "", + rubySingleQuote: false, + trailingComma: "none" + }, + false + ); + + process.env.PRETTIER_RUBY_PID = serverPID; + process.env.PRETTIER_RUBY_FILE = connectionFilepath; + process.env.PRETTIER_RUBY_HOST = JSON.stringify(connectionOptions); +} + +export default globalSetup; diff --git a/test/js/globalSetup.ts b/test/js/globalSetup.ts deleted file mode 100644 index 8cd5001d..00000000 --- a/test/js/globalSetup.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { spawn, spawnSync } from "child_process"; -import { unlinkSync } from "fs"; -import path from "path"; - -import { getLang, getInfoFilepath } from "../../src/parser/parseSync"; - -// This is somewhat similar to the spawnServer function in parseSync but -// slightly different in that it logs its information into environment variables -// so that it can be reused across the test suite. -function globalSetup() { - // Set a RUBY_VERSION environment variable because certain tests will only run - // for certain versions of Ruby. - const args = ["--disable-gems", "-e", "puts RUBY_VERSION"]; - process.env.RUBY_VERSION = spawnSync("ruby", args).stdout.toString().trim(); - - // Set up just one parsing server for the entirety of the test suite. - const filepath = getInfoFilepath(); - const server = spawn( - "ruby", - [path.join(__dirname, "../../src/parser/server.rb"), filepath], - { - env: Object.assign({}, process.env, { LANG: getLang() }), - detached: true, - stdio: "inherit" - } - ); - - // Get the connection information from the parsing server. - const information = spawnSync("node", [ - path.join(__dirname, "../../src/parser/getInfo.js"), - filepath - ]); - - if (information.status !== 0) { - throw new Error(information.stderr.toString()); - } - - process.env.PRETTIER_RUBY_HOST = information.stdout.toString(); - process.env.PRETTIER_RUBY_PID = `${server.pid}`; - - unlinkSync(filepath); - server.unref(); -} - -export default globalSetup; diff --git a/test/js/globalTeardown.js b/test/js/globalTeardown.js new file mode 100644 index 00000000..c51948b9 --- /dev/null +++ b/test/js/globalTeardown.js @@ -0,0 +1,25 @@ +import fs from "fs"; + +// If a parse server was successfully spawned, then its process ID will be in +// the PRETTIER_RUBY_PID environment variable. At the end of the test suite we +// should send a kill signal to it. +function globalTeardown() { + const serverPID = process.env.PRETTIER_RUBY_PID; + const connectionFilepath = process.env.PRETTIER_RUBY_FILE; + + if (serverPID) { + try { + const pid = process.platform === "win32" ? serverPID : -serverPID; + process.kill(pid, "SIGINT"); + } catch (error) { + console.error("Failed to kill the parser process in globalTeardown."); + throw error; + } + } + + if (fs.existsSync(connectionFilepath)) { + fs.unlinkSync(connectionFilepath); + } +} + +export default globalTeardown; diff --git a/test/js/globalTeardown.ts b/test/js/globalTeardown.ts deleted file mode 100644 index b4b20e9a..00000000 --- a/test/js/globalTeardown.ts +++ /dev/null @@ -1,16 +0,0 @@ -// If a parse server was successfully spawned, then its process ID will be in -// the PRETTIER_RUBY_PID environment variable. At the end of the test suite we -// should send a kill signal to it. -function globalTeardown() { - const prettierRubyPID = process.env.PRETTIER_RUBY_PID; - - if (prettierRubyPID) { - try { - process.kill(parseInt(prettierRubyPID, 10), "SIGINT"); - } catch (e) { - throw new Error("Failed to kill the parser process in globalTeardown."); - } - } -} - -export default globalTeardown; diff --git a/test/js/haml/comment.test.ts b/test/js/haml/comment.test.js similarity index 69% rename from test/js/haml/comment.test.ts rename to test/js/haml/comment.test.js index 0b29db72..6ceac558 100644 --- a/test/js/haml/comment.test.ts +++ b/test/js/haml/comment.test.js @@ -2,7 +2,9 @@ import { haml } from "../utils"; describe("comment", () => { test("single line", () => { - expect(haml("/ This is the peanutbutterjelly element")).toMatchFormat(); + return expect( + haml("/ This is the peanutbutterjelly element") + ).toMatchFormat(); }); test("multi line", () => { @@ -11,7 +13,7 @@ describe("comment", () => { %p This doesn't render, because it's commented out! `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("conditional", () => { @@ -20,7 +22,7 @@ describe("comment", () => { %h1 Get Firefox `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("revealed", () => { @@ -29,6 +31,6 @@ describe("comment", () => { You are not using Internet Explorer, or are using version 10+. `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); }); diff --git a/test/js/haml/doctype.test.js b/test/js/haml/doctype.test.js new file mode 100644 index 00000000..5e6f1ba1 --- /dev/null +++ b/test/js/haml/doctype.test.js @@ -0,0 +1,43 @@ +import { haml } from "../utils"; + +describe("doctype", () => { + test("basic", () => { + return expect(haml("!!! Basic")).toMatchFormat(); + }); + + test("frameset", () => { + return expect(haml("!!! Frameset")).toMatchFormat(); + }); + + test("mobile", () => { + return expect(haml("!!! Mobile")).toMatchFormat(); + }); + + test("rdfa", () => { + return expect(haml("!!! RDFa")).toMatchFormat(); + }); + + test("strict", () => { + return expect(haml("!!! Strict")).toMatchFormat(); + }); + + test("xml", () => { + return expect(haml("!!! XML")).toMatchFormat(); + }); + + test("encoding", () => { + return expect(haml("!!! XML iso-8859-1")).toMatchFormat(); + }); + + test("1.1", () => { + return expect(haml("!!! 1.1")).toMatchFormat(); + }); + + test("5", () => { + return expect(haml("!!! 5")).toMatchFormat(); + }); + + test("misc", () => { + return expect(haml("!!! foo")).toMatchFormat(); + }); +}); diff --git a/test/js/haml/doctype.test.ts b/test/js/haml/doctype.test.ts deleted file mode 100644 index bd1ffe58..00000000 --- a/test/js/haml/doctype.test.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { haml } from "../utils"; - -describe("doctype", () => { - test("basic", () => { - expect(haml("!!! Basic")).toMatchFormat(); - }); - - test("frameset", () => { - expect(haml("!!! Frameset")).toMatchFormat(); - }); - - test("mobile", () => { - expect(haml("!!! Mobile")).toMatchFormat(); - }); - - test("rdfa", () => { - expect(haml("!!! RDFa")).toMatchFormat(); - }); - - test("strict", () => { - expect(haml("!!! Strict")).toMatchFormat(); - }); - - test("xml", () => { - expect(haml("!!! XML")).toMatchFormat(); - }); - - test("encoding", () => { - expect(haml("!!! XML iso-8859-1")).toMatchFormat(); - }); - - test("1.1", () => { - expect(haml("!!! 1.1")).toMatchFormat(); - }); - - test("5", () => { - expect(haml("!!! 5")).toMatchFormat(); - }); - - test("misc", () => { - expect(haml("!!! foo")).toMatchFormat(); - }); -}); diff --git a/test/js/haml/filter.test.js b/test/js/haml/filter.test.js new file mode 100644 index 00000000..14e7e223 --- /dev/null +++ b/test/js/haml/filter.test.js @@ -0,0 +1,31 @@ +import { haml } from "../utils"; + +describe("filter", () => { + test("self", () => { + const content = haml(` + :haml + -# comment + `); + + return expect(content).toMatchFormat(); + }); + + test("custom", () => { + const content = haml(` + :python + def foo: + bar + `); + + return expect(content).toMatchFormat(); + }); + + test("css", () => { + const content = haml(` + :css + .foo { height: 100px; width: 100px; } + `); + + return expect(content).toMatchFormat(); + }); +}); diff --git a/test/js/haml/filter.test.ts b/test/js/haml/filter.test.ts deleted file mode 100644 index f00aad6c..00000000 --- a/test/js/haml/filter.test.ts +++ /dev/null @@ -1,103 +0,0 @@ -import { haml } from "../utils"; - -describe("filter", () => { - test("self", () => { - const content = haml(` - :haml - -# comment - `); - - expect(content).toMatchFormat(); - }); - - test("custom", () => { - const content = haml(` - :python - def foo: - bar - `); - - expect(content).toMatchFormat(); - }); - - test("css", () => { - const content = haml(` - :css - .foo { height: 100px; width: 100px; } - `); - - expect(content).toChangeFormat( - haml(` - :css - .foo { - height: 100px; - width: 100px; - } - `) - ); - }); - - test("javascript", () => { - const content = haml(` - :javascript - 1+1 - `); - - expect(content).toChangeFormat( - haml(` - :javascript - 1 + 1; - `) - ); - }); - - test("less", () => { - const content = haml(` - :less - .foo { .bar { height: 100px; } } - `); - - expect(content).toChangeFormat( - haml(` - :less - .foo { - .bar { - height: 100px; - } - } - `) - ); - }); - - test("markdown", () => { - const content = haml(` - :markdown - *Hello, world!* - `); - - expect(content).toChangeFormat( - haml(` - :markdown - _Hello, world!_ - `) - ); - }); - - test("scss", () => { - const content = haml(` - :scss - .foo { .bar { height: 100px; } } - `); - - expect(content).toChangeFormat( - haml(` - :scss - .foo { - .bar { - height: 100px; - } - } - `) - ); - }); -}); diff --git a/test/js/haml/hamlComment.test.ts b/test/js/haml/hamlComment.test.js similarity index 59% rename from test/js/haml/hamlComment.test.ts rename to test/js/haml/hamlComment.test.js index de38dfae..757f241b 100644 --- a/test/js/haml/hamlComment.test.ts +++ b/test/js/haml/hamlComment.test.js @@ -2,11 +2,11 @@ import { haml } from "../utils"; describe("haml comment", () => { test("empty", () => { - expect(haml("-#")).toMatchFormat(); + return expect(haml("-#")).toMatchFormat(); }); test("same line", () => { - expect(haml("-# comment")).toMatchFormat(); + return expect(haml("-# comment")).toMatchFormat(); }); test("multi line", () => { @@ -17,10 +17,10 @@ describe("haml comment", () => { comment `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("weird spacing same line", () => { - expect(haml("-# foobar ")).toChangeFormat("-# foobar"); + return expect(haml("-# foobar ")).toChangeFormat("-# foobar"); }); }); diff --git a/test/js/haml/parser.test.ts b/test/js/haml/parser.test.ts deleted file mode 100644 index 8a6b1068..00000000 --- a/test/js/haml/parser.test.ts +++ /dev/null @@ -1,32 +0,0 @@ -import type { HAML, Plugin } from "../../../src/types"; -import parser from "../../../src/haml/parser"; - -describe("parser", () => { - test("parse", () => { - expect(parser.parse("= foo", {}, {} as Plugin.Options).type).toEqual( - "root" - ); - }); - - test("parse failure", () => { - expect(() => - parser.parse(`%div("invalid ": 1)`, {}, {} as Plugin.Options) - ).toThrowError(); - }); - - test("hasPragma", () => { - const withPragma = "-# @prettier"; - const withoutPragma = "-# foo"; - - expect(parser.hasPragma(withPragma)).toBe(true); - expect(parser.hasPragma(withoutPragma)).toBe(false); - }); - - test("locStart", () => { - expect(parser.locStart({} as HAML.AnyNode)).toEqual(0); - }); - - test("locEnd", () => { - expect(parser.locEnd({} as HAML.AnyNode)).toEqual(0); - }); -}); diff --git a/test/js/haml/plain.test.ts b/test/js/haml/plain.test.js similarity index 72% rename from test/js/haml/plain.test.ts rename to test/js/haml/plain.test.js index 4f824053..87b1e79f 100644 --- a/test/js/haml/plain.test.ts +++ b/test/js/haml/plain.test.js @@ -4,10 +4,10 @@ describe("plain", () => { const specialChars = ["%", ".", "#", "/", "!", "=", "&", "~", "-", "\\", ":"]; test.each(specialChars)("escapes starting %s", (specialChar) => { - expect(haml(`\\${specialChar}`)).toMatchFormat(); + return expect(haml(`\\${specialChar}`)).toMatchFormat(); }); test("does not unnecessarily escape other characters", () => { - expect(haml("foo")).toMatchFormat(); + return expect(haml("foo")).toMatchFormat(); }); }); diff --git a/test/js/haml/script.test.ts b/test/js/haml/script.test.js similarity index 54% rename from test/js/haml/script.test.ts rename to test/js/haml/script.test.js index 35569303..f9c56e02 100644 --- a/test/js/haml/script.test.ts +++ b/test/js/haml/script.test.js @@ -2,7 +2,7 @@ import { haml } from "../utils"; describe("script", () => { test("single line", () => { - expect(haml('%p= "hello"')).toMatchFormat(); + return expect(haml('%p= "hello"')).toMatchFormat(); }); test("multi line", () => { @@ -12,15 +12,11 @@ describe("script", () => { = "yo" `); - expect(content).toMatchFormat(); - }); - - test("escape", () => { - expect(haml(`& I like #{"cheese & crackers"}`)).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("escape with interpolate", () => { - expect(haml(`&= "I like cheese & crackers"`)).toMatchFormat(); + return expect(haml(`&= "I like cheese & crackers"`)).toMatchFormat(); }); test("children", () => { @@ -29,10 +25,10 @@ describe("script", () => { = bar `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("preserve", () => { - expect(haml('~ "Foo\\n

Bar\\nBaz
"')).toMatchFormat(); + return expect(haml('~ "Foo\\n
Bar\\nBaz
"')).toMatchFormat(); }); }); diff --git a/test/js/haml/silentScript.test.ts b/test/js/haml/silentScript.test.js similarity index 78% rename from test/js/haml/silentScript.test.ts rename to test/js/haml/silentScript.test.js index d263bd14..c7e78177 100644 --- a/test/js/haml/silentScript.test.ts +++ b/test/js/haml/silentScript.test.js @@ -2,7 +2,7 @@ import { haml } from "../utils"; describe("silent script", () => { test("single line", () => { - expect(haml('- foo = "hello"')).toMatchFormat(); + return expect(haml('- foo = "hello"')).toMatchFormat(); }); test("multi-line", () => { @@ -11,7 +11,7 @@ describe("silent script", () => { - bar `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("multi line with case", () => { @@ -26,7 +26,7 @@ describe("silent script", () => { = "3" `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("multi line with if/else", () => { @@ -40,7 +40,7 @@ describe("silent script", () => { -# qix `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("multi line with unless/else", () => { @@ -54,7 +54,7 @@ describe("silent script", () => { -# qix `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("multi line with embedded", () => { @@ -67,6 +67,6 @@ describe("silent script", () => { %span baz `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); }); diff --git a/test/js/haml/tag.test.ts b/test/js/haml/tag.test.js similarity index 54% rename from test/js/haml/tag.test.ts rename to test/js/haml/tag.test.js index 6d050a89..70f4c17f 100644 --- a/test/js/haml/tag.test.ts +++ b/test/js/haml/tag.test.js @@ -2,31 +2,31 @@ import { long, haml } from "../utils"; describe("tag", () => { test("class", () => { - expect(haml("%p.foo")).toMatchFormat(); + return expect(haml("%p.foo")).toMatchFormat(); }); test("class multiple", () => { - expect(haml("%p.foo.bar.baz")).toMatchFormat(); + return expect(haml("%p.foo.bar.baz")).toMatchFormat(); }); test("id", () => { - expect(haml("%p#foo")).toMatchFormat(); + return expect(haml("%p#foo")).toMatchFormat(); }); test("classes and id", () => { - expect(haml("%p.foo.bar#baz")).toMatchFormat(); + return expect(haml("%p.foo.bar#baz")).toMatchFormat(); }); test("self closing", () => { - expect(haml("%br/")).toMatchFormat(); + return expect(haml("%br/")).toMatchFormat(); }); test("whitespace removal left single line", () => { - expect(haml('%p>= "Foo\\nBar"')).toMatchFormat(); + return expect(haml('%p>= "Foo\\nBar"')).toMatchFormat(); }); test("whitespace removal right single line", () => { - expect(haml('%p<= "Foo\\nBar"')).toMatchFormat(); + return expect(haml('%p<= "Foo\\nBar"')).toMatchFormat(); }); test("whitespace removal right multi line", () => { @@ -36,72 +36,65 @@ describe("tag", () => { Foo! `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("dynamic attribute", () => { - expect(haml("%span{html_attrs('fr-fr')}")).toMatchFormat(); + return expect(haml("%span{html_attrs('fr-fr')}")).toMatchFormat(); }); test("dynamic attributes (ruby hash)", () => { - const content = haml("%div{data: { controller: 'lesson-evaluation' }}"); + const content = haml(`%div{data: { controller: "lesson-evaluation" }}`); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("dynamic attributes (html-style)", () => { const content = haml("%img(title=@title alt=@alt)/"); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); describe("static attributes", () => { test("basic", () => { - expect(haml("%span(foo)")).toChangeFormat("%span{foo: true}"); + return expect(haml("%span(foo)")).toChangeFormat("%span{foo: true}"); }); test("hash label, single quote", () => { const content = haml(`%section(xml:lang="en" title="title")`); - const expected = "%section{'xml:lang': 'en', title: 'title'}"; + const expected = `%section{"xml:lang": "en", title: "title"}`; - expect(content).toChangeFormat(expected); + return expect(content).toChangeFormat(expected); }); test("hash label, double quote", () => { const content = haml(`%section(xml:lang="en" title="title")`); const expected = `%section{"xml:lang": "en", title: "title"}`; - expect(content).toChangeFormat(expected, { rubySingleQuote: false }); + return expect(content).toChangeFormat(expected); }); test("hash label, single quote, interpolation", () => { const content = haml(`%section{title: "#{title}"}`); - expect(content).toMatchFormat(); - }); - - test("hash rocket, single quote", () => { - const content = haml(`%section(xml:lang="en" title="title")`); - const expected = `%section{:'xml:lang' => 'en', :title => 'title'}`; - - expect(content).toChangeFormat(expected, { rubyHashLabel: false }); - }); - - test("hash rocket, double quote", () => { - const content = haml(`%section(xml:lang="en" title="title")`); - const expected = '%section{:"xml:lang" => "en", :title => "title"}'; - - expect(content).toChangeFormat(expected, { - rubyHashLabel: false, - rubySingleQuote: false - }); + return expect(content).toMatchFormat(); }); test("non-strings", () => { const content = haml(`%section(foo=1 bar=2)`); const expected = `%section(foo=1 bar=2)`; - expect(content).toChangeFormat(expected); + return expect(content).toChangeFormat(expected); + }); + + test("attributes prefixed with @", () => { + return Promise.all([ + expect(haml(`%span{"@click": "open = true"}`)).toMatchFormat(), + expect(haml(`%span{"@click.outside": "open = true"}`)).toMatchFormat(), + expect( + haml(`%span{"@keydown.arrow-up.prevent": "open = true"}`) + ).toMatchFormat() + ]); }); }); @@ -112,7 +105,7 @@ describe("tag", () => { Hello! `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("long declaration before text", () => { @@ -126,18 +119,18 @@ describe("tag", () => { foo `); - expect(content).toChangeFormat(expected); + return expect(content).toChangeFormat(expected); }); test("with quotes in string", () => { const content = haml(`%div{title: "escaping quotes, it's annoying"}`); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("with interpolation in the value", () => { const content = haml(`%p hello"#{1 + 2} little pigs"`); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); }); diff --git a/test/js/rbs/method.txt b/test/js/rbs/method.txt index abc4047e..dfd4dd65 100644 --- a/test/js/rbs/method.txt +++ b/test/js/rbs/method.txt @@ -1,11 +1,11 @@ def t: -> void def t: -> void | ... -def t: -> ('a' | 'b' | 'c') -def t: -> ('a' | 'b' | 'c')? -def t: -> ('a' & 'b' & 'c') -def t: -> ('a' & 'b' & 'c')? -def t: -> ('a' & ('b' | 'c')) -def t: -> ('a' & ('b' | 'c'))? +def t: -> ("a" | "b" | "c") +def t: -> ("a" | "b" | "c")? +def t: -> ("a" & "b" & "c") +def t: -> ("a" & "b" & "c")? +def t: -> ("a" & ("b" | "c")) +def t: -> ("a" & ("b" | "c"))? def self.t: -> void def self.t: -> void | ... def self?.t: -> void diff --git a/test/js/rbs/parser.test.ts b/test/js/rbs/parser.test.ts deleted file mode 100644 index efa7ea76..00000000 --- a/test/js/rbs/parser.test.ts +++ /dev/null @@ -1,45 +0,0 @@ -import type { Plugin, RBS } from "../../../src/types"; -import { ruby } from "../utils"; -import parser from "../../../src/rbs/parser"; - -function parse(source: string) { - return parser.parse(source, {}, {} as Plugin.Options); -} - -describe("parser", () => { - test("parse", () => { - expect(parse("class Foo end").declarations).toHaveLength(1); - }); - - test("parse failure", () => { - expect(() => parse("<>")).toThrowError(); - }); - - test("hasPragma", () => { - const withPragma = ruby(` - # @prettier - module Foo - end - `); - - const withoutPragma = ruby(` - module Foo - end - `); - - expect(parser.hasPragma(withPragma)).toBe(true); - expect(parser.hasPragma(withoutPragma)).toBe(false); - }); - - test("locStart", () => { - const node = { location: { start_pos: 5 } } as RBS.AnyNode; - - expect(parser.locStart(node)).toEqual(5); - }); - - test("locEnd", () => { - const node = { location: { end_pos: 5 } } as RBS.AnyNode; - - expect(parser.locEnd(node)).toEqual(5); - }); -}); diff --git a/test/js/rbs/rbs.test.ts b/test/js/rbs/rbs.test.js similarity index 58% rename from test/js/rbs/rbs.test.ts rename to test/js/rbs/rbs.test.js index 00f4cf46..3e6addac 100644 --- a/test/js/rbs/rbs.test.ts +++ b/test/js/rbs/rbs.test.js @@ -1,21 +1,19 @@ -import fs from "fs"; -import os from "os"; -import path from "path"; - +import { readFileSync } from "fs"; +import { platform } from "os"; import { atLeastVersion, rbs } from "../utils"; -function testCases(name: string, transform: (_source: string) => string) { - const buffer = fs.readFileSync(path.resolve(__dirname, `${name}.txt`)); +function testCases(name, transform) { + const buffer = readFileSync(new URL(`${name}.txt`, import.meta.url)); const sources = buffer.toString().slice(0, -1).split(/\r?\n/); sources.forEach((source) => { test(source, () => { - expect(rbs(transform(source))).toMatchFormat(); + return expect(rbs(transform(source))).toMatchFormat(); }); }); } -function describeCases(name: string, transform: (_source: string) => string) { +function describeCases(name, transform) { describe(name, () => { testCases(name, transform); }); @@ -35,7 +33,7 @@ describe("rbs", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("interface with type params", () => { @@ -44,16 +42,36 @@ describe("rbs", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); + if (atLeastVersion("3.1")) { + test("interface with bounded type param", () => { + const content = rbs(` + interface _Foo[A < B] + end + `); + + return expect(content).toMatchFormat(); + }); + + test("interface with fancy bounded type params", () => { + const content = rbs(` + interface _Foo[U < singleton(::Hash), V < W[X, Y]] + end + `); + + return expect(content).toMatchFormat(); + }); + } + test("class", () => { const content = rbs(` class Foo end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("class with type params", () => { @@ -62,7 +80,7 @@ describe("rbs", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("class with complicated type params", () => { @@ -71,9 +89,29 @@ describe("rbs", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); + if (atLeastVersion("3.1")) { + test("class with bounded type param", () => { + const content = rbs(` + class Foo[A < B] + end + `); + + return expect(content).toMatchFormat(); + }); + + test("class with fancy bounded type params", () => { + const content = rbs(` + class Foo[U < singleton(::Hash), V < W[X, Y]] + end + `); + + return expect(content).toMatchFormat(); + }); + } + test("class with annotations", () => { const content = rbs(` %a{This is an annotation.} @@ -81,7 +119,7 @@ describe("rbs", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("class with annotations that cannot be switched to braces", () => { @@ -91,7 +129,7 @@ describe("rbs", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("class with comments", () => { @@ -101,7 +139,7 @@ describe("rbs", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("class with superclass", () => { @@ -110,7 +148,7 @@ describe("rbs", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("module", () => { @@ -119,7 +157,7 @@ describe("rbs", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("module with type params", () => { @@ -128,7 +166,7 @@ describe("rbs", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("module with self types", () => { @@ -137,7 +175,7 @@ describe("rbs", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("multiple empty lines", () => { @@ -160,7 +198,7 @@ describe("rbs", () => { end `); - expect(content).toChangeFormat(expected); + return expect(content).toChangeFormat(expected); }); }); @@ -179,35 +217,43 @@ describe("rbs", () => { testCases("literal", (source) => `T: ${source}`); test("+1 drops the plus sign", () => { - expect(rbs("T: +1")).toChangeFormat("T: 1"); + return expect(rbs("T: +1")).toChangeFormat("T: 1"); }); test("uses default quotes", () => { - expect(rbs("T: 'foo'")).toMatchFormat(); + return expect(rbs(`T: "foo"`)).toMatchFormat(); }); test("changes quotes to match", () => { - expect(rbs("T: 'foo'")).toChangeFormat(`T: "foo"`, { - rubySingleQuote: false - }); + return expect(rbs("T: 'foo'")).toChangeFormat(`T: "foo"`); }); test("keeps string the same when there is an escape sequence", () => { - expect(rbs(`T: "super \\" duper"`)).toMatchFormat(); + return expect(rbs(`T: "super \\a duper"`)).toMatchFormat(); + }); + + test("unescapes double quotes when using single quotes", () => { + return expect(rbs(`T: "super \\" duper"`)).toChangeFormat( + `T: "super \\" duper"` + ); }); test("unescapes single quotes when using double quotes", () => { - expect(rbs(`T: 'super \\' duper'`)).toChangeFormat(`T: "super ' duper"`, { - rubySingleQuote: false - }); + return expect(rbs(`T: 'super \\' duper'`)).toChangeFormat( + `T: 'super \\' duper'` + ); }); test("maintains escape sequences when using double quotes", () => { - expect(rbs(`T: "escape sequences \\a\\b\\e\\f\\n\\r"`)).toMatchFormat(); + return expect( + rbs(`T: "escape sequences \\a\\b\\e\\f\\n\\r"`) + ).toMatchFormat(); }); test("maintains not escape sequences when using single quotes", () => { - expect(rbs(`T: 'escape sequences \\a\\b\\e\\f\\n\\r'`)).toMatchFormat(); + return expect( + rbs(`T: 'escape sequences \\a\\b\\e\\f\\n\\r'`) + ).toMatchFormat(); }); }); @@ -233,27 +279,21 @@ describe("rbs", () => { testCases("optional", (source) => `T: ${source}`); test("removes optional space before question mark", () => { - expect(rbs("T: :foo ?")).toChangeFormat("T: :foo?"); + return expect(rbs("T: :foo ?")).toChangeFormat("T: :foo?"); }); }); - describe("plain", () => { - testCases("plain", (source) => `T: ${source}`); - - test("any gets transformed into untyped", () => { - expect(rbs("T: any")).toChangeFormat("T: untyped"); - }); - }); + describeCases("plain", (source) => `T: ${source}`); describe("proc", () => { testCases("proc", (source) => `T: ${source}`); test("drops optional parentheses when there are no params", () => { - expect(rbs("T: ^() -> void")).toChangeFormat("T: ^-> void"); + return expect(rbs("T: ^() -> void")).toChangeFormat("T: ^-> void"); }); test("drops optional parentheses with block param when there are no params to the block", () => { - expect(rbs("T: ^{ () -> void } -> void")).toChangeFormat( + return expect(rbs("T: ^{ () -> void } -> void")).toChangeFormat( "T: ^{ -> void } -> void" ); }); @@ -263,14 +303,14 @@ describe("rbs", () => { // For some reason these tests are failing on windows on Ruby < 3.0. I'm not // sure why, but I'm leaving it here for now. - if (os.platform() !== "win32" || atLeastVersion("3.0")) { + if (platform() !== "win32" || atLeastVersion("3.0")) { describe("non-ASCII", () => { test("emoji", () => { - expect(rbs(`T: { "🌼" => Integer }`)).toMatchFormat(); + return expect(rbs(`T: { "🌼" => Integer }`)).toMatchFormat(); }); test("kanji", () => { - expect(rbs(`T: { "日本語" => Integer }`)).toMatchFormat(); + return expect(rbs(`T: { "日本語" => Integer }`)).toMatchFormat(); }); }); } diff --git a/test/js/rbs/record.txt b/test/js/rbs/record.txt index debba3ed..d5e3a6e0 100644 --- a/test/js/rbs/record.txt +++ b/test/js/rbs/record.txt @@ -1,3 +1,3 @@ { foo: Integer } -{ foo: untyped, 3 => 'hoge' } +{ foo: untyped, 3 => "hoge" } { :+ => 1 } diff --git a/test/js/ruby/comments.test.ts b/test/js/ruby/comments.test.js similarity index 81% rename from test/js/ruby/comments.test.ts rename to test/js/ruby/comments.test.js index 5c34fbf1..1dcea4a3 100644 --- a/test/js/ruby/comments.test.ts +++ b/test/js/ruby/comments.test.js @@ -1,4 +1,4 @@ -import { ruby } from "../utils"; +import { ruby } from "../utils.js"; describe("comments", () => { describe("on their own line", () => { @@ -10,7 +10,7 @@ describe("comments", () => { a = 1 `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("at the end of the file", () => { @@ -21,7 +21,7 @@ describe("comments", () => { # the end of the file `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); const commentBlocks = [ @@ -46,7 +46,7 @@ describe("comments", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("as the first statement", () => { @@ -58,7 +58,7 @@ describe("comments", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("as the last statement", () => { @@ -70,7 +70,7 @@ describe("comments", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); }); @@ -91,7 +91,7 @@ describe("comments", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("case/when/end statements", () => { @@ -110,7 +110,7 @@ describe("comments", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("begin/rescue/ensure/end statements", () => { @@ -130,7 +130,7 @@ describe("comments", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); /* eslint-disable no-useless-escape */ @@ -146,21 +146,25 @@ describe("comments", () => { /_/ /_/ /_/ /____/ /_/ /_/ /_____/ /____/ /_/ /_/ `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); }); describe("inline", () => { test("basic", () => { - expect("foo # this is an inline comment").toMatchFormat(); + return expect("foo # this is an inline comment").toMatchFormat(); }); test("commands", () => { - expect("command 'foo' # this is an inline comment").toMatchFormat(); + return expect( + `command "foo" # this is an inline comment` + ).toMatchFormat(); }); test("command calls", () => { - expect("command.call 'foo' # this is an inline comment").toMatchFormat(); + return expect( + `command.call "foo" # this is an inline comment` + ).toMatchFormat(); }); }); @@ -176,7 +180,7 @@ describe("comments", () => { ] `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); }); @@ -186,13 +190,13 @@ describe("comments", () => { { # these are comments # inside of a hash - foo: 'bar', + foo: "bar", # and then some more - bar: 'baz' + bar: "baz" } `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); }); @@ -208,7 +212,7 @@ describe("comments", () => { ) `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); }); @@ -218,7 +222,12 @@ describe("comments", () => { .baz `); - expect(content).toMatchFormat(); + const expected = ruby(` + foo.bar # comment + .baz + `); + + return expect(content).toChangeFormat(expected); }); describe("declaration style comments", () => { @@ -237,18 +246,18 @@ describe("comments", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); }); test("works with multi-byte characters", () => { const content = ruby(` [ - ['先生小'], # - ['小'] + ["先生小"], # + ["小"] ] `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); }); diff --git a/test/js/ruby/embed.test.ts b/test/js/ruby/embed.test.ts deleted file mode 100644 index beeca9ac..00000000 --- a/test/js/ruby/embed.test.ts +++ /dev/null @@ -1,144 +0,0 @@ -import { ruby } from "../utils"; - -describe("embed", () => { - test("ignores parsers it can't find", () => { - const content = ruby(` - <<-JAVA - int i=0; - JAVA - `); - - expect(content).toMatchFormat(); - }); - - test("formats correctly on straight heredocs", () => { - const content = ruby(` - <<-JS.squish - const a=1; - const b=2; - return a+b; - JS - `); - - const expected = ruby(` - <<-JS.squish - const a = 1; - const b = 2; - return a + b; - JS - `); - - expect(content).toChangeFormat(expected); - }); - - test("formats correctly on squiggly heredocs", () => { - const content = ruby(` - <<~JS.squish - const a=1; - const b=2; - return a+b; - JS - `); - - const expected = ruby(` - <<~JS.squish - const a = 1; - const b = 2; - return a + b; - JS - `); - - expect(content).toChangeFormat(expected); - }); - - test("does not format if the heredoc has an interpolation", () => { - const content = ruby(` - <<~JS.squish - const a=1; - const b=#{2}; - return a+b; - JS - `); - - expect(content).toMatchFormat(); - }); - - test("removes whitespace so embedded parsers don't misinterpret", () => { - const content = ruby(` - <<~MARKDOWN - foo - MARKDOWN - `); - - const expected = ruby(` - <<~MARKDOWN - foo - MARKDOWN - `); - - expect(content).toChangeFormat(expected); - }); - - test("keeps parent indentation", () => { - const content = ruby(` - some_block do - another_block do - x += 1 - description <<~JS - // This is a DSL method on the another_block inner block. - // This is another line of the string. - JS - end - end - `); - - expect(content).toMatchFormat(); - }); - - test("correctly indents nested code while keeping parent indentation", () => { - const content = ruby(` - some_block do - another_block do - x += 1 - description <<~JS - [1, function () { return 2; }, 3]; - JS - end - end - `); - - const expected = ruby(` - some_block do - another_block do - x += 1 - description <<~JS - [ - 1, - function () { - return 2; - }, - 3 - ]; - JS - end - end - `); - - expect(content).toChangeFormat(expected); - }); - - test("doesn't consider empty lines as part of the common leading whitespace", () => { - const content = ruby(` - some_block do - x += 1 - description <<~MARKDOWN - This is a line. It's followed by two literal line breaks. - - This is another line of the string. - MARKDOWN - end - `); - - expect(content).toMatchFormat(); - }); -}); diff --git a/test/js/ruby/encoding.test.js b/test/js/ruby/encoding.test.js new file mode 100644 index 00000000..1d6bb806 --- /dev/null +++ b/test/js/ruby/encoding.test.js @@ -0,0 +1,19 @@ +describe("encoding", () => { + const header = "# -*- encoding: binary -*-"; + + test("comments", () => { + return expect(`${header}\n# il était`).toMatchFormat(); + }); + + test("symbol literals", () => { + return expect(`${header}\n:il_était`).toMatchFormat(); + }); + + test("string literals", () => { + return expect(`${header}\n"ひらがな"`).toMatchFormat(); + }); + + test("regexp literals", () => { + return expect(`${header}\n/ひらがな/`).toMatchFormat(); + }); +}); diff --git a/test/js/ruby/encoding.test.ts b/test/js/ruby/encoding.test.ts deleted file mode 100644 index 39693dbe..00000000 --- a/test/js/ruby/encoding.test.ts +++ /dev/null @@ -1,19 +0,0 @@ -describe("encoding", () => { - const header = "# -*- encoding: binary -*-"; - - test("comments", () => { - expect(`${header}\n# il était`).toMatchFormat(); - }); - - test("symbol literals", () => { - expect(`${header}\n:il_était`).toMatchFormat(); - }); - - test("string literals", () => { - expect(`${header}\n'ひらがな'`).toMatchFormat(); - }); - - test("regexp literals", () => { - expect(`${header}\n/ひらがな/`).toMatchFormat(); - }); -}); diff --git a/test/js/ruby/errors.test.js b/test/js/ruby/errors.test.js new file mode 100644 index 00000000..a5e99bbb --- /dev/null +++ b/test/js/ruby/errors.test.js @@ -0,0 +1,24 @@ +import { format } from "prettier"; + +describe("errors", () => { + const cases = [ + "alias $a $1", + "self = 1", + "$` = 1", + "class foo; end", + "def foo(A) end", + "def foo($a) end", + "def foo(@a) end", + "def foo(@@a) end", + "<>" + ]; + + test.each(cases)("fails for %s", async (content) => { + try { + await format(content, { parser: "ruby", plugins: ["."] }); + expect(true).toBe(false); + } catch (error) { + expect(error.loc).toBeDefined(); + } + }); +}); diff --git a/test/js/ruby/errors.test.ts b/test/js/ruby/errors.test.ts deleted file mode 100644 index b1054e33..00000000 --- a/test/js/ruby/errors.test.ts +++ /dev/null @@ -1,29 +0,0 @@ -import prettier from "prettier"; -import printer from "../../../src/ruby/printer"; - -describe("errors", () => { - const cases = [ - "alias $a $1", - "self = 1", - "$` = 1", - "class foo; end", - "def foo(A) end", - "def foo($a) end", - "def foo(@a) end", - "def foo(@@a) end", - "<>" - ]; - - test.each(cases)("fails for %s", (content) => { - const format = () => - prettier.format(content, { parser: "ruby", plugins: ["."] }); - - expect(format).toThrow(); - }); - - test("when encountering an unsupported node type", () => { - const path = { getValue: () => ({ type: "unsupported", body: {} }) }; - - expect(() => (printer as any).print(path)).toThrow("Unsupported"); - }); -}); diff --git a/test/js/ruby/ignore.test.ts b/test/js/ruby/ignore.test.js similarity index 61% rename from test/js/ruby/ignore.test.ts rename to test/js/ruby/ignore.test.js index f0626f20..f1ce1f95 100644 --- a/test/js/ruby/ignore.test.ts +++ b/test/js/ruby/ignore.test.js @@ -1,12 +1,12 @@ -import { ruby } from "../utils"; +import { ruby } from "../utils.js"; describe("ignore", () => { test("you can ignore code blocks", () => { const content = ruby(` - # prettier-ignore + # stree-ignore class Foo; def bar; 1+1+1; end; end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); }); diff --git a/test/js/ruby/layout.test.ts b/test/js/ruby/layout.test.js similarity index 67% rename from test/js/ruby/layout.test.ts rename to test/js/ruby/layout.test.js index 37da3f63..393d5e5d 100644 --- a/test/js/ruby/layout.test.ts +++ b/test/js/ruby/layout.test.js @@ -1,20 +1,20 @@ -import { ruby } from "../utils"; +import { ruby } from "../utils.js"; describe("layout", () => { test("turns multiple blank lines into just one blank line", () => { - expect("1\n\n\n\n\n2").toChangeFormat("1\n\n2"); + return expect("1\n\n\n\n\n2").toChangeFormat("1\n\n2"); }); test("turns semicolons into adjacent lines", () => { - expect("1; 2; 3").toChangeFormat("1\n2\n3"); + return expect("1; 2; 3").toChangeFormat("1\n2\n3"); }); test("maintains semicolons from within interpolation", () => { - expect(`"a#{b; c}"`).toMatchFormat(); + return expect(`"a#{b; c}"`).toMatchFormat(); }); test("handles multiple newlines at the end of the file", () => { - expect("foo\n\n\n").toChangeFormat("foo"); + return expect("foo\n\n\n").toChangeFormat("foo"); }); test("keeps comments in their place when nothing to attach to", () => { @@ -36,6 +36,6 @@ describe("layout", () => { # Comment `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); }); diff --git a/test/js/ruby/locations.test.ts b/test/js/ruby/locations.test.ts deleted file mode 100644 index c3239faa..00000000 --- a/test/js/ruby/locations.test.ts +++ /dev/null @@ -1,10 +0,0 @@ -import parser from "../../../src/ruby/parser"; - -describe("locations", () => { - test("locStart and locEnd are defined", () => { - const { hasOwnProperty } = Object.prototype; - - expect(hasOwnProperty.call(parser, "locStart")).toBe(true); - expect(hasOwnProperty.call(parser, "locEnd")).toBe(true); - }); -}); diff --git a/test/js/ruby/nodes/alias.test.ts b/test/js/ruby/nodes/alias.test.js similarity index 55% rename from test/js/ruby/nodes/alias.test.ts rename to test/js/ruby/nodes/alias.test.js index f1f67398..df83939f 100644 --- a/test/js/ruby/nodes/alias.test.ts +++ b/test/js/ruby/nodes/alias.test.js @@ -1,36 +1,36 @@ -import { long, ruby } from "../../utils"; +import { long, ruby } from "../../utils.js"; describe("alias", () => { test("bare word aliases", () => { - expect("alias foo bar").toMatchFormat(); + return expect("alias foo bar").toMatchFormat(); }); test("bare word operator aliases", () => { - expect("alias << push").toMatchFormat(); + return expect("alias << push").toMatchFormat(); }); test("bare word keyword aliases", () => { - expect("alias in within").toMatchFormat(); + return expect("alias in within").toMatchFormat(); }); test("bare word constant aliases", () => { - expect("alias in IN").toMatchFormat(); + return expect("alias in IN").toMatchFormat(); }); test("symbol aliases become bare word aliases", () => { - expect("alias :foo :bar").toChangeFormat("alias foo bar"); + return expect("alias :foo :bar").toChangeFormat("alias foo bar"); }); test("dynamic symbols do not get transformed (left)", () => { - expect("alias :'foo' :bar").toChangeFormat("alias :'foo' bar"); + return expect(`alias :"foo" :bar`).toChangeFormat(`alias :"foo" bar`); }); test("dynamic symbols do not get transformed (right)", () => { - expect("alias :foo :'bar'").toChangeFormat("alias foo :'bar'"); + return expect(`alias :foo :"bar"`).toChangeFormat(`alias foo :"bar"`); }); test("global aliases", () => { - expect("alias $foo $bar").toMatchFormat(); + return expect("alias $foo $bar").toMatchFormat(); }); test("handles long symbols", () => { @@ -39,11 +39,11 @@ describe("alias", () => { bar `); - expect(`alias ${long} bar`).toChangeFormat(expected); + return expect(`alias ${long} bar`).toChangeFormat(expected); }); test("handles comments on the right node", () => { - expect("alias foo bar # baz").toMatchFormat(); + return expect("alias foo bar # baz").toMatchFormat(); }); test("handles comments on the left node", () => { @@ -52,7 +52,7 @@ describe("alias", () => { bar `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("handles comments on both nodes", () => { @@ -61,6 +61,6 @@ describe("alias", () => { bar # bar `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); }); diff --git a/test/js/ruby/nodes/aref.test.ts b/test/js/ruby/nodes/aref.test.js similarity index 55% rename from test/js/ruby/nodes/aref.test.ts rename to test/js/ruby/nodes/aref.test.js index 8bb699cd..aa7d7cb4 100644 --- a/test/js/ruby/nodes/aref.test.ts +++ b/test/js/ruby/nodes/aref.test.js @@ -1,24 +1,24 @@ -import { ruby } from "../../utils"; +import { ruby } from "../../utils.js"; describe("aref", () => { test("literal reference", () => { - expect("array[5]").toMatchFormat(); + return expect("array[5]").toMatchFormat(); }); test("dynamic reference", () => { - expect("array[idx]").toMatchFormat(); + return expect("array[idx]").toMatchFormat(); }); test("reference with comment", () => { - expect("array[idx] # foo").toMatchFormat(); + return expect("array[idx] # foo").toMatchFormat(); }); test("literal assignment", () => { - expect("array[5] = 6").toMatchFormat(); + return expect("array[5] = 6").toMatchFormat(); }); test("dynamic assignment", () => { - expect("array[idx] = 6").toMatchFormat(); + return expect("array[idx] = 6").toMatchFormat(); }); test("comments within assignment", () => { @@ -30,6 +30,6 @@ describe("aref", () => { ] `); - expect(contents).toMatchFormat(); + return expect(contents).toMatchFormat(); }); }); diff --git a/test/js/ruby/nodes/arrays.test.ts b/test/js/ruby/nodes/arrays.test.js similarity index 56% rename from test/js/ruby/nodes/arrays.test.ts rename to test/js/ruby/nodes/arrays.test.js index 1bd4311b..e54d567f 100644 --- a/test/js/ruby/nodes/arrays.test.ts +++ b/test/js/ruby/nodes/arrays.test.js @@ -1,72 +1,64 @@ -import { long, ruby } from "../../utils"; +import { long, ruby } from "../../utils.js"; describe("array", () => { test("empty arrays", () => { - expect("[]").toMatchFormat(); + return expect("[]").toMatchFormat(); }); test("basic formatting", () => { - expect("[1, 2, 3]").toMatchFormat(); + return expect("[1, 2, 3]").toMatchFormat(); }); test("does not transform single string arrays", () => { - expect("['a']").toMatchFormat(); + return expect(`["a"]`).toMatchFormat(); }); test("does not transform single symbol arrays", () => { - expect("[:a]").toMatchFormat(); + return expect("[:a]").toMatchFormat(); }); test("transforms basic string arrays", () => { - expect("['a', 'b', 'c', 'd', 'e']").toChangeFormat("%w[a b c d e]"); + return expect(`["a", "b", "c", "d", "e"]`).toChangeFormat("%w[a b c d e]"); }); test("does not transform string arrays with interpolation", () => { - expect(`['a', "#{b}", 'c']`).toMatchFormat(); + return expect(`["a", "#{b}", "c"]`).toMatchFormat(); }); test("does not transform string arrays with spaces", () => { - expect("['a', 'b c', 'd', 'e']").toMatchFormat(); + return expect(`["a", "b c", "d", "e"]`).toMatchFormat(); }); test("does not transform string arrays with tabs", () => { - expect(`['a', "b\\tc", 'd', 'e']`).toMatchFormat(); + return expect(`["a", "b\\tc", "d", "e"]`).toMatchFormat(); }); test("does not transform string arrays with newlines", () => { - expect(`['a', "b\\nc", 'd', 'e']`).toMatchFormat(); + return expect(`["a", "b\\nc", "d", "e"]`).toMatchFormat(); }); test("does not transform string arrays with carriage returns", () => { - expect(`['a', "b\\rc", 'd', 'e']`).toMatchFormat(); + return expect(`["a", "b\\rc", "d", "e"]`).toMatchFormat(); }); test("does not transform string arrays with interpolation", () => { - expect(`['a', "b#{c}d", 'e']`).toMatchFormat(); + return expect(`["a", "b#{c}d", "e"]`).toMatchFormat(); }); test("does not transform string arrays with brackets", () => { - expect(`['a [] b', 'c [] d']`).toMatchFormat(); - }); - - test("does not transform string arrays if disabled", () => { - expect(`['a', 'b']`).toMatchFormat({ rubyArrayLiteral: false }); - }); - - test("does not transform symbol arrays if disabled", () => { - expect("[:a, :b]").toMatchFormat({ rubyArrayLiteral: false }); + return expect(`["a [] b", "c [] d"]`).toMatchFormat(); }); test("transforms basic symbol arrays", () => { - expect("[:a, :b, :c]").toChangeFormat("%i[a b c]"); + return expect("[:a, :b, :c]").toChangeFormat("%i[a b c]"); }); test("does not transform symbol arrays with dynamic symbols", () => { - expect("[:'a + b']").toMatchFormat(); + return expect(`[:"a + b"]`).toMatchFormat(); }); test("handles splats", () => { - expect("[1, 2, *[3, 4], 5, 6]").toMatchFormat(); + return expect("[1, 2, *[3, 4], 5, 6]").toMatchFormat(); }); test("breaks appropriately", () => { @@ -82,18 +74,11 @@ describe("array", () => { ] `); - expect(contents).toMatchFormat(); - }); - - test("adds trailing commas when requested", () => { - const before = `[${long}, ${long}, ${long}]`; - const after = `[\n ${long},\n ${long},\n ${long},\n]`; - - expect(before).toChangeFormat(after, { trailingComma: "all" }); + return expect(contents).toMatchFormat(); }); test("breaking maintains calls on the end", () => { - expect(`[${long}].freeze`).toChangeFormat(`[\n ${long}\n].freeze`); + return expect(`[${long}].freeze`).toChangeFormat(`[\n ${long}\n].freeze`); }); describe("heredocs", () => { @@ -104,7 +89,7 @@ describe("array", () => { HERE `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("as the last value", () => { @@ -114,7 +99,7 @@ describe("array", () => { HERE `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("with splats in the array", () => { @@ -124,20 +109,7 @@ describe("array", () => { HERE `); - expect(content).toMatchFormat(); - }); - - test("with trailing commas", () => { - const content = ruby(` - [ - ${long}, - <<~HERE, - this is the heredoc - HERE - ] - `); - - expect(content).toMatchFormat({ trailingComma: "all" }); + return expect(content).toMatchFormat(); }); }); @@ -147,7 +119,7 @@ describe("array", () => { [] `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("with leading comments and comments in the body", () => { @@ -159,7 +131,7 @@ describe("array", () => { ] `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("with comments just in the body", () => { @@ -170,7 +142,7 @@ describe("array", () => { ] `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("with comments just outside but attached", () => { @@ -180,7 +152,7 @@ describe("array", () => { ) `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test.each(["%w", "%W", "%i", "%I"])("%s special array literals", (start) => diff --git a/test/js/ruby/nodes/assign.test.js b/test/js/ruby/nodes/assign.test.js new file mode 100644 index 00000000..f8a1254e --- /dev/null +++ b/test/js/ruby/nodes/assign.test.js @@ -0,0 +1,149 @@ +import { long, ruby } from "../../utils.js"; + +describe("assign", () => { + describe("single assignment", () => { + test("basic", () => { + return expect("a = 1").toMatchFormat(); + }); + + test("multiline", () => { + const content = ruby(` + a = + begin + 1 + end + `); + + return expect(content).toMatchFormat(); + }); + + test("other operator", () => { + return expect("a ||= b").toMatchFormat(); + }); + }); + + test("heredoc", () => { + const content = ruby(` + text = <<-TEXT + abcd + TEXT + `); + + return expect(content).toMatchFormat(); + }); + + describe("breaking", () => { + test("inline becomes multi line", () => { + return expect(`${long} = ${long}`).toChangeFormat(`${long} =\n ${long}`); + }); + + test("arrays don't get force indented", () => { + return expect(`a = [${long}, ${long}, ${long}]`).toChangeFormat( + ruby(` + a = [ + ${long}, + ${long}, + ${long} + ] + `) + ); + }); + + test("hashes don't get force indented", () => { + return expect( + `a = { a: ${long}, b: ${long}, c: ${long} }` + ).toChangeFormat( + ruby(` + a = { + a: + ${long}, + b: + ${long}, + c: + ${long} + } + `) + ); + }); + + describe("assignments from quotewords and similar", () => { + const cases = ["w", "W", "i", "I"]; + + test.each(cases)("x = %s[...] is not force-indented", (literal) => { + return expect(`a = %${literal}[${long} ${long}]`).toChangeFormat( + ruby(` + a = %${literal}[ + ${long} + ${long} + ] + `) + ); + }); + }); + + test("chained methods on array literals don't get oddly indented", () => { + return expect(`a = [${long}].freeze`).toChangeFormat( + ruby(` + a = [ + ${long} + ].freeze + `) + ); + }); + + test("chained methods on hash literals don't get oddly indented", () => { + return expect(`a = { a: ${long} }.freeze`).toChangeFormat( + ruby(` + a = { + a: + ${long} + }.freeze + `) + ); + }); + + describe("assignment operators", () => { + // some but not all + const operators = ["||", "&&", "+", "*", "%", "**", "<<"]; + + test.each(operators)("array %s= [...] is not force-indented", (op) => { + return expect(`a ${op}= [${long}, ${long}, ${long}]`).toChangeFormat( + ruby(` + a ${op}= [ + ${long}, + ${long}, + ${long} + ] + `) + ); + }); + + test.each(operators)("hash %s= { ... } is not force-indented", (op) => { + return expect( + `a ${op}= { a: ${long}, b: ${long}, c: ${long} }` + ).toChangeFormat( + ruby(` + a ${op}= { + a: + ${long}, + b: + ${long}, + c: + ${long} + } + `) + ); + }); + }); + }); + + describe("constants", () => { + test("assigning to constant", () => { + return expect(`Pret::TIER = "config"`).toMatchFormat(); + }); + + test("assigning to top level constants", () => { + return expect(`::PRETTIER = "config"`).toMatchFormat(); + }); + }); +}); diff --git a/test/js/ruby/nodes/assign.test.ts b/test/js/ruby/nodes/assign.test.ts deleted file mode 100644 index 9dddd72a..00000000 --- a/test/js/ruby/nodes/assign.test.ts +++ /dev/null @@ -1,98 +0,0 @@ -import { long, ruby } from "../../utils"; - -describe("assign", () => { - describe("single assignment", () => { - test("basic", () => { - expect("a = 1").toMatchFormat(); - }); - - test("multiline", () => { - const content = ruby(` - a = - begin - 1 - end - `); - - expect(content).toMatchFormat(); - }); - - test("other operator", () => { - expect("a ||= b").toMatchFormat(); - }); - }); - - test("heredoc", () => { - const content = ruby(` - text = <<-TEXT - abcd - TEXT - `); - - expect(content).toMatchFormat(); - }); - - describe("breaking", () => { - test("inline becomes multi line", () => { - expect(`${long} = ${long}`).toChangeFormat(`${long} =\n ${long}`); - }); - - test("arrays don't get force indented", () => { - expect(`a = [${long}, ${long}, ${long}]`).toChangeFormat( - ruby(` - a = [ - ${long}, - ${long}, - ${long} - ] - `) - ); - }); - - test("hashes don't get force indented", () => { - expect(`a = { a: ${long}, b: ${long}, c: ${long} }`).toChangeFormat( - ruby(` - a = { - a: - ${long}, - b: - ${long}, - c: - ${long} - } - `) - ); - }); - - test("chained methods on array literals don't get oddly indented", () => { - expect(`a = [${long}].freeze`).toChangeFormat( - ruby(` - a = [ - ${long} - ].freeze - `) - ); - }); - - test("chained methods on hash literals don't get oddly indented", () => { - expect(`a = { a: ${long} }.freeze`).toChangeFormat( - ruby(` - a = { - a: - ${long} - }.freeze - `) - ); - }); - }); - - describe("constants", () => { - test("assigning to constant", () => { - expect("Pret::TIER = 'config'").toMatchFormat(); - }); - - test("assigning to top level constants", () => { - expect("::PRETTIER = 'config'").toMatchFormat(); - }); - }); -}); diff --git a/test/js/ruby/nodes/binary.test.ts b/test/js/ruby/nodes/binary.test.js similarity index 61% rename from test/js/ruby/nodes/binary.test.ts rename to test/js/ruby/nodes/binary.test.js index a04618c4..2ce05d6a 100644 --- a/test/js/ruby/nodes/binary.test.ts +++ b/test/js/ruby/nodes/binary.test.js @@ -1,12 +1,12 @@ -import { long, ruby } from "../../utils"; +import { long, ruby } from "../../utils.js"; describe("binary", () => { test("single line", () => { - expect("foo && bar && baz").toMatchFormat(); + return expect("foo && bar && baz").toMatchFormat(); }); test("multi line", () => { - expect(`${long} && ${long} && ${long}`).toChangeFormat( + return expect(`${long} && ${long} && ${long}`).toChangeFormat( `${long} &&\n ${long} &&\n ${long}` ); }); @@ -19,7 +19,7 @@ describe("binary", () => { ] `); - expect(content).toChangeFormat(expected); + return expect(content).toChangeFormat(expected); }); test("with heredoc and comment", () => { @@ -29,10 +29,10 @@ describe("binary", () => { HERE `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("no spaces for **", () => { - expect("a**b").toMatchFormat(); + return expect("a**b").toMatchFormat(); }); }); diff --git a/test/js/ruby/nodes/blocks.test.ts b/test/js/ruby/nodes/blocks.test.js similarity index 55% rename from test/js/ruby/nodes/blocks.test.ts rename to test/js/ruby/nodes/blocks.test.js index 443464c0..8d4c9d8f 100644 --- a/test/js/ruby/nodes/blocks.test.ts +++ b/test/js/ruby/nodes/blocks.test.js @@ -1,44 +1,44 @@ -import { long, ruby } from "../../utils"; +import { long, ruby } from "../../utils.js"; describe("blocks", () => { test("empty", () => { - expect("loop {}").toMatchFormat(); + return expect("loop {}").toMatchFormat(); }); test("single line non-breaking", () => { - expect("loop { 1 }").toMatchFormat(); + return expect("loop { 1 }").toMatchFormat(); }); test("single line breaking", () => { - expect(`loop { ${long} }`).toChangeFormat(`loop do\n ${long}\nend`); + return expect(`loop { ${long} }`).toChangeFormat(`loop do\n ${long}\nend`); }); test("multi line non-breaking", () => { - expect("loop do\n 1\nend").toChangeFormat("loop { 1 }"); + return expect("loop do\n 1\nend").toChangeFormat("loop { 1 }"); }); test("multi-line breaking", () => { - expect(`loop do\n ${long}\nend`).toMatchFormat(); + return expect(`loop do\n ${long}\nend`).toMatchFormat(); }); test("multi-line with comment", () => { - expect("loop do\n # foobar\nend").toMatchFormat(); + return expect("loop do\n # foobar\nend").toMatchFormat(); }); test("multi-line on command, no body", () => { - expect("command 'foobar' do\nend").toMatchFormat(); + return expect(`command "foobar" do\nend`).toMatchFormat(); }); test("multi-line on command call, no body", () => { - expect("command.call 'foobar' do\nend").toMatchFormat(); + return expect(`command.call "foobar" do\nend`).toMatchFormat(); }); test("multi-line on command, with body", () => { - expect("command 'foobar' do\n foo\nend").toMatchFormat(); + return expect(`command "foobar" do\n foo\nend`).toMatchFormat(); }); test("multi-line on command call, with body", () => { - expect("command.call 'foobar' do\n foo\nend").toMatchFormat(); + return expect(`command.call "foobar" do\n foo\nend`).toMatchFormat(); }); test("blocks nested inside commands use braces", () => { @@ -48,7 +48,7 @@ describe("blocks", () => { }.bar `); - expect(`foo ${long} { ${long} }.bar`).toChangeFormat(expected); + return expect(`foo ${long} { ${long} }.bar`).toChangeFormat(expected); }); test("breaking maintains calls on the end", () => { @@ -59,7 +59,16 @@ describe("blocks", () => { end.to_i `); - expect(content).toMatchFormat(); + const expected = ruby(` + method + .each do |foo| + bar + baz + end + .to_i + `); + + return expect(content).toChangeFormat(expected); }); test("doesn't do weird things with comments", () => { @@ -71,7 +80,7 @@ describe("blocks", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); describe("for loops", () => { @@ -82,7 +91,7 @@ describe("blocks", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("multiple variables", () => { @@ -92,7 +101,7 @@ describe("blocks", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("optional do keyword", () => { @@ -114,70 +123,55 @@ describe("blocks", () => { end `); - expect(content).toChangeFormat(expected); + return expect(content).toChangeFormat(expected); }); }); - // from ruby test/ruby/test_call.rb - test("inline do end", () => { - expect(`assert_nil(("a".sub! "b" do end&.foo {}))`).toChangeFormat( - ruby(` - assert_nil( - ( - 'a'.sub! 'b' do - end&.foo do - end - ) - ) - `) - ); - }); - test("excessed_comma nodes", () => { - expect("proc { |x,| }").toMatchFormat(); + return expect("proc { |x,| }").toMatchFormat(); }); describe("args", () => { test("no body", () => { - expect("loop { |i| }").toMatchFormat(); + return expect("loop { |i| }").toMatchFormat(); }); test("single line non-breaking", () => { - expect("loop { |i| 1 }").toMatchFormat(); + return expect("loop { |i| 1 }").toMatchFormat(); }); test("single line breaking", () => { - expect(`loop { |i| ${long} }`).toChangeFormat( + return expect(`loop { |i| ${long} }`).toChangeFormat( `loop do |i|\n ${long}\nend` ); }); test("multi-line non-breaking", () => { - expect("loop do |i|\n i\nend").toChangeFormat("loop { |i| i }"); + return expect("loop do |i|\n i\nend").toChangeFormat("loop { |i| i }"); }); test("multi-line breaking", () => { - expect(`loop do |i|\n ${long}\nend`).toMatchFormat(); + return expect(`loop do |i|\n ${long}\nend`).toMatchFormat(); }); test("block-local args", () => { - expect("loop { |i; j| 1 }").toMatchFormat(); + return expect("loop { |i; j| 1 }").toMatchFormat(); }); test("splat", () => { - expect("loop { |*| i }").toMatchFormat(); + return expect("loop { |*| i }").toMatchFormat(); }); test("destructure", () => { - expect("loop { |(a, b)| i }").toMatchFormat(); + return expect("loop { |(a, b)| i }").toMatchFormat(); }); test("lots of args types", () => { - expect("loop { |a, (b, c), d, *e| i }").toMatchFormat(); + return expect("loop { |a, (b, c), d, *e| i }").toMatchFormat(); }); test("does not split up args inside pipes", () => { - expect(`loop do |${long} = 1, a${long} = 2|\nend`).toMatchFormat(); + return expect(`loop do |${long} = 1, a${long} = 2|\nend`).toMatchFormat(); }); }); @@ -189,6 +183,17 @@ describe("blocks", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); + }); + + // https://github.com/prettier/plugin-ruby/issues/1042 + test("comments on the do block without a command", () => { + const content = ruby(` + let!(:some_variable) do # comment text + nil + end + `); + + return expect(content).toMatchFormat(); }); }); diff --git a/test/js/ruby/nodes/break.test.ts b/test/js/ruby/nodes/break.test.js similarity index 54% rename from test/js/ruby/nodes/break.test.ts rename to test/js/ruby/nodes/break.test.js index 8a51b2bb..10ba00f9 100644 --- a/test/js/ruby/nodes/break.test.ts +++ b/test/js/ruby/nodes/break.test.js @@ -1,20 +1,20 @@ -import { ruby } from "../../utils"; +import { ruby } from "../../utils.js"; describe("break", () => { test("empty break", () => { - expect("break").toMatchFormat(); + return expect("break").toMatchFormat(); }); test("break with one argument, no parens", () => { - expect("break 1").toMatchFormat(); + return expect("break 1").toMatchFormat(); }); test("break with parens drops parens", () => { - expect("break(1)").toChangeFormat("break 1"); + return expect("break(1)").toChangeFormat("break 1"); }); test("break with multiple arguments", () => { - expect("break 1, 2, 3").toMatchFormat(); + return expect("break 1, 2, 3").toMatchFormat(); }); test("keeps parens for multiple statements", () => { @@ -25,14 +25,14 @@ describe("break", () => { ) `); - expect("break(a = 1; a == 1)").toChangeFormat(expected); + return expect("break(a = 1; a == 1)").toChangeFormat(expected); }); test("keeps parens for _mod nodes", () => { - expect("break(1 if true)").toMatchFormat(); + return expect("break(1 if true)").toMatchFormat(); }); test("works with comments", () => { - expect("break # foo").toMatchFormat(); + return expect("break # foo").toMatchFormat(); }); }); diff --git a/test/js/ruby/nodes/calls.test.ts b/test/js/ruby/nodes/calls.test.js similarity index 73% rename from test/js/ruby/nodes/calls.test.ts rename to test/js/ruby/nodes/calls.test.js index 33c936ca..1b57328e 100644 --- a/test/js/ruby/nodes/calls.test.ts +++ b/test/js/ruby/nodes/calls.test.js @@ -1,14 +1,14 @@ -import { long, ruby } from "../../utils"; +import { long, ruby } from "../../utils.js"; describe("calls", () => { test("simple calls", () => { - const content = "posts.active.where('created_at > ?', 1.year.ago)"; + const content = `posts.active.where("created_at > ?", 1.year.ago)`; - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("short chains", () => { - expect("foo.bar.baz qux").toMatchFormat(); + return expect("foo.bar.baz qux").toMatchFormat(); }); test("chain methods", () => { @@ -27,18 +27,18 @@ describe("calls", () => { .hhhhhhhhhh `); - expect(before).toChangeFormat(after); + return expect(before).toChangeFormat(after); }); test("chains of methods with one with arguments right at the top", () => { const content = ruby(` aaa.bbb.ccc.ddd.eee.merge( - ${long.slice(0, 30)}: 'aaa', - ${long.slice(0, 31)}: 'bbb' + ${long.slice(0, 30)}: "aaa", + ${long.slice(0, 31)}: "bbb" ) `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("chains of methods with a block right at the top", () => { @@ -49,38 +49,39 @@ describe("calls", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("tons of calls that fit on one line", () => { const content = "a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z"; - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("chains which contain a .where.not", () => { const content = ruby(` Customer .active - .where(foo: 'bar') + .where(foo: "bar") .where.not(banned_at: nil) - .order(created_at: 'desc') + .order(created_at: "desc") .limit(10) `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); describe("within sig blocks", () => { test("basic chains", () => { const content = ruby(` sig do - params(contacts: Contact::ActiveRecord_Relation) - .returns(Customer::ActiveRecord_Relation) + params(contacts: Contact::ActiveRecord_Relation).returns( + Customer::ActiveRecord_Relation + ) end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("chains with other methods", () => { @@ -92,7 +93,7 @@ describe("calls", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); }); @@ -109,31 +110,31 @@ describe("calls", () => { .select_all(:table1) `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("no explicit call doesn't add call", () => { - expect("a.(1, 2, 3)").toMatchFormat(); + return expect("a.(1, 2, 3)").toMatchFormat(); }); test("explicit call maintains call", () => { - expect("a.call(1, 2, 3)").toMatchFormat(); + return expect("a.call(1, 2, 3)").toMatchFormat(); }); test("double bang with a special operator on a call", () => { - expect("!!object&.topic_list").toMatchFormat(); + return expect("!!object&.topic_list").toMatchFormat(); }); test("bang with a special operator on a command_call", () => { - expect("!domain&.include? '@'").toMatchFormat(); + return expect(`!domain&.include? "@"`).toMatchFormat(); }); test("#call shorthand does not eliminate empty parentheses", () => { - expect("Foo.new.()").toMatchFormat(); + return expect("Foo.new.()").toMatchFormat(); }); test("methods that look like constants do not eliminate empty parens", () => { - expect("Foo()").toMatchFormat(); + return expect("Foo()").toMatchFormat(); }); test("call chains with no indent on the first receiver", () => { @@ -141,15 +142,14 @@ describe("calls", () => { const content = `result = [${item}, ${item}, ${item}].map(&:foo?).bbb.ccc`; const expected = ruby(` - result = - [ - ${item}, - ${item}, - ${item} - ].map(&:foo?).bbb.ccc + result = [ + ${item}, + ${item}, + ${item} + ].map(&:foo?).bbb.ccc `); - expect(content).toChangeFormat(expected); + return expect(content).toChangeFormat(expected); }); test("chained method_add_arg after a block", () => { @@ -158,7 +158,7 @@ describe("calls", () => { end.d e, f `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("comments in a method chain get printed correctly", () => { @@ -194,13 +194,13 @@ describe("calls", () => { # then remove remaining rows with duplicate emails uniq { |contact| contact[:email] } .tap do |res| - CSV.open(OUTPUT_PATH, 'wb') do |csv| + CSV.open(OUTPUT_PATH, "wb") do |csv| csv << HEADERS res.each { |d| csv << d.values } end end `); - expect(content).toChangeFormat(expected); + return expect(content).toChangeFormat(expected); }); }); diff --git a/test/js/ruby/nodes/case.test.ts b/test/js/ruby/nodes/case.test.js similarity index 66% rename from test/js/ruby/nodes/case.test.ts rename to test/js/ruby/nodes/case.test.js index f9d4e71f..f6efaa5d 100644 --- a/test/js/ruby/nodes/case.test.ts +++ b/test/js/ruby/nodes/case.test.js @@ -1,4 +1,4 @@ -import { long, ruby } from "../../utils"; +import { long, ruby } from "../../utils.js"; describe("case", () => { test("empty case", () => { @@ -9,7 +9,7 @@ describe("case", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("single when", () => { @@ -20,7 +20,7 @@ describe("case", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("multiple predicates, one when", () => { @@ -31,39 +31,39 @@ describe("case", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("breaking with multiple predicates, one when", () => { const content = ruby(` case foo - when '${long}', - 'a${long}', - 'b${long}' + when "${long}", + "a${long}", + "b${long}" bar end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("breaking with multiple predicates, each one not too long", () => { const content = ruby(` case foo - when '${long.slice(0, 40)}', '${long.slice(0, 40)}' + when "${long.slice(0, 40)}", "${long.slice(0, 40)}" bar end `); const expected = ruby(` case foo - when '${long.slice(0, 40)}', - '${long.slice(0, 40)}' + when "${long.slice(0, 40)}", + "${long.slice(0, 40)}" bar end `); - expect(content).toChangeFormat(expected); + return expect(content).toChangeFormat(expected); }); test("multiple consecutive whens", () => { @@ -75,7 +75,7 @@ describe("case", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("basic multiple branches", () => { @@ -88,7 +88,7 @@ describe("case", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("else clauses", () => { @@ -101,6 +101,6 @@ describe("case", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); }); diff --git a/test/js/ruby/nodes/class.test.ts b/test/js/ruby/nodes/class.test.js similarity index 72% rename from test/js/ruby/nodes/class.test.ts rename to test/js/ruby/nodes/class.test.js index a69c4d6e..ba917ba9 100644 --- a/test/js/ruby/nodes/class.test.ts +++ b/test/js/ruby/nodes/class.test.js @@ -1,4 +1,4 @@ -import { long, ruby } from "../../utils"; +import { long, ruby } from "../../utils.js"; describe("class", () => { test("basic nesting", () => { @@ -14,7 +14,7 @@ describe("class", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("inheritance", () => { @@ -25,25 +25,28 @@ describe("class", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("breaking class name", () => { - expect(`class P${long}; end`).toChangeFormat(`class P${long}\nend`); + return expect(`class P${long}; end`).toChangeFormat(`class P${long}\nend`); }); test("breaking module name", () => { - expect(`module P${long}; end`).toChangeFormat(`module P${long}\nend`); + return expect(`module P${long}; end`).toChangeFormat( + `module P${long}\nend` + ); }); test("class push blocks", () => { const content = ruby(` class << Prettier - def foo; end + def foo + end end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("multiple access controls", () => { @@ -69,7 +72,7 @@ describe("class", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("method helper", () => { @@ -81,7 +84,7 @@ describe("class", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); describe.each(["public", "protected", "private"])( @@ -98,7 +101,7 @@ describe("class", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("inline", () => { @@ -110,18 +113,18 @@ describe("class", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); } ); describe("constant reference", () => { test("regular", () => { - expect("Pret::Tier::Ruby").toMatchFormat(); + return expect("Pret::Tier::Ruby").toMatchFormat(); }); test("top-level", () => { - expect("::Pret::Tier::Ruby").toMatchFormat(); + return expect("::Pret::Tier::Ruby").toMatchFormat(); }); }); }); diff --git a/test/js/ruby/nodes/conditionals.test.ts b/test/js/ruby/nodes/conditionals.test.js similarity index 63% rename from test/js/ruby/nodes/conditionals.test.ts rename to test/js/ruby/nodes/conditionals.test.js index cbd3c15b..dc8db071 100644 --- a/test/js/ruby/nodes/conditionals.test.ts +++ b/test/js/ruby/nodes/conditionals.test.js @@ -1,14 +1,14 @@ -import { long, ruby, atLeastVersion } from "../../utils"; +import { long, ruby, atLeastVersion } from "../../utils.js"; describe("conditionals", () => { describe("not operator", () => { // from ruby test/ruby/test_not.rb test("not operator, empty parens", () => { - expect("assert_equal(true, (not ()))").toMatchFormat(); + return expect("assert_equal(true, (not ()))").toMatchFormat(); }); test("not operator from within a ternary adds parens", () => { - expect("a ? not(b) : c").toMatchFormat(); + return expect("a ? not(b) : c").toMatchFormat(); }); test("not operator from within an if/else adds parens", () => { @@ -20,43 +20,43 @@ describe("conditionals", () => { end `); - expect(content).toChangeFormat("a ? not(b) : c"); + return expect(content).toChangeFormat("a ? not(b) : c"); }); }); describe("modifiers", () => { describe.each(["if", "unless"])("%s keyword", (keyword) => { test("when modifying an assignment expression", () => { - const content = `text = '${long}' ${keyword} text`; + const content = `text = "${long}" ${keyword} text`; const expected = ruby(` text = - '${long}' ${keyword} text + "${long}" ${keyword} text `); - expect(content).toChangeFormat(expected); + return expect(content).toChangeFormat(expected); }); test("when modifying an abbreviated assignment expression", () => { - const content = `text ||= '${long}' ${keyword} text`; + const content = `text ||= "${long}" ${keyword} text`; const expected = ruby(` text ||= - '${long}' ${keyword} text + "${long}" ${keyword} text `); - expect(content).toChangeFormat(expected); + return expect(content).toChangeFormat(expected); }); test("when modifying an expression with an assignment descendant", () => { - const content = `true && (text = '${long}') ${keyword} text`; + const content = `true && (text = "${long}") ${keyword} text`; const expected = ruby(` true && ( text = - '${long}' + "${long}" ) ${keyword} text `); - expect(content).toChangeFormat(expected); + return expect(content).toChangeFormat(expected); }); }); @@ -72,7 +72,7 @@ describe("conditionals", () => { end `); - expect(content).toChangeFormat(expected); + return expect(content).toChangeFormat(expected); }); test("does not insert double modifiers on a single line for nested conditionals", () => { @@ -89,32 +89,34 @@ describe("conditionals", () => { end `); - expect(content).toChangeFormat(expected); + return expect(content).toChangeFormat(expected); }); }); describe("when inline allowed", () => { describe.each(["if", "unless"])("%s keyword", (keyword) => { test("inline stays", () => { - expect(`1 ${keyword} a`).toMatchFormat(); + return expect(`1 ${keyword} a`).toMatchFormat(); }); test("multi line changes", () => { - expect(`${keyword} a\n 1\nend`).toChangeFormat(`1 ${keyword} a`); + return expect(`${keyword} a\n 1\nend`).toChangeFormat( + `1 ${keyword} a` + ); }); test("inline breaking changes", () => { - expect(`${long} ${keyword} ${long}`).toChangeFormat( + return expect(`${long} ${keyword} ${long}`).toChangeFormat( `${keyword} ${long}\n ${long}\nend` ); }); test("multi line breaking stays", () => { - expect(`${keyword} ${long}\n ${long}\nend`).toMatchFormat(); + return expect(`${keyword} ${long}\n ${long}\nend`).toMatchFormat(); }); test("not operator", () => { - expect(`b ${keyword} not a`).toMatchFormat(); + return expect(`b ${keyword} not a`).toMatchFormat(); }); test("empty first body", () => { @@ -123,19 +125,18 @@ describe("conditionals", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("empty first body with present second body", () => { const content = ruby(` ${keyword} a - else b end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("comment in body", () => { @@ -145,7 +146,7 @@ describe("conditionals", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("comment in body with question mark method", () => { @@ -155,7 +156,7 @@ describe("conditionals", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("comment on node in body", () => { @@ -165,7 +166,7 @@ describe("conditionals", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("breaks if the predicate is an assignment", () => { @@ -177,7 +178,7 @@ describe("conditionals", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("breaks if the predicate is an op assignment", () => { @@ -189,11 +190,11 @@ describe("conditionals", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("align long predicates", () => { - expect(`foo ${keyword} ${long} || ${long}a`).toChangeFormat( + return expect(`foo ${keyword} ${long} || ${long}a`).toChangeFormat( ruby(` ${keyword} ${long} || ${Array(keyword.length).fill("").join(" ")}${long}a @@ -204,9 +205,9 @@ describe("conditionals", () => { }); test("wraps single lines in parens when assigning", () => { - expect(`hash[:key] = ${keyword} false then :value end`).toChangeFormat( - `hash[:key] = (:value ${keyword} false)` - ); + return expect( + `hash[:key] = ${keyword} false then :value end` + ).toChangeFormat(`hash[:key] = (:value ${keyword} false)`); }); test("wraps inline version with calls", () => { @@ -216,7 +217,7 @@ describe("conditionals", () => { end.to_s `); - expect(content).toChangeFormat("(false if true).to_s"); + return expect(content).toChangeFormat("(false if true).to_s"); }); test("wraps inline version within binary", () => { @@ -226,125 +227,18 @@ describe("conditionals", () => { end || baz `); - expect(content).toChangeFormat("(bar if foo) || baz"); - }); - }); - }); - - describe("when inline not allowed", () => { - describe.each(["if", "unless"])("%s keyword", (keyword) => { - test("inline changes", () => { - expect(`1 ${keyword} a`).toChangeFormat(`${keyword} a\n 1\nend`, { - rubyModifier: false - }); - }); - - test("multi line stays", () => { - expect(`${keyword} a\n 1\nend`).toMatchFormat({ - rubyModifier: false - }); - }); - - test("inline breaking changes", () => { - expect(`${long} ${keyword} ${long}`).toChangeFormat( - `${keyword} ${long}\n ${long}\nend`, - { - rubyModifier: false - } - ); - }); - - test("multi line breaking stays", () => { - expect(`${keyword} ${long}\n ${long}\nend`).toMatchFormat({ - rubyModifier: false - }); - }); - - test("not operator", () => { - expect(`${keyword} not a\n b\nend`).toMatchFormat({ - rubyModifier: false - }); - }); - - test("not operator parens", () => { - expect("not(true)").toMatchFormat(); - }); - - test("empty first body", () => { - const content = ruby(` - ${keyword} a - end - `); - - expect(content).toMatchFormat({ rubyModifier: false }); - }); - - test("empty first body with present second body", () => { - const content = ruby(` - ${keyword} a - - else - b - end - `); - - expect(content).toMatchFormat({ rubyModifier: false }); - }); - - test("comment in body", () => { - const content = ruby(` - ${keyword} a - # comment - end - `); - - expect(content).toMatchFormat({ rubyModifier: false }); - }); - - test("comment on node in body", () => { - const content = ruby(` - ${keyword} a - break # comment - end - `); - - expect(content).toMatchFormat({ rubyModifier: false }); - }); - - test("align long predicates", () => { - expect(`foo ${keyword} ${long} || ${long}a`).toChangeFormat( - ruby(` - ${keyword} ${long} || - ${Array(keyword.length).fill("").join(" ")}${long}a - foo - end - `) - ); - }); - - test("single line should break up", () => { - const content = "foo = if bar? then baz end"; - const expected = ruby(` - foo = - if bar? - baz - end - `); - - expect(content).toChangeFormat(expected, { - rubyModifier: false - }); + return expect(content).toChangeFormat("(bar if foo) || baz"); }); }); }); describe("ternaries", () => { test("non-breaking", () => { - expect("a ? 1 : 2").toMatchFormat(); + return expect("a ? 1 : 2").toMatchFormat(); }); test("breaking", () => { - expect(`a ? ${long} : ${long}`).toChangeFormat( + return expect(`a ? ${long} : ${long}`).toChangeFormat( ruby(` if a ${long} @@ -364,7 +258,7 @@ describe("conditionals", () => { end `); - expect(content).toChangeFormat("a ? 1 : 2"); + return expect(content).toChangeFormat("a ? 1 : 2"); }); test("transform for unless/else", () => { @@ -376,7 +270,7 @@ describe("conditionals", () => { end `); - expect(content).toChangeFormat("a ? 2 : 1"); + return expect(content).toChangeFormat("a ? 2 : 1"); }); test("adds parens if inside of a call", () => { @@ -388,7 +282,7 @@ describe("conditionals", () => { end.to_s `); - expect(content).toChangeFormat("(a ? 1 : 2).to_s"); + return expect(content).toChangeFormat("(a ? 1 : 2).to_s"); }); test("does not add parens if it breaks", () => { @@ -400,7 +294,7 @@ describe("conditionals", () => { end.to_s `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("adds parens if inside of a binary", () => { @@ -412,7 +306,7 @@ describe("conditionals", () => { end + 1 `); - expect(content).toChangeFormat("(a ? 1 : 2) + 1"); + return expect(content).toChangeFormat("(a ? 1 : 2) + 1"); }); test("adds parens if within a command", () => { @@ -427,11 +321,11 @@ describe("conditionals", () => { ) `); - expect(content).toChangeFormat(expected); + return expect(content).toChangeFormat(expected); }); test("does not add parens if within a command_call non-breaking", () => { - expect("foo.bar baz ? foo : bar").toMatchFormat(); + return expect("foo.bar baz ? foo : bar").toMatchFormat(); }); test("adds parens if within a command_call", () => { @@ -446,7 +340,7 @@ describe("conditionals", () => { ) `); - expect(content).toChangeFormat(expected); + return expect(content).toChangeFormat(expected); }); describe("unable to transform", () => { @@ -459,7 +353,7 @@ describe("conditionals", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("command in if body", () => { @@ -471,7 +365,7 @@ describe("conditionals", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("command in else body", () => { @@ -483,7 +377,7 @@ describe("conditionals", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("command call in if body", () => { @@ -495,7 +389,7 @@ describe("conditionals", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("command call in else body", () => { @@ -507,7 +401,7 @@ describe("conditionals", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("heredoc in if body", () => { @@ -522,7 +416,7 @@ describe("conditionals", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("heredoc in else body", () => { @@ -537,7 +431,7 @@ describe("conditionals", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("nested conditional in if body", () => { @@ -561,7 +455,7 @@ describe("conditionals", () => { end `); - expect(content).toChangeFormat(expected); + return expect(content).toChangeFormat(expected); }); test("nested conditional in else body", () => { @@ -584,7 +478,7 @@ describe("conditionals", () => { end `); - expect(content).toChangeFormat(expected); + return expect(content).toChangeFormat(expected); }); test("nested ternary in if body", () => { @@ -594,7 +488,7 @@ describe("conditionals", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("nested ternary in else body", () => { @@ -606,7 +500,7 @@ describe("conditionals", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("command with argument predicate", () => { @@ -618,7 +512,7 @@ describe("conditionals", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("command call with argument predicate", () => { @@ -630,11 +524,11 @@ describe("conditionals", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("align long predicates", () => { - expect(`${long} || ${long}a ? foo : bar`).toChangeFormat( + return expect(`${long} || ${long}a ? foo : bar`).toChangeFormat( ruby(` if ${long} || ${long}a @@ -649,13 +543,13 @@ describe("conditionals", () => { test("lower precendence operators", () => { const content = ruby(` if x.nil? - puts 'nil' and return + puts "nil" and return else x end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("assign nodes in predicate", () => { @@ -667,7 +561,7 @@ describe("conditionals", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("opassign nodes in predicate", () => { @@ -679,7 +573,7 @@ describe("conditionals", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("cannot transform with multiple statements", () => { @@ -692,7 +586,7 @@ describe("conditionals", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); }); }); @@ -707,7 +601,7 @@ describe("conditionals", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("multiple clauses", () => { @@ -723,37 +617,37 @@ describe("conditionals", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); }); describe.each(["if", "unless"])("add parens when necessary %s", (keyword) => { test("args", () => { - expect(`[${keyword} foo? then bar end]`).toChangeFormat( + return expect(`[${keyword} foo? then bar end]`).toChangeFormat( `[(bar ${keyword} foo?)]` ); }); test("assign", () => { - expect(`foo = ${keyword} bar? then baz end`).toChangeFormat( + return expect(`foo = ${keyword} bar? then baz end`).toChangeFormat( `foo = (baz ${keyword} bar?)` ); }); - test("assoc_new", () => { - expect(`{ foo: ${keyword} bar? then baz end }`).toChangeFormat( + test("assoc", () => { + return expect(`{ foo: ${keyword} bar? then baz end }`).toChangeFormat( `{ foo: (baz ${keyword} bar?) }` ); }); test("massign", () => { - expect(`f, o, o = ${keyword} bar? then baz end`).toChangeFormat( + return expect(`f, o, o = ${keyword} bar? then baz end`).toChangeFormat( `f, o, o = (baz ${keyword} bar?)` ); }); test("opassign", () => { - expect(`foo ||= ${keyword} bar? then baz end`).toChangeFormat( + return expect(`foo ||= ${keyword} bar? then baz end`).toChangeFormat( `foo ||= (baz ${keyword} bar?)` ); }); @@ -762,11 +656,11 @@ describe("conditionals", () => { if (atLeastVersion("3.0")) { test.each(["if", "unless"])("%s with pattern matching", (keyword) => { const content = ruby(` - user = { role: 'admin', login: 'matz' } - puts "admin: #{name}" ${keyword} user in { role: 'admin', name: } + user = { role: "admin", login: "matz" } + puts "admin: #{name}" ${keyword} user in { role: "admin", name: } `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); } }); diff --git a/test/js/ruby/nodes/defined.test.js b/test/js/ruby/nodes/defined.test.js new file mode 100644 index 00000000..3faf4b8b --- /dev/null +++ b/test/js/ruby/nodes/defined.test.js @@ -0,0 +1,29 @@ +import { long } from "../../utils.js"; + +describe("defined", () => { + test("no parens", () => { + return expect("defined? a").toChangeFormat("defined?(a)"); + }); + + test("parens", () => { + return expect("defined?(a)").toMatchFormat(); + }); + + test("breaks on long identifier, no parens", () => { + return expect(`defined? ${long}`).toChangeFormat(`defined?(\n ${long}\n)`); + }); + + test("breaks on long identifier, with parens", () => { + return expect(`defined?(${long})`).toChangeFormat( + `defined?(\n ${long}\n)` + ); + }); + + test("breaking keeps breaking", () => { + return expect(`defined?(\n ${long}\n)`).toMatchFormat(); + }); + + test("unnecessary breaking reverts to inline", () => { + return expect("defined?(\n a\n)").toChangeFormat("defined?(a)"); + }); +}); diff --git a/test/js/ruby/nodes/defined.test.ts b/test/js/ruby/nodes/defined.test.ts deleted file mode 100644 index 3e23e252..00000000 --- a/test/js/ruby/nodes/defined.test.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { long } from "../../utils"; - -describe("defined", () => { - test("no parens", () => { - expect("defined? a").toChangeFormat("defined?(a)"); - }); - - test("parens", () => { - expect("defined?(a)").toMatchFormat(); - }); - - test("breaks on long identifier, no parens", () => { - expect(`defined? ${long}`).toChangeFormat(`defined?(\n ${long}\n)`); - }); - - test("breaks on long identifier, with parens", () => { - expect(`defined?(${long})`).toChangeFormat(`defined?(\n ${long}\n)`); - }); - - test("breaking keeps breaking", () => { - expect(`defined?(\n ${long}\n)`).toMatchFormat(); - }); - - test("unnecessary breaking reverts to inline", () => { - expect("defined?(\n a\n)").toChangeFormat("defined?(a)"); - }); -}); diff --git a/test/js/ruby/nodes/embdoc.test.ts b/test/js/ruby/nodes/embdoc.test.js similarity index 77% rename from test/js/ruby/nodes/embdoc.test.ts rename to test/js/ruby/nodes/embdoc.test.js index 592c1a70..9d3e1d2a 100644 --- a/test/js/ruby/nodes/embdoc.test.ts +++ b/test/js/ruby/nodes/embdoc.test.js @@ -1,4 +1,4 @@ -import { ruby } from "../../utils"; +import { ruby } from "../../utils.js"; describe("embdoc", () => { test("basic embdocs", () => { @@ -14,7 +14,7 @@ describe("embdoc", () => { =end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("within a class", () => { @@ -26,7 +26,7 @@ describe("embdoc", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("within a nested class", () => { @@ -40,6 +40,6 @@ describe("embdoc", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); }); diff --git a/test/js/ruby/nodes/field.test.js b/test/js/ruby/nodes/field.test.js new file mode 100644 index 00000000..2492c093 --- /dev/null +++ b/test/js/ruby/nodes/field.test.js @@ -0,0 +1,13 @@ +describe("field", () => { + test("basic", () => { + return expect("foo.x = 1").toMatchFormat(); + }); + + test("replaces :: with .", () => { + return expect("foo::x = 1").toChangeFormat("foo.x = 1"); + }); + + test("with lonely operator", () => { + return expect("foo&.x = 1").toMatchFormat(); + }); +}); diff --git a/test/js/ruby/nodes/field.test.ts b/test/js/ruby/nodes/field.test.ts deleted file mode 100644 index daabe636..00000000 --- a/test/js/ruby/nodes/field.test.ts +++ /dev/null @@ -1,13 +0,0 @@ -describe("field", () => { - test("basic", () => { - expect("foo.x = 1").toMatchFormat(); - }); - - test("replaces :: with .", () => { - expect("foo::x = 1").toChangeFormat("foo.x = 1"); - }); - - test("with lonely operator", () => { - expect("foo&.x = 1").toMatchFormat(); - }); -}); diff --git a/test/js/ruby/nodes/hashes.test.js b/test/js/ruby/nodes/hashes.test.js new file mode 100644 index 00000000..a9ecdc85 --- /dev/null +++ b/test/js/ruby/nodes/hashes.test.js @@ -0,0 +1,257 @@ +import { long, ruby } from "../../utils.js"; + +describe("hash", () => { + test("empty", () => { + return expect("{}").toMatchFormat(); + }); + + test("empty with comments", () => { + const content = ruby(` + { + # foo + # bar + } + `); + + return expect(content).toMatchFormat(); + }); + + test("breaking", () => { + const content = ruby(` + { + ${long}: + ${long}, + ${long}: { + ${long}: + ${long} + } + } + `); + + return expect(content).toMatchFormat(); + }); + + test("breaking maintains calls on the end", () => { + return expect(`{ a: ${long} }.freeze`).toChangeFormat( + `{\n a:\n ${long}\n}.freeze` + ); + }); + + describe("heredocs as values", () => { + test("as the first value", () => { + const content = ruby(` + { foo: <<~HERE, bar: "bar" } + this is the heredoc + HERE + `); + + return expect(content).toMatchFormat(); + }); + + test("as the last value", () => { + const content = ruby(` + { foo: "foo", bar: <<~HERE } + this is the heredoc + HERE + `); + + return expect(content).toMatchFormat(); + }); + + test("when exceeding line length", () => { + const content = ruby(` + { foo: "${long}", bar: <<~HERE } + this is the heredoc + HERE + `); + + const expected = ruby(` + { + foo: + "${long}", + bar: <<~HERE + this is the heredoc + HERE + } + `); + + return expect(content).toChangeFormat(expected); + }); + }); + + describe("dynamic string keys", () => { + test("basic", () => { + return expect(`{ "foo": "bar" }`).toChangeFormat(`{ foo: "bar" }`); + }); + + test("with interpolation", () => { + return expect(`{ "#{1 + 1}": 2 }`).toMatchFormat(); + }); + }); + + describe("bare assoc hash", () => { + test("commands", () => { + return expect("foobar alpha: alpha, beta: beta").toMatchFormat(); + }); + + test("command calls", () => { + return expect("foo.bar alpha: alpha, beta: beta").toMatchFormat(); + }); + + test("calls", () => { + return expect("foobar(alpha: alpha, beta: beta)").toMatchFormat(); + }); + + test("breaks contents and parens together", () => { + const content = ruby(` + foobar(key1: ${long.slice(0, 32)}, key2: ${long.slice(0, 32)}) + `); + + const expected = ruby(` + foobar( + key1: ${long.slice(0, 32)}, + key2: ${long.slice(0, 32)} + ) + `); + + return expect(content).toChangeFormat(expected); + }); + }); + + describe("when hash labels allowed", () => { + test("hash labels stay", () => { + return expect(`{ a: "a", b: "b", c: "c" }`).toMatchFormat(); + }); + + test("hash rockets get replaced", () => { + return expect(`{ :a => "a", :b => "b", :c => "c" }`).toChangeFormat( + `{ a: "a", b: "b", c: "c" }` + ); + }); + + test("hash rockets stay when needed", () => { + return expect("{ Foo => 1, Bar => 2 }").toMatchFormat(); + }); + + test("ending in equals stays", () => { + return expect(`{ :foo= => "bar" }`).toMatchFormat(); + }); + + test("starting with non-letter/non-underscore stays", () => { + return expect(`{ :@foo => "bar" }`).toMatchFormat(); + }); + + test("starting with underscore converts", () => { + return expect(`{ :_foo => "bar" }`).toChangeFormat(`{ _foo: "bar" }`); + }); + }); + + test("prints hashes with consistent keys", () => { + return expect(`{ a: "a", b => "b" }`).toChangeFormat( + `{ :a => "a", b => "b" }` + ); + }); + + test("print hashes with correct braces when contents fits", () => { + const content = ruby(` + { + key1: ${long.slice(0, 32)}, + key2: ${long.slice(0, 32)} + } + `); + + return expect(content).toMatchFormat(); + }); + + test("with leading comments but none in body", () => { + const content = ruby(` + # leading + {} + `); + + return expect(content).toMatchFormat(); + }); + + test("with leading comments and comments in the body", () => { + const content = ruby(` + # leading + { + # inside + # body + } + `); + + return expect(content).toMatchFormat(); + }); + + test("with comments just in the body", () => { + const content = ruby(` + { + # inside + # body + } + `); + + return expect(content).toMatchFormat(); + }); + + // https://github.com/prettier/plugin-ruby/issues/758 + test("splits if the key has a comment attached", () => { + const content = ruby(` + items = { + :"foo-bar"=> # Inline comment + baz, + } + `); + + const expected = ruby(` + items = { + "foo-bar": # Inline comment + baz + } + `); + + return expect(content).toChangeFormat(expected); + }); + + test("child hashes break assoc_news if their parents break", () => { + const content = ruby(` + { + ${long}: { foo: bar } + } + `); + + const expected = ruby(` + { + ${long}: { + foo: bar + } + } + `); + + return expect(content).toChangeFormat(expected); + }); + + test("child hashes break hashes if their parents break", () => { + const key = long.slice(0, 40); + const content = ruby(` + { + ${key}: foo, + ${key}: foo, + ${key}: { foo: bar } + } + `); + + const expected = ruby(` + { + ${key}: foo, + ${key}: foo, + ${key}: { + foo: bar + } + } + `); + + return expect(content).toChangeFormat(expected); + }); +}); diff --git a/test/js/ruby/nodes/hashes.test.ts b/test/js/ruby/nodes/hashes.test.ts deleted file mode 100644 index d32ab7ae..00000000 --- a/test/js/ruby/nodes/hashes.test.ts +++ /dev/null @@ -1,364 +0,0 @@ -import { long, ruby } from "../../utils"; - -describe("hash", () => { - test("empty", () => { - expect("{}").toMatchFormat(); - }); - - test("empty with comments", () => { - const content = ruby(` - { - # foo - # bar - } - `); - - expect(content).toMatchFormat(); - }); - - test("breaking", () => { - const content = ruby(` - { - ${long}: - ${long}, - ${long}: { - ${long}: - ${long} - } - } - `); - - expect(content).toMatchFormat(); - }); - - test("breaking maintains calls on the end", () => { - expect(`{ a: ${long} }.freeze`).toChangeFormat( - `{\n a:\n ${long}\n}.freeze` - ); - }); - - test("breaking with trailing commas", () => { - const expected = `{\n ${long}:\n ${long},\n}`; - - expect(`{ ${long}: ${long} }`).toChangeFormat(expected, { - trailingComma: "all" - }); - }); - - describe("heredocs as values", () => { - test("as the first value", () => { - const content = ruby(` - { foo: <<~HERE, bar: 'bar' } - this is the heredoc - HERE - `); - - expect(content).toMatchFormat(); - }); - - test("as the last value", () => { - const content = ruby(` - { foo: 'foo', bar: <<~HERE } - this is the heredoc - HERE - `); - - expect(content).toMatchFormat(); - }); - - test("with trailing commas", () => { - const content = ruby(` - { - foo: - ${long}, - bar: <<~HERE, - this is the heredoc - HERE - } - `); - - expect(content).toMatchFormat({ trailingComma: "all" }); - }); - - test("when exceeding line length", () => { - const content = ruby(` - { foo: '${long}', bar: <<~HERE } - this is the heredoc - HERE - `); - - const expected = ruby(` - { - foo: - '${long}', - bar: <<~HERE - this is the heredoc - HERE - } - `); - - expect(content).toChangeFormat(expected); - }); - }); - - describe("dynamic string keys", () => { - test("basic", () => { - expect(`{ 'foo': 'bar' }`).toMatchFormat(); - }); - - test("with interpolation", () => { - expect(`{ "#{1 + 1}": 2 }`).toMatchFormat(); - }); - - test("basic without hash labels", () => { - expect(`{ :'foo' => 'bar' }`).toMatchFormat({ rubyHashLabel: false }); - }); - - test("with interpolation without hash labels", () => { - expect(`{ :"#{1 + 1}" => 2 }`).toMatchFormat({ rubyHashLabel: false }); - }); - }); - - describe("bare assoc hash", () => { - test("commands", () => { - expect("foobar alpha: alpha, beta: beta").toMatchFormat(); - }); - - test("command calls", () => { - expect("foo.bar alpha: alpha, beta: beta").toMatchFormat(); - }); - - test("calls", () => { - expect("foobar(alpha: alpha, beta: beta)").toMatchFormat(); - }); - - test("does not add trailing commas on breaking commands", () => { - expect(`foobar ${long}: ${long}, a${long}: a${long}`).toChangeFormat( - ruby(` - foobar ${long}: - ${long}, - a${long}: - a${long} - `), - { trailingComma: "all" } - ); - }); - - test("does not add trailing commas on breaking command calls", () => { - expect(`foo.bar ${long}: ${long}, a${long}: a${long}`).toChangeFormat( - ruby(` - foo.bar ${long}: - ${long}, - a${long}: - a${long} - `), - { trailingComma: "all" } - ); - }); - - test("does add trailing commas on breaking calls", () => { - expect(`foobar(${long}: ${long}, a${long}: a${long})`).toChangeFormat( - ruby(` - foobar( - ${long}: - ${long}, - a${long}: - a${long}, - ) - `), - { trailingComma: "all" } - ); - }); - - test("breaks contents and parens together", () => { - const content = ruby(` - foobar(key1: ${long.slice(0, 32)}, key2: ${long.slice(0, 32)}) - `); - - const expected = ruby(` - foobar( - key1: ${long.slice(0, 32)}, - key2: ${long.slice(0, 32)} - ) - `); - - expect(content).toChangeFormat(expected); - }); - }); - - describe("when hash labels allowed", () => { - test("hash labels stay", () => { - expect("{ a: 'a', b: 'b', c: 'c' }").toMatchFormat(); - }); - - test("hash rockets get replaced", () => { - expect("{ :a => 'a', :b => 'b', :c => 'c' }").toChangeFormat( - "{ a: 'a', b: 'b', c: 'c' }" - ); - }); - - test("hash rockets stay when needed", () => { - expect("{ Foo => 1, Bar => 2 }").toMatchFormat(); - }); - - test("ending in equals stays", () => { - expect("{ :foo= => 'bar' }").toMatchFormat(); - }); - - test("starting with non-letter/non-underscore stays", () => { - expect("{ :@foo => 'bar' }").toMatchFormat(); - }); - - test("starting with underscore converts", () => { - expect("{ :_foo => 'bar' }").toChangeFormat("{ _foo: 'bar' }"); - }); - }); - - describe("when hash labels disallowed", () => { - test("hash labels get replaced", () => { - expect("{ a: 'a', b: 'b', c: 'c' }").toChangeFormat( - "{ :a => 'a', :b => 'b', :c => 'c' }", - { - rubyHashLabel: false - } - ); - }); - - test("hash rockets stay", () => { - expect("{ :a => 'a', :b => 'b', :c => 'c' }").toMatchFormat({ - rubyHashLabel: false - }); - }); - - test("hash rockets stay when needed", () => { - expect("{ Foo => 1, Bar => 2 }").toMatchFormat({ - rubyHashLabel: false - }); - }); - - test("ending in equals stays", () => { - expect("{ :foo= => 'bar' }").toMatchFormat({ - rubyHashLabel: false - }); - }); - - test("starting with non-letter/non-underscore stays", () => { - expect("{ :@foo => 'bar' }").toMatchFormat({ - rubyHashLabel: false - }); - }); - - test("starting with underscore stays", () => { - expect("{ :_foo => 'bar' }").toMatchFormat({ - rubyHashLabel: false - }); - }); - }); - - test("prints hashes with consistent keys", () => { - expect("{ a: 'a', b => 'b' }").toChangeFormat("{ :a => 'a', b => 'b' }"); - }); - - test("print hashes with correct braces when contents fits", () => { - const content = ruby(` - { - key1: ${long.slice(0, 32)}, - key2: ${long.slice(0, 32)} - } - `); - - expect(content).toMatchFormat(); - }); - - test("with leading comments but none in body", () => { - const content = ruby(` - # leading - {} - `); - - expect(content).toMatchFormat(); - }); - - test("with leading comments and comments in the body", () => { - const content = ruby(` - # leading - { - # inside - # body - } - `); - - expect(content).toMatchFormat(); - }); - - test("with comments just in the body", () => { - const content = ruby(` - { - # inside - # body - } - `); - - expect(content).toMatchFormat(); - }); - - // https://github.com/prettier/plugin-ruby/issues/758 - test("splits if the key has a comment attached", () => { - const content = ruby(` - items = { - :'foo-bar'=> # Inline comment - baz, - } - `); - - const expected = ruby(` - items = { - 'foo-bar': # Inline comment - baz - } - `); - - expect(content).toChangeFormat(expected); - }); - - test("child hashes break assoc_news if their parents break", () => { - const content = ruby(` - { - ${long}: { foo: bar } - } - `); - - const expected = ruby(` - { - ${long}: { - foo: bar - } - } - `); - - expect(content).toChangeFormat(expected); - }); - - test("child hashes break hashes if their parents break", () => { - const key = long.slice(0, 40); - const content = ruby(` - { - ${key}: foo, - ${key}: foo, - ${key}: { foo: bar } - } - `); - - const expected = ruby(` - { - ${key}: foo, - ${key}: foo, - ${key}: { - foo: bar - } - } - `); - - expect(content).toChangeFormat(expected); - }); -}); diff --git a/test/js/ruby/nodes/heredocs.test.ts b/test/js/ruby/nodes/heredocs.test.js similarity index 77% rename from test/js/ruby/nodes/heredocs.test.ts rename to test/js/ruby/nodes/heredocs.test.js index 668fb7f1..77e5e8fb 100644 --- a/test/js/ruby/nodes/heredocs.test.ts +++ b/test/js/ruby/nodes/heredocs.test.js @@ -1,4 +1,4 @@ -import { long, ruby } from "../../utils"; +import { long, ruby } from "../../utils.js"; describe("heredocs", () => { describe("straight", () => { @@ -9,7 +9,7 @@ describe("heredocs", () => { HERE `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("with interpolation", () => { @@ -21,7 +21,7 @@ describe("heredocs", () => { HERE `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("on an assignment", () => { @@ -31,7 +31,7 @@ describe("heredocs", () => { HERE `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("nested within another", () => { @@ -44,7 +44,7 @@ describe("heredocs", () => { PARENT `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("with embedded expressions", () => { @@ -58,7 +58,7 @@ describe("heredocs", () => { HERE `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("with a call and indented", () => { @@ -70,7 +70,7 @@ describe("heredocs", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); }); @@ -82,7 +82,7 @@ describe("heredocs", () => { HERE `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("with interpolation", () => { @@ -94,7 +94,7 @@ describe("heredocs", () => { HERE `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("on an assignment", () => { @@ -104,7 +104,7 @@ describe("heredocs", () => { HERE `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("nested within another", () => { @@ -117,7 +117,7 @@ describe("heredocs", () => { PARENT `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("with a call and indented", () => { @@ -129,7 +129,7 @@ describe("heredocs", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); }); @@ -141,7 +141,7 @@ describe("heredocs", () => { HERE `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("on calls with multiple", () => { @@ -153,7 +153,7 @@ describe("heredocs", () => { THERE `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("on commands", () => { @@ -163,7 +163,7 @@ describe("heredocs", () => { HERE `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("on commands with multiple", () => { @@ -175,7 +175,7 @@ describe("heredocs", () => { THERE `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("on command calls", () => { @@ -185,7 +185,7 @@ describe("heredocs", () => { HERE `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("on command calls with multiple", () => { @@ -197,7 +197,7 @@ describe("heredocs", () => { THERE `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); }); @@ -209,7 +209,7 @@ describe("heredocs", () => { TEXT `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("squiggly indent", () => { @@ -219,7 +219,7 @@ describe("heredocs", () => { TEXT `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("straight no indent", () => { @@ -229,7 +229,7 @@ describe("heredocs", () => { TEXT `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); }); @@ -240,11 +240,11 @@ describe("heredocs", () => { foo FOO ${long}: - 'bar' + "bar" ) `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("arg w/ block", () => { @@ -256,12 +256,12 @@ describe("heredocs", () => { `); const expected = ruby(` - puts(<<~TEXT) { 'sample block' } + puts(<<~TEXT) { "sample block" } Hello TEXT `); - expect(content).toChangeFormat(expected); + return expect(content).toChangeFormat(expected); }); test("in an activerecord scope arg w/ chaining", () => { @@ -279,12 +279,12 @@ describe("heredocs", () => { const expected = ruby(` scope :late_for_checkin, - -> { select(<<~EOS.squish).data_push.having('something') } + -> { select(<<~EOS.squish).data_push.having("something") } some complicated query here EOS `); - expect(content).toChangeFormat(expected); + return expect(content).toChangeFormat(expected); }); test("long breakable arg after heredoc literal", () => { @@ -303,17 +303,17 @@ describe("heredocs", () => { ] `); - expect(content).toChangeFormat(expected); + return expect(content).toChangeFormat(expected); }); test("call w/ short breakable arg after heredoc literal", () => { const content = ruby(` - p(<<-BAR, ['value', 'value', 125_484, 0o24024103]) + p(<<-BAR, ["value", "value", 125_484, 0o24024103]) text BAR `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("on calls", () => { @@ -321,17 +321,17 @@ describe("heredocs", () => { call(1, 2, 3, <<-HERE) do foo HERE - puts 'more code' + puts "more code" end `); const expected = ruby(` - call(1, 2, 3, <<-HERE) { puts 'more code' } + call(1, 2, 3, <<-HERE) { puts "more code" } foo HERE `); - expect(content).toChangeFormat(expected); + return expect(content).toChangeFormat(expected); }); test("on calls with trailing arguments", () => { @@ -341,29 +341,29 @@ describe("heredocs", () => { HERE `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("in parens args with trailing args after", () => { const content = ruby(` - Foo.new(<<-ARG1, 'test2') + Foo.new(<<-ARG1, "test2") test1 line 1 test1 line 2 ARG1 `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("in paren args with a call", () => { const content = ruby(` - Foo.new(<<~ARG1.upcase.chomp, 'test2') + Foo.new(<<~ARG1.upcase.chomp, "test2") test1 line 1 test1 line 2 ARG1 `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("on calls with multiple", () => { @@ -375,7 +375,7 @@ describe("heredocs", () => { THERE `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("on commands", () => { @@ -385,7 +385,7 @@ describe("heredocs", () => { HERE `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("on commands with multiple", () => { @@ -397,7 +397,7 @@ describe("heredocs", () => { THERE `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("on command calls with trailing arg", () => { @@ -407,7 +407,7 @@ describe("heredocs", () => { HERE `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("on command calls with multiple", () => { @@ -419,7 +419,7 @@ describe("heredocs", () => { THERE `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("assign with call", () => { @@ -429,7 +429,7 @@ describe("heredocs", () => { TEXT `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("assign with squiggly indent", () => { @@ -440,7 +440,7 @@ describe("heredocs", () => { ).strip `); - expect(content).toChangeFormat( + return expect(content).toChangeFormat( ruby(` foo = (<<~TEXT).strip bar @@ -456,7 +456,7 @@ describe("heredocs", () => { TEXT `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("with a call and indented", () => { @@ -468,7 +468,7 @@ describe("heredocs", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("with a method call", () => { @@ -479,7 +479,7 @@ describe("heredocs", () => { HERE `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("with two calls and indented", () => { @@ -491,7 +491,7 @@ describe("heredocs", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("xstring", () => { @@ -501,7 +501,7 @@ describe("heredocs", () => { SHELL `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("with a comment after the declaration", () => { @@ -511,7 +511,7 @@ describe("heredocs", () => { HERE `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("with a comment after the declaration in a call", () => { @@ -521,7 +521,7 @@ describe("heredocs", () => { HERE `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("spilling out from another node keeps subsequent formatting", () => { @@ -532,6 +532,6 @@ describe("heredocs", () => { qaz `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); }); diff --git a/test/js/ruby/nodes/hooks.test.ts b/test/js/ruby/nodes/hooks.test.js similarity index 53% rename from test/js/ruby/nodes/hooks.test.ts rename to test/js/ruby/nodes/hooks.test.js index 39987281..a5d94a65 100644 --- a/test/js/ruby/nodes/hooks.test.ts +++ b/test/js/ruby/nodes/hooks.test.js @@ -1,30 +1,34 @@ -import { long, ruby } from "../../utils"; +import { long, ruby } from "../../utils.js"; describe.each(["BEGIN", "END"])("%s hook", (hook) => { test("shortens to one line", () => { - expect(`${hook} {\n p 'hook'\n}`).toChangeFormat(`${hook} { p 'hook' }`); + return expect(`${hook} {\n p "hook"\n}`).toChangeFormat( + `${hook} { p "hook" }` + ); }); test("maintains single lines", () => { - expect(`${hook} { p 'hook' }`).toMatchFormat(); + return expect(`${hook} { p "hook" }`).toMatchFormat(); }); test("maintains multi line", () => { - expect(`${hook} {\n ${long}\n}`).toMatchFormat(); + return expect(`${hook} {\n ${long}\n}`).toMatchFormat(); }); test("expands to multi line", () => { - expect(`${hook} { ${long} }`).toChangeFormat(`${hook} {\n ${long}\n}`); + return expect(`${hook} { ${long} }`).toChangeFormat( + `${hook} {\n ${long}\n}` + ); }); test("does not move comments on the declaration", () => { const content = ruby(` ${hook} { # comment - p 'hook' + p "hook" } `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("works for comments in the body", () => { @@ -34,6 +38,6 @@ describe.each(["BEGIN", "END"])("%s hook", (hook) => { } `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); }); diff --git a/test/js/ruby/nodes/kwargs.test.js b/test/js/ruby/nodes/kwargs.test.js new file mode 100644 index 00000000..4aa5d4f5 --- /dev/null +++ b/test/js/ruby/nodes/kwargs.test.js @@ -0,0 +1,13 @@ +describe("kwargs", () => { + test("basic", () => { + return expect("def foo(bar: baz)\nend").toMatchFormat(); + }); + + test("optional", () => { + return expect("def foo(bar:)\nend").toMatchFormat(); + }); + + test("double splat", () => { + return expect("def foo(bar:, **baz)\nend").toMatchFormat(); + }); +}); diff --git a/test/js/ruby/nodes/kwargs.test.ts b/test/js/ruby/nodes/kwargs.test.ts deleted file mode 100644 index 86351a6e..00000000 --- a/test/js/ruby/nodes/kwargs.test.ts +++ /dev/null @@ -1,13 +0,0 @@ -describe("kwargs", () => { - test("basic", () => { - expect("def foo(bar: baz); end").toMatchFormat(); - }); - - test("optional", () => { - expect("def foo(bar:); end").toMatchFormat(); - }); - - test("double splat", () => { - expect("def foo(bar:, **baz); end").toMatchFormat(); - }); -}); diff --git a/test/js/ruby/nodes/lambda.test.ts b/test/js/ruby/nodes/lambda.test.js similarity index 58% rename from test/js/ruby/nodes/lambda.test.ts rename to test/js/ruby/nodes/lambda.test.js index a2222910..a1f9dc3c 100644 --- a/test/js/ruby/nodes/lambda.test.ts +++ b/test/js/ruby/nodes/lambda.test.js @@ -1,70 +1,70 @@ -import { long, ruby } from "../../utils"; +import { long, ruby } from "../../utils.js"; describe("lambda", () => { test("plain stabby lambda literal", () => { - expect("-> { 1 }").toMatchFormat(); + return expect("-> { 1 }").toMatchFormat(); }); test("stabby lambda literal with args", () => { - expect("->(a, b, c) { a + b + c }").toMatchFormat(); + return expect("->(a, b, c) { a + b + c }").toMatchFormat(); }); test("stabby lambda literal with arg, no parens", () => { - expect("-> a { a }").toChangeFormat("->(a) { a }"); + return expect("-> a { a }").toChangeFormat("->(a) { a }"); }); test("stabby lambda with parens, no args", () => { - expect("-> () { 1 }").toChangeFormat("-> { 1 }"); + return expect("-> () { 1 }").toChangeFormat("-> { 1 }"); }); test("breaking stabby lambda literal", () => { - expect(`-> { ${long} }`).toChangeFormat(`-> do\n ${long}\nend`); + return expect(`-> { ${long} }`).toChangeFormat(`-> do\n ${long}\nend`); }); test("breaking stabby lambda literal with args", () => { const content = `->(a) { a + ${long} }`; const expected = `->(a) do\n a +\n ${long}\nend`; - expect(content).toChangeFormat(expected); + return expect(content).toChangeFormat(expected); }); test("stabby lambda literal within a command node", () => { - expect("command :foo, ->(arg) { arg + arg }").toMatchFormat(); + return expect("command :foo, ->(arg) { arg + arg }").toMatchFormat(); }); test("stabby lambda literal that breaks within a command node", () => { - expect(`command :foo, -> { ${long} }`).toChangeFormat( + return expect(`command :foo, -> { ${long} }`).toChangeFormat( ruby(` command :foo, - -> { + -> do ${long} - } + end `) ); }); test("stabby lambda literal with a command call node", () => { - expect("command.call :foo, ->(arg) { arg + arg }").toMatchFormat(); + return expect("command.call :foo, ->(arg) { arg + arg }").toMatchFormat(); }); test("stabby lambda literal that breaks with a command call node", () => { - expect(`command.call :foo, -> { ${long} }`).toChangeFormat( + return expect(`command.call :foo, -> { ${long} }`).toChangeFormat( ruby(` command.call :foo, - -> { + -> do ${long} - } + end `) ); }); test("stabby lambda literal that breaks deeply within a command node", () => { - expect(`command :foo, bar: -> { ${long} }`).toChangeFormat( + return expect(`command :foo, bar: -> { ${long} }`).toChangeFormat( ruby(` command :foo, - bar: -> { + bar: -> do ${long} - } + end `) ); }); @@ -72,25 +72,25 @@ describe("lambda", () => { test("very long arguments list doesn't break within pipes", () => { const content = `command :foo, ->(${long}, a${long}, aa${long}) { true }`; - expect(content).toChangeFormat( + return expect(content).toChangeFormat( ruby(` command :foo, ->( ${long}, a${long}, aa${long} - ) { + ) do true - } + end `) ); }); test("empty brackets", () => { - expect("a[]").toMatchFormat(); + return expect("a[]").toMatchFormat(); }); test("brackets with multiple args", () => { - expect("a[1, 2, 3]").toMatchFormat(); + return expect("a[1, 2, 3]").toMatchFormat(); }); }); diff --git a/test/js/ruby/nodes/loops.test.ts b/test/js/ruby/nodes/loops.test.js similarity index 54% rename from test/js/ruby/nodes/loops.test.ts rename to test/js/ruby/nodes/loops.test.js index 69056d03..fb1bc9bc 100644 --- a/test/js/ruby/nodes/loops.test.ts +++ b/test/js/ruby/nodes/loops.test.js @@ -1,8 +1,8 @@ -import { long, ruby } from "../../utils"; +import { long, ruby } from "../../utils.js"; describe.each(["while", "until"])("%s", (keyword) => { test("aligns predicates", () => { - expect(`foo ${keyword} ${long} || ${long}`).toChangeFormat( + return expect(`foo ${keyword} ${long} || ${long}`).toChangeFormat( ruby(` ${keyword} ${long} || ${Array(keyword.length).fill("").join(" ")}${long} @@ -14,19 +14,19 @@ describe.each(["while", "until"])("%s", (keyword) => { describe("inlines allowed", () => { test("transforms to inline", () => { - expect(`${keyword} a\n 1\nend`).toChangeFormat(`1 ${keyword} a`); + return expect(`${keyword} a\n 1\nend`).toChangeFormat(`1 ${keyword} a`); }); test("maintains inlines", () => { - expect(`1 ${keyword} a`).toMatchFormat(); + return expect(`1 ${keyword} a`).toMatchFormat(); }); test("breaks on large predicates", () => { - expect(`${keyword} ${long}\n 1\nend`).toMatchFormat(); + return expect(`${keyword} ${long}\n 1\nend`).toMatchFormat(); }); test("breaks inlines on large predicates", () => { - expect(`1 ${keyword} ${long}`).toChangeFormat( + return expect(`1 ${keyword} ${long}`).toChangeFormat( `${keyword} ${long}\n 1\nend` ); }); @@ -38,7 +38,7 @@ describe.each(["while", "until"])("%s", (keyword) => { end ${keyword} bar `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("breaks when an assignment is in the predicate", () => { @@ -48,7 +48,7 @@ describe.each(["while", "until"])("%s", (keyword) => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("breaks when a multi assignment is in the predicate", () => { @@ -58,7 +58,7 @@ describe.each(["while", "until"])("%s", (keyword) => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("breaks the parent when there is an assignment", () => { @@ -70,11 +70,11 @@ describe.each(["while", "until"])("%s", (keyword) => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("wraps single lines in parens when assigning", () => { - expect( + return expect( `hash[:key] = ${keyword} false do break :value end` ).toChangeFormat(`hash[:key] = (break :value ${keyword} false)`); }); @@ -85,7 +85,7 @@ describe.each(["while", "until"])("%s", (keyword) => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("empty body, long predicate", () => { @@ -94,60 +94,7 @@ describe.each(["while", "until"])("%s", (keyword) => { end `); - expect(content).toMatchFormat(); - }); - }); - - describe("inlines not allowed", () => { - test("maintains multiline", () => { - expect(`${keyword} a\n 1\nend`).toMatchFormat({ rubyModifier: false }); - }); - - test("transforms to multiline", () => { - expect(`1 ${keyword} a`).toChangeFormat(`${keyword} a\n 1\nend`, { - rubyModifier: false - }); - }); - - test("breaks on large predicates", () => { - expect(`${keyword} ${long}\n 1\nend`).toMatchFormat({ - rubyModifier: false - }); - }); - - test("breaks inlines on large predicates", () => { - expect(`1 ${keyword} ${long}`).toChangeFormat( - `${keyword} ${long}\n 1\nend`, - { rubyModifier: false } - ); - }); - - test("does not break into block when modifying a begin", () => { - const content = ruby(` - begin - foo - end ${keyword} bar - `); - - expect(content).toMatchFormat({ rubyModifier: false }); - }); - - test("empty body", () => { - const content = ruby(` - while foo - end - `); - - expect(content).toMatchFormat({ rubyModifier: false }); - }); - - test("empty body, long predicate", () => { - const content = ruby(` - while ${long} - end - `); - - expect(content).toMatchFormat({ rubyModifier: false }); + return expect(content).toMatchFormat(); }); }); @@ -155,31 +102,31 @@ describe.each(["while", "until"])("%s", (keyword) => { "add parens when necessary %s", (keyword) => { test("args", () => { - expect(`[${keyword} foo? do bar end]`).toChangeFormat( + return expect(`[${keyword} foo? do bar end]`).toChangeFormat( `[(bar ${keyword} foo?)]` ); }); test("assign", () => { - expect(`foo = ${keyword} bar? do baz end`).toChangeFormat( + return expect(`foo = ${keyword} bar? do baz end`).toChangeFormat( `foo = (baz ${keyword} bar?)` ); }); - test("assoc_new", () => { - expect(`{ foo: ${keyword} bar? do baz end }`).toChangeFormat( + test("assoc", () => { + return expect(`{ foo: ${keyword} bar? do baz end }`).toChangeFormat( `{ foo: (baz ${keyword} bar?) }` ); }); test("massign", () => { - expect(`f, o, o = ${keyword} bar? do baz end`).toChangeFormat( + return expect(`f, o, o = ${keyword} bar? do baz end`).toChangeFormat( `f, o, o = (baz ${keyword} bar?)` ); }); test("opassign", () => { - expect(`foo ||= ${keyword} bar? do baz end`).toChangeFormat( + return expect(`foo ||= ${keyword} bar? do baz end`).toChangeFormat( `foo ||= (baz ${keyword} bar?)` ); }); @@ -208,6 +155,6 @@ describe.each(["while", "until"])("%s", (keyword) => { end `); - expect(content).toChangeFormat(expected); + return expect(content).toChangeFormat(expected); }); }); diff --git a/test/js/ruby/nodes/massign.test.js b/test/js/ruby/nodes/massign.test.js new file mode 100644 index 00000000..5c0ac339 --- /dev/null +++ b/test/js/ruby/nodes/massign.test.js @@ -0,0 +1,67 @@ +describe("massign", () => { + test("multi on left, multi on right", () => { + return expect("a, b, c = 1, 2, 3").toMatchFormat(); + }); + + test("single on left, multi on right", () => { + return expect("a = 1, 2, 3").toMatchFormat(); + }); + + test("multi on left, array on right", () => { + return expect("a, b, c = [1, 2, 3]").toMatchFormat(); + }); + + test("parens on left, multi on right", () => { + return expect("(a, b, c) = 1, 2, 3").toChangeFormat("a, b, c = 1, 2, 3"); + }); + + test("double parens on left, multi on right", () => { + return expect("((a, b, c)) = 1, 2, 3").toChangeFormat("a, b, c = 1, 2, 3"); + }); + + test("parens on some of left, multi on right", () => { + return expect("(a, b), c = [1, 2], 3").toMatchFormat(); + }); + + test("extra commas at the end", () => { + return expect("a, = 1").toMatchFormat(); + }); + + test("extra commas at the end with multiple", () => { + return expect("a, b, c, = 1").toMatchFormat(); + }); + + test("extra commas with parens", () => { + return expect("(a, b,), c, = 1").toMatchFormat(); + }); + + test("extra commas with doubled parens", () => { + return expect("((a, b,), c,), = 1").toMatchFormat(); + }); + + describe("splat", () => { + test("after ident", () => { + return expect("a, *b = 1, 2, 3").toMatchFormat(); + }); + + test("between idents", () => { + return expect("a, *b, c, d = 1, 2, 3").toMatchFormat(); + }); + + test("with no name", () => { + return expect("a, * = 1, 2, 3").toMatchFormat(); + }); + + test("on right side", () => { + return expect("a = *a").toMatchFormat(); + }); + + test("only on left side", () => { + return expect("* = [1, 2, 3]").toMatchFormat(); + }); + + test("and then ident on left side", () => { + return expect("*, a = [1, 2, 3]").toMatchFormat(); + }); + }); +}); diff --git a/test/js/ruby/nodes/massign.test.ts b/test/js/ruby/nodes/massign.test.ts deleted file mode 100644 index 5ff61845..00000000 --- a/test/js/ruby/nodes/massign.test.ts +++ /dev/null @@ -1,67 +0,0 @@ -describe("massign", () => { - test("multi on left, multi on right", () => { - expect("a, b, c = 1, 2, 3").toMatchFormat(); - }); - - test("single on left, multi on right", () => { - expect("a = 1, 2, 3").toMatchFormat(); - }); - - test("multi on left, array on right", () => { - expect("a, b, c = [1, 2, 3]").toMatchFormat(); - }); - - test("parens on left, multi on right", () => { - expect("(a, b, c) = 1, 2, 3").toChangeFormat("a, b, c = 1, 2, 3"); - }); - - test("double parens on left, multi on right", () => { - expect("((a, b, c)) = 1, 2, 3").toChangeFormat("a, b, c = 1, 2, 3"); - }); - - test("parens on some of left, multi on right", () => { - expect("(a, b), c = [1, 2], 3").toMatchFormat(); - }); - - test("extra commas at the end", () => { - expect("a, = 1").toMatchFormat(); - }); - - test("extra commas at the end with multiple", () => { - expect("a, b, c, = 1").toMatchFormat(); - }); - - test("extra commas with parens", () => { - expect("(a, b,), c, = 1").toMatchFormat(); - }); - - test("extra commas with doubled parens", () => { - expect("((a, b,), c,), = 1").toMatchFormat(); - }); - - describe("splat", () => { - test("after ident", () => { - expect("a, *b = 1, 2, 3").toMatchFormat(); - }); - - test("between idents", () => { - expect("a, *b, c, d = 1, 2, 3").toMatchFormat(); - }); - - test("with no name", () => { - expect("a, * = 1, 2, 3").toMatchFormat(); - }); - - test("on right side", () => { - expect("a = *a").toMatchFormat(); - }); - - test("only on left side", () => { - expect("* = [1, 2, 3]").toMatchFormat(); - }); - - test("and then ident on left side", () => { - expect("*, a = [1, 2, 3]").toMatchFormat(); - }); - }); -}); diff --git a/test/js/ruby/nodes/method.test.ts b/test/js/ruby/nodes/method.test.js similarity index 57% rename from test/js/ruby/nodes/method.test.ts rename to test/js/ruby/nodes/method.test.js index 15b63195..5195e29f 100644 --- a/test/js/ruby/nodes/method.test.ts +++ b/test/js/ruby/nodes/method.test.js @@ -1,81 +1,85 @@ -import { atLeastVersion, long, ruby } from "../../utils"; +import { atLeastVersion, long, ruby } from "../../utils.js"; describe("method", () => { describe("definitions", () => { test("shorthand for empty methods", () => { - expect("def foo; end").toMatchFormat(); + return expect("def foo; end").toChangeFormat("def foo\nend"); }); test("shorthand for empty methods with parens", () => { - expect("def foo(); end").toMatchFormat(); + return expect("def foo(); end").toChangeFormat("def foo()\nend"); }); test("single arg, no parens", () => { - expect("def foo bar\nend").toChangeFormat("def foo(bar); end"); + return expect("def foo bar\nend").toChangeFormat("def foo(bar)\nend"); }); test("single arg, with parens", () => { - expect("def foo(bar)\nend").toChangeFormat("def foo(bar); end"); + return expect("def foo(bar)\nend").toMatchFormat(); }); test("shorthand for empty singleton methods", () => { - expect("def self.foo; end").toMatchFormat(); + return expect("def self.foo; end").toChangeFormat("def self.foo\nend"); }); test("shorthand for empty singleton methods with parens", () => { - expect("def self.foo(); end").toMatchFormat(); + return expect("def self.foo(); end").toChangeFormat( + "def self.foo()\nend" + ); }); test("singleton, single arg, no parens", () => { - expect("def self.foo bar\nend").toChangeFormat("def self.foo(bar); end"); + return expect("def self.foo bar\nend").toChangeFormat( + "def self.foo(bar)\nend" + ); }); test("singleton, single arg, with parens", () => { - expect("def self.foo(bar)\nend").toChangeFormat("def self.foo(bar); end"); + return expect("def self.foo(bar)\nend").toMatchFormat(); }); test("shorthand with a body", () => { - expect("def foo(alpha); 1; end").toChangeFormat( + return expect("def foo(alpha); 1; end").toChangeFormat( "def foo(alpha)\n 1\nend" ); }); test("single splat arg with no name", () => { - expect("def foo(*); end").toMatchFormat(); + return expect("def foo(*); end").toChangeFormat("def foo(*)\nend"); }); test("double splat arg with no name", () => { - expect("def foo(**); end").toMatchFormat(); + return expect("def foo(**); end").toChangeFormat("def foo(**)\nend"); }); test("with helper method", () => { const content = ruby(` private def foo - 'bar' + "bar" end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("with helper method on defs", () => { const content = ruby(` private def self.foo - 'bar' + "bar" end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("every single arg type", () => { const content = ruby(` def method(req, *rest, post, kwarg:, kwarg_opt: 1, **kwarg_rest, &block) - 'foo' + "foo" end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("breaking", () => { @@ -84,10 +88,11 @@ describe("method", () => { def foo( ${long}:, a${long}: - ); end + ) + end `); - expect(content).toChangeFormat(expected); + return expect(content).toChangeFormat(expected); }); test("with comments on method definition", () => { @@ -99,7 +104,7 @@ describe("method", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("with comments on params", () => { @@ -113,28 +118,30 @@ describe("method", () => { **kwarg_rest, # kwarg_rest comment &block # block comment ) - 'foo' + "foo" end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("with comments on optional params", () => { const content = ruby(` def method( - optl = 'value' # comment + optl = "value" # comment ) - 'foo' + "foo" end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); if (atLeastVersion("2.7")) { test("nokw_param", () => { - expect("def foo(**nil); end").toMatchFormat(); + return expect("def foo(**nil); end").toChangeFormat( + "def foo(**nil)\nend" + ); }); test("args_forward", () => { @@ -144,7 +151,7 @@ describe("method", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); } @@ -156,19 +163,15 @@ describe("method", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("single-line methods", () => { - expect("def foo = bar").toMatchFormat(); - }); - - test("single-line methods with empty params", () => { - expect("def foo() = bar").toChangeFormat("def foo = bar"); + return expect("def foo = bar").toMatchFormat(); }); test("single-line methods with params", () => { - expect("def foo(name) = bar").toMatchFormat(); + return expect("def foo(name) = bar").toMatchFormat(); }); } @@ -182,25 +185,21 @@ describe("method", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); }); describe("method calls", () => { - test("empty parens", () => { - expect("foo()").toChangeFormat("foo"); - }); - test("single args", () => { - expect("foo(1)").toMatchFormat(); + return expect("foo(1)").toMatchFormat(); }); test("multi arg", () => { - expect("foo(1, 2)").toMatchFormat(); + return expect("foo(1, 2)").toMatchFormat(); }); test("just block", () => { - expect("foo(&block)").toMatchFormat(); + return expect("foo(&block)").toMatchFormat(); }); describe("commands", () => { @@ -211,7 +210,7 @@ describe("method", () => { ) `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("alignment for `to`", () => { @@ -221,7 +220,7 @@ describe("method", () => { ) `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("alignment for `not_to`", () => { @@ -231,7 +230,7 @@ describe("method", () => { ) `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("alignment for `to_not`", () => { @@ -241,7 +240,7 @@ describe("method", () => { ) `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("just block", () => { @@ -251,21 +250,21 @@ describe("method", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); }); describe("single splat", () => { test("plain", () => { - expect("foo(*bar)").toMatchFormat(); + return expect("foo(*bar)").toMatchFormat(); }); test("with multi args", () => { - expect("foo(1, 2, *abc)").toMatchFormat(); + return expect("foo(1, 2, *abc)").toMatchFormat(); }); test("between multi args", () => { - expect("foo(1, 2, *abc, 3, 4)").toMatchFormat(); + return expect("foo(1, 2, *abc, 3, 4)").toMatchFormat(); }); test("with comments", () => { @@ -278,7 +277,7 @@ describe("method", () => { ) `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("with trailing comments", () => { @@ -291,11 +290,11 @@ describe("method", () => { ) `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("with block", () => { - expect("foo(*bar, &block)").toMatchFormat(); + return expect("foo(*bar, &block)").toMatchFormat(); }); test("with comments and block", () => { @@ -306,74 +305,74 @@ describe("method", () => { ) `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); }); describe("double splat", () => { test("plain", () => { - expect("foo(**bar)").toMatchFormat(); + return expect("foo(**bar)").toMatchFormat(); }); test("with block", () => { - expect("foo(**bar, &block)").toMatchFormat(); + return expect("foo(**bar, &block)").toMatchFormat(); }); test("with splat and block", () => { - expect("foo(*bar, **baz, &block)").toMatchFormat(); + return expect("foo(*bar, **baz, &block)").toMatchFormat(); }); test("after kwarg", () => { - expect("foo(kwarg: 1, **splat)").toMatchFormat(); + return expect("foo(kwarg: 1, **splat)").toMatchFormat(); }); test("before kwarg", () => { - expect("foo(**splat, kwarg: 1)").toMatchFormat(); + return expect("foo(**splat, kwarg: 1)").toMatchFormat(); }); test("before kwargs", () => { - expect("foo(before: 1, **splat, after: 1)").toMatchFormat(); + return expect("foo(before: 1, **splat, after: 1)").toMatchFormat(); }); }); describe("different operators", () => { test("double colon gets changed", () => { - expect("Foo::foo").toChangeFormat("Foo.foo"); + return expect("Foo::foo").toChangeFormat("Foo.foo"); }); test("lonely operator", () => { - expect("foo&.foo").toMatchFormat(); + return expect("foo&.foo").toMatchFormat(); }); }); describe("breaking", () => { describe("without trailing commas", () => { test("starting with no trailing comma stays", () => { - expect(`foo(${long}, a${long})`).toChangeFormat( + return expect(`foo(${long}, a${long})`).toChangeFormat( `foo(\n ${long},\n a${long}\n)` ); }); test("with breaking ternary as first argument", () => { - expect(`foo bar ? ${long} : a${long}`).toChangeFormat( + return expect(`foo bar ? ${long} : a${long}`).toChangeFormat( `foo(\n if bar\n ${long}\n else\n a${long}\n end\n)` ); }); test("starting with trailing comma changes", () => { - expect(`foo(${long}, a${long},)`).toChangeFormat( + return expect(`foo(${long}, a${long},)`).toChangeFormat( `foo(\n ${long},\n a${long}\n)` ); }); test("with block on the end", () => { - expect(`foo(${long}, &block)`).toChangeFormat( + return expect(`foo(${long}, &block)`).toChangeFormat( `foo(\n ${long},\n &block\n)` ); }); test("on commands", () => { - expect(`command ${long}, a${long}`).toChangeFormat( + return expect(`command ${long}, a${long}`).toChangeFormat( ruby(` command ${long}, a${long} @@ -382,7 +381,7 @@ describe("method", () => { }); test("on command calls", () => { - expect(`command.call ${long}, a${long}`).toChangeFormat( + return expect(`command.call ${long}, a${long}`).toChangeFormat( ruby(` command.call ${long}, a${long} @@ -390,67 +389,6 @@ describe("method", () => { ); }); }); - - describe("with trailing commas", () => { - test("starting with no trailing comma changes", () => { - expect(`foo(${long}, a${long})`).toChangeFormat( - `foo(\n ${long},\n a${long},\n)`, - { - trailingComma: "all" - } - ); - }); - - test("starting with trailing comma stays", () => { - expect(`foo(${long}, a${long},)`).toChangeFormat( - `foo(\n ${long},\n a${long},\n)`, - { - trailingComma: "all" - } - ); - }); - - test("with block on the end", () => { - expect(`foo(${long}, &block)`).toChangeFormat( - `foo(\n ${long},\n &block\n)`, - { - trailingComma: "all" - } - ); - }); - - test("on commands", () => { - expect(`command ${long}, a${long}`).toChangeFormat( - ruby(` - command ${long}, - a${long} - `), - { trailingComma: "all" } - ); - }); - - test("on command calls", () => { - expect(`command.call ${long}, a${long}`).toChangeFormat( - ruby(` - command.call ${long}, - a${long} - `), - { trailingComma: "all" } - ); - }); - - test("on long commands within an arg_paren", () => { - const expected = ruby(` - foo( - ${long} 'bar' - ) - `); - - expect(`foo(${long} 'bar')`).toChangeFormat(expected, { - trailingComma: "all" - }); - }); - }); }); }); }); diff --git a/test/js/ruby/nodes/next.test.ts b/test/js/ruby/nodes/next.test.js similarity index 52% rename from test/js/ruby/nodes/next.test.ts rename to test/js/ruby/nodes/next.test.js index 9e2dbdd4..b1a9fb54 100644 --- a/test/js/ruby/nodes/next.test.ts +++ b/test/js/ruby/nodes/next.test.js @@ -1,20 +1,20 @@ -import { ruby } from "../../utils"; +import { ruby } from "../../utils.js"; describe("next", () => { test("bare", () => { - expect("next").toMatchFormat(); + return expect("next").toMatchFormat(); }); test("one arg, no parens", () => { - expect("next 1").toMatchFormat(); + return expect("next 1").toMatchFormat(); }); test("one arg, with parens", () => { - expect("next(1)").toChangeFormat("next 1"); + return expect("next(1)").toChangeFormat("next 1"); }); test("multiple args", () => { - expect("next 1, 2").toMatchFormat(); + return expect("next 1, 2").toMatchFormat(); }); test("keeps parens for multiple statements", () => { @@ -25,10 +25,10 @@ describe("next", () => { ) `); - expect("next(a = 1; a == 1)").toChangeFormat(expected); + return expect("next(a = 1; a == 1)").toChangeFormat(expected); }); test("keeps parens for _mod nodes", () => { - expect("next(1 if true)").toMatchFormat(); + return expect("next(1 if true)").toMatchFormat(); }); }); diff --git a/test/js/ruby/nodes/numbers.test.ts b/test/js/ruby/nodes/numbers.test.js similarity index 56% rename from test/js/ruby/nodes/numbers.test.ts rename to test/js/ruby/nodes/numbers.test.js index 82266637..a1edd35b 100644 --- a/test/js/ruby/nodes/numbers.test.ts +++ b/test/js/ruby/nodes/numbers.test.js @@ -1,49 +1,49 @@ describe("numbers", () => { test("basic", () => { - expect("123").toMatchFormat(); + return expect("123").toMatchFormat(); }); test("preserves sign", () => { - expect("-123").toMatchFormat(); + return expect("-123").toMatchFormat(); }); test("respects no o for octal numbers", () => { - expect("0123").toChangeFormat("0123"); + return expect("0123").toChangeFormat("0123"); }); test("respects o for octal numbers", () => { - expect("0o123").toChangeFormat("0o123"); + return expect("0o123").toChangeFormat("0o123"); }); test("does not consider numbers large until they have more than 4 digits", () => { - expect("1234").toMatchFormat(); + return expect("1234").toMatchFormat(); }); test("for large numbers adds underscores (mod 3 ==== 0)", () => { - expect("123456").toChangeFormat("123_456"); + return expect("123456").toChangeFormat("123_456"); }); test("for large numbers adds underscores (mod 3 === 1)", () => { - expect("1234567").toChangeFormat("1_234_567"); + return expect("1234567").toChangeFormat("1_234_567"); }); test("for large numbers add underscores (mod 3 ==== 2)", () => { - expect("12345678").toChangeFormat("12_345_678"); + return expect("12345678").toChangeFormat("12_345_678"); }); test("ignores numbers that already have underscores", () => { - expect("2019_04_17_17_09_00").toMatchFormat(); + return expect("2019_04_17_17_09_00").toMatchFormat(); }); test("ignores formatting on binary numbers", () => { - expect("0b01101001").toMatchFormat(); + return expect("0b01101001").toMatchFormat(); }); test("ignores formatting on octal numbers", () => { - expect("0o123401234").toMatchFormat(); + return expect("0o123401234").toMatchFormat(); }); test("ignores formatting on hex numbers", () => { - expect("0x123401234").toMatchFormat(); + return expect("0x123401234").toMatchFormat(); }); }); diff --git a/test/js/ruby/nodes/patterns.test.js b/test/js/ruby/nodes/patterns.test.js new file mode 100644 index 00000000..19e0793f --- /dev/null +++ b/test/js/ruby/nodes/patterns.test.js @@ -0,0 +1,189 @@ +import { atLeastVersion, atMostVersion, ruby } from "../../utils.js"; + +describe("patterns", () => { + if (atMostVersion("2.7")) { + test("pattern matching does not exist before ruby 2.7", () => { + // this is here because test files must contain at least one test, so for + // earlier versions of ruby this is just going to chill here + }); + + return; + } + + const cases = [ + "0", + "-1..1", + "Integer", + "bar", + "0 | 1 | 2", + "Integer => bar", + "Object[0, *bar, 1]", + "^bar", + "{ x: 0.. => px, **rest }", + "**rest", + "SuperPoint[x: 0.. => px]" + ]; + + if (atLeastVersion("3.0")) { + cases.push("[*, 0, *]", "[*, 0, 1, 2, *]", "FooBar[*, 0, *]"); + + test("rassign", () => { + const content = `{ db: { user: "John" } } => { db: { user: } }`; + + return expect(content).toMatchFormat(); + }); + + test("rassign with fndptn", () => { + const content = "(1..10).to_a.shuffle => [*bef, 2..4 => thresh, *aft]"; + + return expect(content).toMatchFormat(); + }); + } + + test.each(cases)("%s", (pattern) => { + const content = ruby(` + case foo + in ${pattern} + baz + end + `); + + return expect(content).toMatchFormat(); + }); + + test("a, b, *c, d, e", () => { + const content = ruby(` + case foo + in a, b, *c, d, e + baz + end + `); + + const expectedContent = ruby(` + case foo + in [a, b, *c, d, e] + baz + end + `); + + return expect(content).toChangeFormat(expectedContent); + }); + + test("0, [1, _] => bar", () => { + const content = ruby(` + case foo + in 0, [1, _] => bar + baz + end + `); + + const expectedContent = ruby(` + case foo + in [0, [1, _] => bar] + baz + end + `); + + return expect(content).toChangeFormat(expectedContent); + }); + + test("*c, d, e", () => { + const content = ruby(` + case foo + in *c, d, e + baz + end + `); + + const expectedContent = ruby(` + case foo + in [*c, d, e] + baz + end + `); + + return expect(content).toChangeFormat(expectedContent); + }); + + test("_, _", () => { + const content = ruby(` + case foo + in _, _ + baz + end + `); + + const expectedContent = ruby(` + case foo + in [_, _] + baz + end + `); + + return expect(content).toChangeFormat(expectedContent); + }); + + test("a, b if b == a * 2", () => { + const content = ruby(` + case foo + in a, b if b == a * 2 + baz + end + `); + + const expectedContent = ruby(` + case foo + in [a, b] if b == a * 2 + baz + end + `); + + return expect(content).toChangeFormat(expectedContent); + }); + + test("with a single array element", () => { + const content = ruby(` + case value + in [element] + matched + end + `); + + return expect(content).toMatchFormat(); + }); + + test("with comments in an array pattern", () => { + const content = ruby(` + case foo + in 1, # 1 comment + 2 # 2 comment + bar + end + `); + + const expectedContent = ruby(` + case foo + in [ + 1, # 1 comment + 2 + ] # 2 comment + bar + end + `); + + return expect(content).toChangeFormat(expectedContent); + }); + + test("multiple clauses", () => { + const content = ruby(` + case foo + in bar + 1 + in baz + 2 + end + `); + + return expect(content).toMatchFormat(); + }); +}); diff --git a/test/js/ruby/nodes/patterns.test.ts b/test/js/ruby/nodes/patterns.test.ts deleted file mode 100644 index 136def0d..00000000 --- a/test/js/ruby/nodes/patterns.test.ts +++ /dev/null @@ -1,106 +0,0 @@ -import { atLeastVersion, atMostVersion, ruby } from "../../utils"; - -describe("patterns", () => { - if (atMostVersion("2.7")) { - test("pattern matching does not exist before ruby 2.7", () => { - // this is here because test files must contain at least one test, so for - // earlier versions of ruby this is just going to chill here - }); - - return; - } - - const cases = [ - "0", - "-1..1", - "Integer", - "bar", - "_, _", - "0 | 1 | 2", - "Integer => bar", - "Object[0, *bar, 1]", - "a, b, *c, d, e", - "*c, d, e", - "0, [1, _] => bar", - "^bar", - "x: 0.. => px, **rest", - "**rest", - "SuperPoint[x: 0.. => px]", - "a, b if b == a * 2" - ]; - - if (atLeastVersion("3.0")) { - cases.push("[*, 0, *]", "[*, 0, 1, 2, *]", "FooBar[*, 0, *]"); - - test("rassign", () => { - const content = "{ db: { user: 'John' } } => { db: { user: } }"; - - expect(content).toMatchFormat(); - }); - - test("rassign with fndptn", () => { - const content = "(1..10).to_a.shuffle => [*bef, 2..4 => thresh, *aft]"; - - expect(content).toMatchFormat(); - }); - } - - test.each(cases)("%s", (pattern) => { - const content = ruby(` - case foo - in ${pattern} - baz - end - `); - - expect(content).toMatchFormat(); - }); - - test("with a single array element", () => { - const content = ruby(` - case value - in [element] - matched - end - `); - - expect(content).toMatchFormat(); - }); - - test("with comments in an array pattern", () => { - const content = ruby(` - case foo - in 1, # 1 comment - 2 # 2 comment - bar - end - `); - - expect(content).toMatchFormat(); - }); - - test("with comments in an array pattern", () => { - const content = ruby(` - case foo - in foo:, # foo comment - bar: # bar comment - bar - end - `); - - expect(content).toMatchFormat(); - }); - - test("multiple clauses", () => { - const content = ruby(` - case foo - in bar - 1 - in baz - 2 - end - `); - - expect(content).toMatchFormat(); - }); -}); diff --git a/test/js/ruby/nodes/ranges.test.ts b/test/js/ruby/nodes/ranges.test.js similarity index 53% rename from test/js/ruby/nodes/ranges.test.ts rename to test/js/ruby/nodes/ranges.test.js index 3e3d67d2..1f92ba36 100644 --- a/test/js/ruby/nodes/ranges.test.ts +++ b/test/js/ruby/nodes/ranges.test.js @@ -1,39 +1,39 @@ -import { atLeastVersion } from "../../utils"; +import { atLeastVersion } from "../../utils.js"; describe("ranges", () => { test("two dot", () => { - expect("1..2").toMatchFormat(); + return expect("1..2").toMatchFormat(); }); test("negative two dot", () => { - expect("-2..-1").toMatchFormat(); + return expect("-2..-1").toMatchFormat(); }); test("three dot", () => { - expect("3...4").toMatchFormat(); + return expect("3...4").toMatchFormat(); }); test("negative three dot", () => { - expect("-4...-3").toMatchFormat(); + return expect("-4...-3").toMatchFormat(); }); if (atLeastVersion("2.6")) { test("two dot with no ending", () => { - expect("1..").toMatchFormat(); + return expect("1..").toMatchFormat(); }); test("three dot with no ending", () => { - expect("1...").toMatchFormat(); + return expect("1...").toMatchFormat(); }); } if (atLeastVersion("2.7")) { test("two dot with no beginning", () => { - expect("..2").toMatchFormat(); + return expect("..2").toMatchFormat(); }); test("three dot with no beginning", () => { - expect("...2").toMatchFormat(); + return expect("...2").toMatchFormat(); }); } }); diff --git a/test/js/ruby/nodes/regexp.test.ts b/test/js/ruby/nodes/regexp.test.js similarity index 57% rename from test/js/ruby/nodes/regexp.test.ts rename to test/js/ruby/nodes/regexp.test.js index 59866495..327e6e2b 100644 --- a/test/js/ruby/nodes/regexp.test.ts +++ b/test/js/ruby/nodes/regexp.test.js @@ -1,56 +1,56 @@ -import { ruby } from "../../utils"; +import { ruby } from "../../utils.js"; describe("regexp", () => { test("basic", () => { - expect("/abc/").toMatchFormat(); + return expect("/abc/").toMatchFormat(); }); test("unnecessary braces", () => { - expect("%r{abc}").toChangeFormat("/abc/"); + return expect("%r{abc}").toChangeFormat("/abc/"); }); test("unnecessary slashes", () => { - expect("%r/abc/").toChangeFormat("/abc/"); + return expect("%r/abc/").toChangeFormat("/abc/"); }); test("unnecessary brackets", () => { - expect("%r[abc]").toChangeFormat("/abc/"); + return expect("%r[abc]").toChangeFormat("/abc/"); }); test("unnecessary parens", () => { - expect("%r(abc)").toChangeFormat("/abc/"); + return expect("%r(abc)").toChangeFormat("/abc/"); }); test("necessary braces", () => { - expect("%r{a/b/c}").toMatchFormat(); + return expect("%r{a/b/c}").toMatchFormat(); }); test("interpolation", () => { - expect("/a#{inter}c/").toMatchFormat(); + return expect("/a#{inter}c/").toMatchFormat(); }); test("modifiers", () => { - expect("/abc/i").toMatchFormat(); + return expect("/abc/i").toMatchFormat(); }); test("braces and modifiers", () => { - expect("%r{a/b/c}mi").toMatchFormat(); + return expect("%r{a/b/c}mi").toMatchFormat(); }); test("global interpolation", () => { - expect("/#$&/").toChangeFormat("/#{$&}/"); + return expect("/#$&/").toChangeFormat("/#{$&}/"); }); test("do not change if { and / in regexp literal", () => { - expect("%r(a{b/c)").toMatchFormat(); + return expect("%r(a{b/c)").toMatchFormat(); }); test("do not change if } and / in regexp literal", () => { - expect("%r[a}b/c]").toMatchFormat(); + return expect("%r[a}b/c]").toMatchFormat(); }); test("parens with }", () => { - expect("%r(a}bc)").toChangeFormat("/a}bc/"); + return expect("%r(a}bc)").toChangeFormat("/a}bc/"); }); test("comments in regex", () => { @@ -63,18 +63,18 @@ describe("regexp", () => { \\Z/x `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("forces braces if could be ambiguous with space in command", () => { - expect("foo %r{ bar}").toMatchFormat(); + return expect("foo %r{ bar}").toMatchFormat(); }); test("forces braces if could be ambiguous with equals in command", () => { - expect("foo %r{= bar}").toMatchFormat(); + return expect("foo %r{= bar}").toMatchFormat(); }); test("do not force braces if space is in parens", () => { - expect("foo(/ bar/)").toMatchFormat(); + return expect("foo(/ bar/)").toMatchFormat(); }); }); diff --git a/test/js/ruby/nodes/rescue.test.ts b/test/js/ruby/nodes/rescue.test.js similarity index 83% rename from test/js/ruby/nodes/rescue.test.ts rename to test/js/ruby/nodes/rescue.test.js index b3948af7..4a10d7b1 100644 --- a/test/js/ruby/nodes/rescue.test.ts +++ b/test/js/ruby/nodes/rescue.test.js @@ -1,4 +1,4 @@ -import { ruby } from "../../utils"; +import { ruby } from "../../utils.js"; describe("rescue", () => { test("inline", () => { @@ -10,7 +10,7 @@ describe("rescue", () => { end `); - expect("a rescue nil").toChangeFormat(expected); + return expect("a rescue nil").toChangeFormat(expected); }); test("rescue just variable", () => { @@ -22,7 +22,7 @@ describe("rescue", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); // from ruby spec/ruby/language/rescue_spec.rb @@ -35,7 +35,7 @@ describe("rescue", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); // https://github.com/prettier/plugin-ruby/pull/1000 @@ -48,7 +48,7 @@ describe("rescue", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test.each(["begin", "def foo"])("%s with every clause", (declaration) => { @@ -74,7 +74,7 @@ describe("rescue", () => { end `); - expect(content).toChangeFormat( + return expect(content).toChangeFormat( ruby(` ${declaration} 1 @@ -108,7 +108,7 @@ describe("rescue", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("comment inline", () => { @@ -120,7 +120,7 @@ describe("rescue", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("comment inline with multiple", () => { @@ -132,7 +132,7 @@ describe("rescue", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("comment inline with splat", () => { @@ -144,7 +144,7 @@ describe("rescue", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("one error with a comment", () => { @@ -156,7 +156,7 @@ describe("rescue", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("two errors with a comment", () => { @@ -168,6 +168,6 @@ describe("rescue", () => { end `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); }); diff --git a/test/js/ruby/nodes/return.test.js b/test/js/ruby/nodes/return.test.js new file mode 100644 index 00000000..0121128c --- /dev/null +++ b/test/js/ruby/nodes/return.test.js @@ -0,0 +1,103 @@ +import { long, ruby } from "../../utils.js"; + +describe("return", () => { + test("bare", () => { + return expect("return").toMatchFormat(); + }); + + test("one arg, no parens", () => { + return expect("return 1").toMatchFormat(); + }); + + test("one arg, with parens", () => { + return expect("return(1)").toChangeFormat("return 1"); + }); + + test("multiple args", () => { + return expect("return 1, 2").toMatchFormat(); + }); + + test("return method call", () => { + return expect("return foo :bar").toMatchFormat(); + }); + + test("return with breaking", () => { + return expect(`return ${long}`).toChangeFormat(`return(\n ${long}\n)`); + }); + + test("returning an array", () => { + return expect("return [1, 2, 3]").toChangeFormat("return 1, 2, 3"); + }); + + test("returning an empty array", () => { + return expect("return []").toMatchFormat(); + }); + + test("returning a single element array", () => { + return expect("return [1]").toMatchFormat(); + }); + + test("returning a list that breaks", () => { + return expect(`return ${long}, ${long}`).toChangeFormat( + `return [\n ${long},\n ${long}\n]` + ); + }); + + test("returning an array within parens", () => { + return expect("return([1, 2, 3])").toChangeFormat("return 1, 2, 3"); + }); + + test("returning a long special array", () => { + return expect(`return %w[${long}]`).toChangeFormat( + `return(\n %w[\n ${long}\n ]\n)` + ); + }); + + test("returning two arguments, one that breaks", () => { + return expect(`return foo, ${long}`).toChangeFormat( + `return [\n foo,\n ${long}\n]` + ); + }); + + test("returning two arguments, the first with parentheses", () => { + return expect("return (1), 2").toMatchFormat(); + }); + + test("returning with the or keyword", () => { + return expect("return(a or b)").toMatchFormat(); + }); + + test("returning with the not keyword", () => { + return expect("return(not a)").toMatchFormat(); + }); + + test("comment inside of return parentheses", () => { + const content = ruby(` + return( + # foo + bar + ) + `); + + return expect(content).toMatchFormat(); + }); + + test("returning multiple statements", () => { + const content = ruby(` + return( + foo + bar + ) + `); + + return expect(content).toMatchFormat(); + }); + + test("returning a value with a modifier if", () => { + const content = ruby(` + return :inactive if given_date.before?(first_event_date) + `); + + return expect(content).toMatchFormat(); + }); +}); diff --git a/test/js/ruby/nodes/return.test.ts b/test/js/ruby/nodes/return.test.ts deleted file mode 100644 index 754188c6..00000000 --- a/test/js/ruby/nodes/return.test.ts +++ /dev/null @@ -1,84 +0,0 @@ -import { long, ruby } from "../../utils"; - -describe("return", () => { - test("bare", () => { - expect("return").toMatchFormat(); - }); - - test("one arg, no parens", () => { - expect("return 1").toMatchFormat(); - }); - - test("one arg, with parens", () => { - expect("return(1)").toChangeFormat("return 1"); - }); - - test("multiple args", () => { - expect("return 1, 2").toMatchFormat(); - }); - - test("return method call", () => { - expect("return foo :bar").toMatchFormat(); - }); - - test("return with breaking", () => { - expect(`return ${long}`).toChangeFormat(`return(\n ${long}\n)`); - }); - - test("returning an array", () => { - expect("return [1, 2, 3]").toChangeFormat("return 1, 2, 3"); - }); - - test("returning an empty array", () => { - expect("return []").toMatchFormat(); - }); - - test("returning a single element array", () => { - expect("return [1]").toMatchFormat(); - }); - - test("returning a list that breaks", () => { - expect(`return ${long}, ${long}`).toChangeFormat( - `return [\n ${long},\n ${long}\n]` - ); - }); - - test("returning an array within parens", () => { - expect("return([1, 2, 3])").toChangeFormat("return 1, 2, 3"); - }); - - test("returning a long special array", () => { - expect(`return %w[${long}]`).toChangeFormat( - `return(\n %w[\n ${long}\n ]\n)` - ); - }); - - test("returning two arguments, one that breaks", () => { - expect(`return foo, ${long}`).toChangeFormat( - `return [\n foo,\n ${long}\n]` - ); - }); - - test("returning two arguments, the first with parentheses", () => { - expect("return (1), 2").toMatchFormat(); - }); - - test("returning with the or keyword", () => { - expect("return(a or b)").toMatchFormat(); - }); - - test("returning with the not keyword", () => { - expect("return(not a)").toMatchFormat(); - }); - - test("comment inside of return parentheses", () => { - const content = ruby(` - return( - # foo - bar - ) - `); - - expect(content).toMatchFormat(); - }); -}); diff --git a/test/js/ruby/nodes/strings.test.ts b/test/js/ruby/nodes/strings.test.js similarity index 56% rename from test/js/ruby/nodes/strings.test.ts rename to test/js/ruby/nodes/strings.test.js index c7fee41a..3970ad51 100644 --- a/test/js/ruby/nodes/strings.test.ts +++ b/test/js/ruby/nodes/strings.test.js @@ -1,4 +1,4 @@ -import { long, ruby } from "../../utils"; +import { long, ruby } from "../../utils.js"; describe("strings", () => { describe("%-literals with escape sequences in the middle", () => { @@ -25,119 +25,117 @@ describe("strings", () => { describe("with single quotes", () => { test("empty single quote strings stay", () => { - expect("''").toMatchFormat(); + return expect("''").toChangeFormat(`""`); }); test("empty double quote strings change", () => { - expect(`""`).toChangeFormat("''"); + return expect(`""`).toMatchFormat(); }); test("basic strings with single quotes stay", () => { - expect("'abc'").toMatchFormat(); + return expect("'abc'").toChangeFormat(`"abc"`); }); test("basic strings with double quotes change", () => { - expect(`"abc"`).toChangeFormat("'abc'"); + return expect(`"abc"`).toMatchFormat(); }); test("double quotes with inner single quotes stay", () => { - expect(`"abc's"`).toMatchFormat(); + return expect(`"abc's"`).toMatchFormat(); }); describe("escape sequences", () => { test("single quotes stay", () => { - expect("'abc\\n'").toMatchFormat(); + return expect("'abc\\n'").toMatchFormat(); }); test("double quotes stay", () => { - expect(`"abc\\n"`).toMatchFormat(); + return expect(`"abc\\n"`).toMatchFormat(); }); test("interpolation within single quotes stay", () => { - expect(`'#{"\\n"}'`).toMatchFormat(); + return expect(`'#{"\\n"}'`).toMatchFormat(); }); test("interpolation within double quotes stay", () => { - expect(`"#{"\\n"}"`).toMatchFormat(); + return expect(`"#{"\\n"}"`).toMatchFormat(); }); test("escaped double quotes are not unquoted", () => { - expect("'abc \\\"def\\\" ghi'").toMatchFormat(); + return expect("'abc \\\"def\\\" ghi'").toMatchFormat(); }); }); }); describe("with double quotes", () => { test("empty single quote strings change", () => { - expect("''").toChangeFormat(`""`, { rubySingleQuote: false }); + return expect("''").toChangeFormat(`""`); }); test("empty double quote strings stay", () => { - expect(`""`).toMatchFormat({ rubySingleQuote: false }); + return expect(`""`).toMatchFormat(); }); test("basic strings with single quotes change", () => { - expect("'abc'").toChangeFormat(`"abc"`, { rubySingleQuote: false }); + return expect("'abc'").toChangeFormat(`"abc"`); }); test("basic strings with double quotes stay", () => { - expect(`"abc"`).toMatchFormat({ rubySingleQuote: false }); + return expect(`"abc"`).toMatchFormat(); }); test("double quotes with inner single quotes stay", () => { - expect(`"abc's"`).toMatchFormat({ rubySingleQuote: false }); + return expect(`"abc's"`).toMatchFormat(); }); - test("double quotes get escaped", () => { - expect(`'"foo"'`).toChangeFormat(`"\\"foo\\""`, { - rubySingleQuote: false - }); + test("double quotes do not get escaped if it results in more quotes", () => { + return expect(`'"foo"'`).toMatchFormat(); }); describe("escape sequences", () => { test("single quotes stay", () => { - expect("'abc\\n'").toMatchFormat(); + return expect("'abc\\n'").toMatchFormat(); }); test("double quotes stay", () => { - expect(`"abc\\n"`).toMatchFormat(); + return expect(`"abc\\n"`).toMatchFormat(); }); test("interpolation within single quotes stay", () => { - expect(`'#{"\\n"}'`).toMatchFormat(); + return expect(`'#{"\\n"}'`).toMatchFormat(); }); test("interpolation within double quotes stay", () => { - expect(`"#{"\\n"}"`).toMatchFormat(); + return expect(`"#{"\\n"}"`).toMatchFormat(); }); }); }); describe("with %{} quotes", () => { test("matches correctly", () => { - expect("%{foo\\n#{bar}\\nbaz}").toMatchFormat(); + return expect("%{foo\\n#{bar}\\nbaz}").toMatchFormat(); }); }); test("concatenation", () => { - expect(`'abc' \\\n 'def' \\\n 'ghi'`).toMatchFormat(); + return expect(`"abc" \\\n "def" \\\n "ghi"`).toMatchFormat(); }); describe("interpolation", () => { test("with keywords", () => { - expect(`"abc #{super} abc"`).toMatchFormat(); + return expect(`"abc #{super} abc"`).toMatchFormat(); }); test("at the beginning of the string", () => { - expect(`"#{abc} abc"`).toMatchFormat(); + return expect(`"#{abc} abc"`).toMatchFormat(); }); test("very interpolated", () => { - expect(`"abc #{"abc #{abc} abc"} abc"`).toMatchFormat(); + return expect(`"abc #{"abc #{abc} abc"} abc"`).toMatchFormat(); }); test("long strings with interpolation do not break", () => { - expect(`"${long} #{foo[:bar]} ${long}"`).toMatchFormat(); + return expect(`"${long} #{foo[:bar]} ${long}"`).toMatchFormat(); }); test("long strings with interpolation that were broken do break", () => { @@ -149,7 +147,7 @@ describe("strings", () => { HERE `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("within a heredoc there is no indentation", () => { @@ -159,107 +157,93 @@ describe("strings", () => { HERE `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); }); describe("char literals", () => { test("single chars get changed", () => { - expect("?a").toChangeFormat("'a'"); + return expect("?a").toChangeFormat(`"a"`); }); test("single chars get changed with double quotes", () => { - expect("?a").toChangeFormat(`"a"`, { rubySingleQuote: false }); + return expect("?a").toChangeFormat(`"a"`); }); test("control escape sequences stay", () => { - expect("?\\C-a").toMatchFormat(); + return expect("?\\C-a").toMatchFormat(); }); test("meta escape sequences stay", () => { - expect("?\\M-a").toMatchFormat(); + return expect("?\\M-a").toMatchFormat(); }); test("meta and control sequences stay", () => { - expect("?\\M-\\C-a").toMatchFormat(); + return expect("?\\M-\\C-a").toMatchFormat(); }); }); describe("xstrings", () => { test("backtick literals", () => { - expect("`abc`").toMatchFormat(); + return expect("`abc`").toMatchFormat(); }); test("breaking backtick literals", () => { - expect(`\`${long}\``).toMatchFormat(); + return expect(`\`${long}\``).toMatchFormat(); }); test("breaking backtick literals with method chains", () => { - expect(`\`${long}\`.to_s`).toMatchFormat(); + return expect(`\`${long}\`.to_s`).toMatchFormat(); }); test("%x literals", () => { - expect("%x[abc]").toChangeFormat("`abc`"); + return expect("%x[abc]").toChangeFormat("`abc`"); }); test("breaking %x literals", () => { - expect(`%x[${long}]`).toChangeFormat(`\`${long}\``); + return expect(`%x[${long}]`).toChangeFormat(`\`${long}\``); }); test("breaking %x literals with method chains", () => { - expect(`%x[${long}].to_s`).toChangeFormat(`\`${long}\`.to_s`); + return expect(`%x[${long}].to_s`).toChangeFormat(`\`${long}\`.to_s`); }); }); describe("symbols", () => { test("basic", () => { - expect(":abc").toMatchFormat(); + return expect(":abc").toMatchFormat(); }); test("with single quotes", () => { - expect(":'abc'").toMatchFormat(); + return expect(":'abc'").toChangeFormat(`:"abc"`); }); test("with double quotes", () => { - expect(`:"abc"`).toChangeFormat(":'abc'"); + return expect(`:"abc"`).toMatchFormat(); }); test("with double quotes with double quotes desired", () => { - expect(`:"abc"`).toMatchFormat({ rubySingleQuote: false }); - }); - - test("with false interpolation and single quotes, no rubySingleQuote", () => { - expect(":'abc#{foo}abc'").toMatchFormat({ rubySingleQuote: false }); + return expect(`:"abc"`).toMatchFormat(); }); test("with real interpolation and double quotes", () => { - expect(`:"abc#{foo}abc"`).toMatchFormat(); - }); - - test("with real interpolation and double quotes, rubySingleQuote", () => { - expect(`:"abc#{foo}abc"`).toMatchFormat({ rubySingleQuote: true }); + return expect(`:"abc#{foo}abc"`).toMatchFormat(); }); test("%s literal", () => { - expect("%s[abc]").toChangeFormat(":'abc'"); + return expect("%s[abc]").toChangeFormat(`:"abc"`); }); test("%s literal with false interpolation", () => { - expect("%s[abc#{d}]").toChangeFormat(":'abc#{d}'"); + return expect("%s[abc#{d}]").toChangeFormat(`:'abc#{d}'`); }); test("%s literal as hash key", () => { - expect("{ %s[abc] => d }").toChangeFormat("{ 'abc': d }"); - }); - - test("%s literal as hash key, no rubySingleQuote", () => { - expect("{ %s[abc] => d }").toChangeFormat(`{ "abc": d }`, { - rubySingleQuote: false - }); + return expect("{ %s[abc] => d }").toChangeFormat(`{ abc: d }`); }); test("symbol literal as a hash key", () => { - expect("{ '\\d' => 1 }").toMatchFormat(); + return expect("{ '\\d' => 1 }").toMatchFormat(); }); test("%s literal with newlines", () => { @@ -269,17 +253,17 @@ describe("strings", () => { ] `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("gets correct quotes", () => { - const content = "where('lint_tool_configs.plugin': plugins + %w[core])"; + const content = `where("lint_tool_configs.plugin": plugins + %w[core])`; - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); }); test.each(["@v", "@@v", "$v"])("%s dvar", (interp) => { - expect(`"#${interp}"`).toChangeFormat(`"#{${interp}}"`); + return expect(`"#${interp}"`).toChangeFormat(`"#{${interp}}"`); }); }); diff --git a/test/js/ruby/nodes/super.test.ts b/test/js/ruby/nodes/super.test.js similarity index 56% rename from test/js/ruby/nodes/super.test.ts rename to test/js/ruby/nodes/super.test.js index 76a9cd62..1b66b025 100644 --- a/test/js/ruby/nodes/super.test.ts +++ b/test/js/ruby/nodes/super.test.js @@ -1,49 +1,49 @@ -import { ruby } from "../../utils"; +import { ruby } from "../../utils.js"; describe("super", () => { test("bare", () => { - expect("super").toMatchFormat(); + return expect("super").toMatchFormat(); }); test("empty parens", () => { - expect("super()").toMatchFormat(); + return expect("super()").toMatchFormat(); }); test("one arg, no parens", () => { - expect("super 1").toMatchFormat(); + return expect("super 1").toMatchFormat(); }); test("one arg, with parens", () => { - expect("super(1)").toMatchFormat(); + return expect("super(1)").toMatchFormat(); }); test("multiple args, no parens", () => { - expect("super 1, 2").toMatchFormat(); + return expect("super 1, 2").toMatchFormat(); }); test("multiple args, with parens", () => { - expect("super(1, 2)").toMatchFormat(); + return expect("super(1, 2)").toMatchFormat(); }); describe("with comments", () => { test("bare", () => { - expect("super # comment").toMatchFormat(); + return expect("super # comment").toMatchFormat(); }); test("empty parens", () => { - expect("super() # comment").toMatchFormat(); + return expect("super() # comment").toMatchFormat(); }); test("one arg, no parens", () => { - expect("super 1 # comment").toMatchFormat(); + return expect("super 1 # comment").toMatchFormat(); }); test("one arg, with parens", () => { - expect("super(1) # comment").toMatchFormat(); + return expect("super(1) # comment").toMatchFormat(); }); test("multiple args, no parens", () => { - expect("super 1, 2 # comment").toMatchFormat(); + return expect("super 1, 2 # comment").toMatchFormat(); }); test("multiple args, multiple lines, no parens", () => { @@ -52,11 +52,11 @@ describe("super", () => { 2 # second comment `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("multiple args, with parens", () => { - expect("super(1, 2) # comment").toMatchFormat(); + return expect("super(1, 2) # comment").toMatchFormat(); }); test("multiple args, multiple lines, no parens", () => { @@ -67,7 +67,7 @@ describe("super", () => { ) `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); }); }); diff --git a/test/js/ruby/nodes/unary.test.ts b/test/js/ruby/nodes/unary.test.js similarity index 63% rename from test/js/ruby/nodes/unary.test.ts rename to test/js/ruby/nodes/unary.test.js index cebf7b98..8f619b74 100644 --- a/test/js/ruby/nodes/unary.test.ts +++ b/test/js/ruby/nodes/unary.test.js @@ -1,10 +1,10 @@ describe("unary", () => { test("regular", () => { - expect("!foo").toMatchFormat(); + return expect("!foo").toMatchFormat(); }); // https://github.com/prettier/plugin-ruby/issues/764 test("with other operator", () => { - expect("!(x&.>(0))").toMatchFormat(); + return expect("!(x&.>(0))").toMatchFormat(); }); }); diff --git a/test/js/ruby/nodes/undef.test.ts b/test/js/ruby/nodes/undef.test.js similarity index 59% rename from test/js/ruby/nodes/undef.test.ts rename to test/js/ruby/nodes/undef.test.js index fb4f81c1..3716cab6 100644 --- a/test/js/ruby/nodes/undef.test.ts +++ b/test/js/ruby/nodes/undef.test.js @@ -1,12 +1,12 @@ -import { long, ruby } from "../../utils"; +import { long, ruby } from "../../utils.js"; describe("undef", () => { test("single inline", () => { - expect("undef foo").toMatchFormat(); + return expect("undef foo").toMatchFormat(); }); test("multiple inline", () => { - expect("undef foo, bar").toMatchFormat(); + return expect("undef foo, bar").toMatchFormat(); }); test("multiple breaking", () => { @@ -15,15 +15,15 @@ describe("undef", () => { a${long} `); - expect(`undef ${long}, a${long}`).toChangeFormat(expected); + return expect(`undef ${long}, a${long}`).toChangeFormat(expected); }); test("single with comment", () => { - expect("undef foo # bar").toMatchFormat(); + return expect("undef foo # bar").toMatchFormat(); }); test("multiple inline with comment", () => { - expect("undef foo, bar # baz").toMatchFormat(); + return expect("undef foo, bar # baz").toMatchFormat(); }); test("multiple lines comment on first", () => { @@ -32,7 +32,7 @@ describe("undef", () => { bar `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("multiple lines comment on each", () => { @@ -41,7 +41,7 @@ describe("undef", () => { bar # bam `); - expect(content).toMatchFormat(); + return expect(content).toMatchFormat(); }); test("multiple breaking with comment", () => { @@ -50,6 +50,6 @@ describe("undef", () => { a${long} # foo `); - expect(`undef ${long}, a${long} # foo`).toChangeFormat(expected); + return expect(`undef ${long}, a${long} # foo`).toChangeFormat(expected); }); }); diff --git a/test/js/ruby/nodes/yield.test.ts b/test/js/ruby/nodes/yield.test.js similarity index 57% rename from test/js/ruby/nodes/yield.test.ts rename to test/js/ruby/nodes/yield.test.js index f6bafbeb..5ac27496 100644 --- a/test/js/ruby/nodes/yield.test.ts +++ b/test/js/ruby/nodes/yield.test.js @@ -1,21 +1,21 @@ describe("yield", () => { test("bare yield", () => { - expect("yield").toMatchFormat(); + return expect("yield").toMatchFormat(); }); test("yield with one argument, no parens", () => { - expect("yield i").toMatchFormat(); + return expect("yield i").toMatchFormat(); }); test("yield with one argument, with parens", () => { - expect("yield(i)").toMatchFormat(); + return expect("yield(i)").toMatchFormat(); }); test("yield with multiple arguments, no parens", () => { - expect("yield i, 2").toMatchFormat(); + return expect("yield i, 2").toMatchFormat(); }); test("yield with multiple arguments, with parens", () => { - expect("yield(i, 2)").toMatchFormat(); + return expect("yield(i, 2)").toMatchFormat(); }); }); diff --git a/test/js/ruby/pragma.test.ts b/test/js/ruby/pragma.test.ts deleted file mode 100644 index b763f3e0..00000000 --- a/test/js/ruby/pragma.test.ts +++ /dev/null @@ -1,46 +0,0 @@ -import parser from "../../../src/ruby/parser"; -import printer from "../../../src/ruby/printer"; -import { ruby } from "../utils"; - -describe("pragma", () => { - describe("hasPragma", () => { - test("checks for @prettier comments", () => { - expect(parser.hasPragma("# @prettier")).toBe(true); - }); - - test("checks for @format comments", () => { - expect(parser.hasPragma("# @format")).toBe(true); - }); - - test("does not check for anything else", () => { - expect(parser.hasPragma("# @foobar")).toBe(false); - }); - - test("works when the comment is not on the first line", () => { - const content = ruby(` - # typed: true - # @format - `); - - expect(parser.hasPragma(content)).toBe(true); - }); - }); - - describe("insertPragma", () => { - test("inserts normally", () => { - const content = "foo + bar"; - - expect(printer.insertPragma(content)).toEqual(`# @format\n\n${content}`); - }); - - test("inserts when there is already a comment at the top", () => { - const content = ruby(` - # frozen_string_literal: true - - foo - `); - - expect(printer.insertPragma(content)).toEqual(`# @format\n${content}`); - }); - }); -}); diff --git a/test/js/ruby/toProc.test.ts b/test/js/ruby/toProc.test.ts deleted file mode 100644 index a10b746c..00000000 --- a/test/js/ruby/toProc.test.ts +++ /dev/null @@ -1,210 +0,0 @@ -import { ruby } from "../utils"; - -describe("to_proc transform", () => { - test("basic inline", () => { - expect("loop { |i| i.to_s }").toChangeFormat("loop(&:to_s)", { - rubyToProc: true - }); - }); - - test("basic inline with option turned off", () => { - expect("loop { |i| i.to_s }").toMatchFormat({ rubyToProc: false }); - }); - - test("basic multi-line", () => { - const content = ruby(` - list.each do |node| - node.print - end - `); - - expect(content).toChangeFormat("list.each(&:print)", { - rubyToProc: true - }); - }); - - test("maintains to_proc if already in use when rubyToProc false", () => { - expect("loop(&:to_s)").toMatchFormat({ rubyToProc: false }); - }); - - test("maintains to_proc if already in use when rubyToProc true", () => { - expect("loop(&:to_s)").toMatchFormat({ rubyToProc: true }); - }); - - test("multi-line with comment", () => { - const content = ruby(` - foo.each do |bar| - # comment - bar.baz - end - `); - - expect(content).toMatchFormat({ rubyToProc: true }); - }); - - test("happens for command nodes", () => { - const content = ruby(` - command 'foo' do |bar| - bar.to_s - end - `); - - expect(content).toChangeFormat("command 'foo', &:to_s", { - rubyToProc: true - }); - }); - - test("happens for command call nodes", () => { - const content = ruby(` - command.call 'foo' do |bar| - bar.to_s - end - `); - - expect(content).toChangeFormat("command.call 'foo', &:to_s", { - rubyToProc: true - }); - }); - - test("with args and parens", () => { - expect("foo(bar) { |baz| baz.to_i }").toChangeFormat("foo(bar, &:to_i)", { - rubyToProc: true - }); - }); - - test("with commands", () => { - const content = ruby(` - command bar do |baz| - baz.to_i - end - `); - - expect(content).toChangeFormat("command bar, &:to_i", { - rubyToProc: true - }); - }); - - test("with command calls", () => { - const content = ruby(` - command.call bar do |baz| - baz.to_i - end - `); - - expect(content).toChangeFormat("command.call bar, &:to_i", { - rubyToProc: true - }); - }); - - test("when inside of an aref node", () => { - const content = "foo[:bar].each { |baz| baz.to_s }"; - const expected = "foo[:bar].each(&:to_s)"; - - expect(content).toChangeFormat(expected, { rubyToProc: true }); - }); - - describe("when not to transform", () => { - test("when called with &.", () => { - const content = "loop { |i| i&.to_s }"; - - expect(content).toMatchFormat({ rubyToProc: true }); - }); - - test("when there are multiple lines", () => { - const content = ruby(` - loop do |i| - i.to_s - i.next - end - `); - - expect(content).toMatchFormat({ rubyToProc: true }); - }); - - test("when there is a rescue, else, or ensure", () => { - const content = ruby(` - loop do |i| - i.to_s - rescue Foo - foo - end - `); - - expect(content).toMatchFormat({ rubyToProc: true }); - }); - - test("when there are args to the method call", () => { - const content = "loop { |i| i.to_s(:db) }"; - - expect(content).toMatchFormat({ rubyToProc: true }); - }); - - test("when there are multiple args", () => { - const content = "loop { |i, j| i.to_s }"; - - expect(content).toMatchFormat({ rubyToProc: true }); - }); - - test("when we're inside an if:", () => { - const content = "{ if: proc { |i| i.to_s } }"; - - expect(content).toMatchFormat({ rubyToProc: true }); - }); - - test("when we're inside an :if =>", () => { - const content = "{ :if => proc { |i| i.to_s } }"; - const expected = "{ if: proc { |i| i.to_s } }"; - - expect(content).toChangeFormat(expected, { rubyToProc: true }); - }); - - test("when we're inside a regular hash", () => { - const content = "{ when: proc { |i| i.to_s } }"; - const expected = "{ when: proc(&:to_s) }"; - - expect(content).toChangeFormat(expected, { rubyToProc: true }); - }); - - test("when we're inside a regular hash", () => { - const content = "{ when: proc { |i| i.to_s } }"; - const expected = "{ when: proc(&:to_s) }"; - - expect(content).toChangeFormat(expected, { rubyToProc: true }); - }); - - test("when there are no variables", () => { - expect("loop { i.to_s }").toMatchFormat({ rubyToProc: true }); - }); - }); - - describe.each(["if", "unless"])( - "does not transform when used inside hash with %s", - (keyword) => { - test(`hash literal with :${keyword} key`, () => { - expect(`{ ${keyword}: ->(foo) { foo.to_s } }`).toMatchFormat({ - rubyToProc: true - }); - }); - - test(`hash literal with hashrocket :${keyword} key`, () => { - expect(`{ :${keyword} => ->(foo) { foo.to_s } }`).toMatchFormat({ - rubyHashLabel: false, - rubyToProc: true - }); - }); - - test(`method arguments with :${keyword} key`, () => { - expect(`bar ${keyword}: ->(foo) { foo.to_s }`).toMatchFormat({ - rubyToProc: true - }); - }); - - test(`method arguments with hashrocket :${keyword} key`, () => { - expect(`bar :${keyword} => ->(foo) { foo.to_s }`).toMatchFormat({ - rubyHashLabel: false, - rubyToProc: true - }); - }); - } - ); -}); diff --git a/test/js/setupTests.js b/test/js/setupTests.js new file mode 100644 index 00000000..c0459fb0 --- /dev/null +++ b/test/js/setupTests.js @@ -0,0 +1,32 @@ +import { format } from "prettier"; +import plugin from "../../src/plugin.js"; + +function normalize(code) { + const string = typeof code === "string" ? code : code.code; + return string.replace(/\r?\n/g, "\n").trim(); +} + +async function checkFormat(before, after) { + const originalText = typeof before === "string" ? before : before.code; + const formatted = await format(originalText, { + parser: typeof before === "string" ? "ruby" : before.parser, + plugins: [plugin] + }); + + const expected = normalize(after); + const received = normalize(formatted); + + return { + pass: received === expected, + message: () => `Expected:\n${expected}\nReceived:\n${received}` + }; +} + +expect.extend({ + toChangeFormat(before, after) { + return checkFormat(before, after); + }, + toMatchFormat(before) { + return checkFormat(before, before); + } +}); diff --git a/test/js/setupTests.ts b/test/js/setupTests.ts deleted file mode 100644 index d6bb28d5..00000000 --- a/test/js/setupTests.ts +++ /dev/null @@ -1,50 +0,0 @@ -import prettier from "prettier"; - -import type { Plugin } from "../../src/types"; -import type { Code } from "./types"; -import plugin from "../../src/plugin"; - -type Config = Partial; - -function normalize(code: Code) { - const string = typeof code === "string" ? code : code.code; - return string.replace(/\r?\n/g, "\n").trim(); -} - -function checkFormat(before: Code, after: Code, config: Config) { - const originalText = typeof before === "string" ? before : before.code; - const formatted = prettier.format(originalText, { - parser: typeof before === "string" ? "ruby" : before.parser, - originalText, - plugins: [plugin as any as string], - ...config - }); - - const expected = normalize(after); - const received = normalize(formatted); - - return { - pass: received === expected, - message: () => `Expected:\n${expected}\nReceived:\n${received}` - }; -} - -expect.extend({ - toChangeFormat(before: Code, after: Code, config: Config = {}) { - return checkFormat(before, after, config); - }, - toMatchFormat(before: Code, config: Config = {}) { - return checkFormat(before, before, config); - } -}); - -declare global { - // eslint-disable-next-line @typescript-eslint/no-namespace - namespace jest { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - interface Matchers { - toChangeFormat(after: Code, config?: Config): CustomMatcherResult; - toMatchFormat(config?: Config): CustomMatcherResult; - } - } -} diff --git a/test/js/types.ts b/test/js/types.ts deleted file mode 100644 index 26de5835..00000000 --- a/test/js/types.ts +++ /dev/null @@ -1,4 +0,0 @@ -export type Code = - | string - | { code: string; parser: "rbs" } - | { code: string; parser: "haml" }; diff --git a/test/js/utils.ts b/test/js/utils.js similarity index 75% rename from test/js/utils.ts rename to test/js/utils.js index 2d0f0242..8ca50d04 100644 --- a/test/js/utils.ts +++ b/test/js/utils.js @@ -1,8 +1,6 @@ -import type { Code } from "./types"; - export const long = Array(80).fill("a").join(""); -function stripLeadingWhitespace(code: string) { +function stripLeadingWhitespace(code) { if (!code.includes("\n")) { return code; } @@ -15,15 +13,15 @@ function stripLeadingWhitespace(code: string) { return content.map((line) => line.slice(indent)).join("\n"); } -export function ruby(code: string) { +export function ruby(code) { return stripLeadingWhitespace(code); } -export function rbs(code: string): Code { +export function rbs(code) { return { code: stripLeadingWhitespace(code), parser: "rbs" }; } -export function haml(code: string): Code { +export function haml(code) { return { code: stripLeadingWhitespace(code), parser: "haml" }; } @@ -32,10 +30,10 @@ export function haml(code: string): Code { // should be always available. TypeScript doesn't know that though, so we // explicitly allow it to be undefined by coalescing with the empty string. -export function atLeastVersion(version: string) { +export function atLeastVersion(version) { return (process.env.RUBY_VERSION || "") >= version; } -export function atMostVersion(version: string) { +export function atMostVersion(version) { return (process.env.RUBY_VERSION || "") < version; } diff --git a/test/rb/metadata_test.rb b/test/rb/metadata_test.rb deleted file mode 100644 index 815839b1..00000000 --- a/test/rb/metadata_test.rb +++ /dev/null @@ -1,829 +0,0 @@ -# frozen_string_literal: true - -require 'test_helper' - -class MetadataTest < Minitest::Test - def test_BEGIN - assert_metadata :BEGIN, <<~SOURCE - BEGIN { - } - SOURCE - end - - def test_END - assert_metadata :END, <<~SOURCE - END { - } - SOURCE - end - - def test_alias - assert_metadata :alias, 'alias foo bar' - end - - def test_array_args - assert_metadata :array, <<~SOURCE - [ - foo, - bar, - baz - ] - SOURCE - end - - def test_array_args_add_star - assert_metadata :array, <<~SOURCE - [ - foo, - *bar, - baz - ] - SOURCE - end - - def test_array_qwords - assert_metadata :array, <<~SOURCE - %w[ - foo - bar - baz - ] - SOURCE - end - - def test_aref - assert_metadata :aref, 'foo[bar]' - end - - def test_aref_field - assert_node_metadata( - :aref_field, - parse('foo[bar] = baz').dig(:body, 0), - sc: 0, - ec: 8 - ) - end - - def test_args - assert_node_metadata( - :args, - parse('foo bar, baz').dig(:body, 1, :body, 0), - sc: 4, - ec: 12 - ) - end - - def test_args_add_block - assert_node_metadata( - :args_add_block, - parse('foo bar, baz').dig(:body, 1), - sc: 4, - ec: 12 - ) - end - - def test_args_add_star - assert_node_metadata( - :args_add_star, - parse('foo *bar').dig(:body, 1, :body, 0), - sc: 4, - ec: 8 - ) - end - - def test_arg_paren - content = <<~SOURCE - foo( - a, - b, - c - ) - SOURCE - - assert_node_metadata( - :arg_paren, - parse(content).dig(:body, 1), - sc: 3, - ec: 20 - ) - end - - def test_assign - assert_metadata :assign, 'foo = bar' - end - - def test_assoc_new - assert_node_metadata( - :assoc_new, - parse('{ foo: bar, bar: baz }').dig(:body, 0, :body, 0), - sc: 2, - ec: 10 - ) - end - - def test_assoc_splat - assert_node_metadata( - :assoc_splat, - parse('foo **bar').dig(:body, 1, :body, 0, :body, 0, :body, 0), - sc: 4, - ec: 9 - ) - end - - def test_assoclist_from_args - assert_node_metadata( - :assoclist_from_args, - parse('{ foo => bar }').dig(:body, 0), - sc: 1, - ec: 13 - ) - end - - def test_bare_assoc_hash - assert_node_metadata( - :bare_assoc_hash, - parse('foo(bar: baz)').dig(:body, 1, :body, 0, :body, 0, :body, 0), - sc: 4, - ec: 12 - ) - end - - def test_begin - assert_metadata :begin, <<~SOURCE - begin - begin; end - end - SOURCE - end - - def test_binary - assert_metadata :binary, 'foo + bar' - end - - def test_blockarg - assert_node_metadata( - :blockarg, - parse('def foo(&bar) end').dig(:body, 1, :body, 0, :body, 6), - sc: 8, - ec: 12 - ) - end - - def test_block_var - assert_node_metadata( - :block_var, - parse('foo { |bar| }').dig(:body, 1, :body, 0), - sc: 6, - ec: 11 - ) - end - - def test_bodystmt - assert_node_metadata( - :bodystmt, - parse('class Foo; def foo; end; end').dig(:body, 2), - sc: 9, - ec: 25 - ) - end - - def test_brace_block - assert_node_metadata( - :brace_block, - parse('foo { bar }').dig(:body, 1), - sc: 4, - ec: 11 - ) - end - - def test_break - assert_metadata :break, 'break foo' - end - - def test_call - assert_metadata :call, 'foo.bar' - end - - def test_case - assert_metadata :case, <<~SOURCE - case foo - when bar - case baz - when qux - end - end - SOURCE - end - - def test_class - assert_metadata :class, <<~SOURCE - class Foo - class Bar; end - end - SOURCE - end - - def test_command - assert_metadata :command, 'foo bar' - end - - def test_command_call - assert_metadata :command_call, 'foo.bar baz' - end - - def test_const_ref - assert_node_metadata( - :const_ref, - parse('class Foo; end').dig(:body, 0), - sc: 6, - ec: 9 - ) - end - - def test_const_path_field - assert_node_metadata( - :const_path_field, - parse('Foo::Bar = baz').dig(:body, 0), - sc: 0, - ec: 8 - ) - end - - def test_const_path_ref - assert_metadata :const_path_ref, 'Foo::Bar' - end - - def test_def - assert_metadata :def, <<~SOURCE - def foo - def bar; end - end - SOURCE - end - - def test_defined - assert_metadata :defined, <<~SOURCE - defined?( - Foo - ) - SOURCE - end - - def test_defs - assert_metadata :defs, <<~SOURCE - def Object.foo - def Object.bar; end - end - SOURCE - end - - def test_do_block - assert_node_metadata( - :do_block, - parse('foo do; bar; end').dig(:body, 1), - sc: 4, - ec: 16 - ) - end - - def test_dot2 - assert_metadata :dot2, 'foo..bar' - end - - def test_dot3 - assert_metadata :dot3, 'foo...bar' - end - - def test_dyna_symbol - assert_metadata :dyna_symbol, ':"foo #{bar} baz"' - end - - def test_else - content = <<~SOURCE - if foo - bar - else - baz - end - SOURCE - - assert_node_metadata(:else, parse(content).dig(:body, 2), sc: 13, ec: 27) - end - - def test_elsif - content = <<~SOURCE - if foo - bar - elsif bar - qux - end - SOURCE - - assert_node_metadata(:elsif, parse(content).dig(:body, 2), sc: 13, ec: 32) - end - - def test_ensure - content = <<~SOURCE - begin - foo - ensure - bar - end - SOURCE - - assert_node_metadata( - :ensure, - parse(content).dig(:body, 0, :body, 3), - sc: 12, - ec: 28 - ) - end - - if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.6') - def test_excessed_comma - assert_node_metadata( - :excessed_comma, - parse('foo { |bar,| }').dig(:body, 1, :body, 0, :body, 0, :body, 2), - sc: 10, - ec: 11 - ) - end - end - - def test_fcall - assert_node_metadata(:fcall, parse('foo(bar)').dig(:body, 0), sc: 0, ec: 3) - end - - def test_field - assert_node_metadata( - :field, - parse('foo.bar = baz').dig(:body, 0), - sc: 0, - ec: 7 - ) - end - - def test_for - assert_metadata :for, <<~SOURCE - for foo in bar do - for baz in qux do - end - end - SOURCE - end - - def test_hash - assert_metadata :hash, <<~SOURCE - { - foo: 'bar' - } - SOURCE - end - - def test_if - assert_metadata :if, <<~SOURCE - if foo - if bar; end - end - SOURCE - end - - def test_ifop - assert_metadata :ifop, 'foo ? bar : baz' - end - - def test_if_mod - assert_metadata :if_mod, 'foo if bar' - end - - def test_kwrest_param - assert_node_metadata( - :kwrest_param, - parse('def foo(**bar); end').dig(:body, 1, :body, 0, :body, 5), - sc: 8, - ec: 13 - ) - end - - def test_lambda - assert_metadata :lambda, <<~SOURCE - -> (foo, bar) { - foo + bar - } - SOURCE - end - - def test_massign - assert_metadata :massign, 'foo, bar, baz = 1, 2, 3' - end - - def test_method_add_arg - assert_metadata :method_add_arg, 'foo(bar)' - end - - def test_method_add_block - assert_metadata :method_add_block, 'foo { bar }' - end - - def test_mlhs - assert_node_metadata( - :mlhs, - parse('foo, bar, baz = 1, 2, 3').dig(:body, 0), - sc: 0, - ec: 13 - ) - end - - def test_mlhs_add_post - assert_node_metadata( - :mlhs_add_post, - parse('foo, *bar, baz = 1, 2, 3').dig(:body, 0), - sc: 5, - ec: 14 - ) - end - - def test_mlhs_add_star - assert_node_metadata( - :mlhs_add_star, - parse('foo, *bar = 1, 2, 3').dig(:body, 0), - sc: 5, - ec: 9 - ) - end - - def test_mlhs_paren - assert_node_metadata( - :mlhs_paren, - parse('(foo, bar) = baz').dig(:body, 0), - sc: 0, - ec: 10 - ) - end - - def test_module - assert_metadata :module, <<~SOURCE - module Foo - module Bar; end - end - SOURCE - end - - def test_mrhs_add_star - assert_node_metadata( - :mrhs_add_star, - parse('foo, bar = *baz').dig(:body, 1), - sc: 11, - ec: 15 - ) - end - - def test_mrhs_new_from_args - assert_node_metadata( - :mrhs_new_from_args, - parse('foo, bar, baz = 1, 2, 3').dig(:body, 1), - sc: 16, - ec: 23 - ) - end - - def test_next - assert_metadata :next, 'next foo' - end - - def test_opassign - assert_metadata :opassign, 'foo ||= bar' - end - - def test_params - content = <<~SOURCE - def foo( - bar, - baz - ); end - SOURCE - - assert_node_metadata( - :params, - parse(content).dig(:body, 1, :body, 0), - sc: 8, - ec: 22 - ) - end - - def test_paren - assert_metadata :paren, '()' - end - - def test_qsymbols - assert_node_metadata( - :qsymbols, - parse('%i[foo bar baz]').dig(:body, 0), - sc: 0, - ec: 15 - ) - end - - def test_qwords - assert_node_metadata( - :qwords, - parse('%w[foo bar baz]').dig(:body, 0), - sc: 0, - ec: 15 - ) - end - - def test_redo - assert_metadata :redo, 'redo' - end - - def test_regexp_literal - assert_metadata :regexp_literal, '/foo/' - assert_metadata :regexp_literal, '%r{foo}' - assert_metadata :regexp_literal, '%r(foo)' - - assert_node_metadata( - :regexp_literal, - parse('%r(foo)'), - beging: '%r(', - ending: ')' - ) - end - - def test_rescue - assert_node_metadata( - :rescue, - parse('begin; foo; rescue => bar; baz; end').dig(:body, 0, :body, 1), - sc: 12, - ec: 35 - ) - end - - def test_rescue_mod - assert_metadata :rescue_mod, 'foo rescue bar' - end - - def test_rest_param - assert_node_metadata( - :rest_param, - parse('def foo(*bar); end').dig(:body, 1, :body, 0, :body, 2), - sc: 8, - ec: 12 - ) - end - - def test_retry - assert_metadata :retry, 'retry' - end - - def test_return - assert_metadata :return, 'return foo' - end - - def test_return0 - assert_metadata :return0, 'return' - end - - def test_sclass - assert_metadata :sclass, <<~SOURCE - class << Foo - class << Bar; end - end - SOURCE - end - - def test_string_concat - assert_metadata :string_concat, <<~SOURCE - 'foo' \ - 'bar' - SOURCE - end - - def test_string_dvar - assert_node_metadata( - :string_dvar, - parse('"#$foo"').dig(:body, 0), - sc: 1, - ec: 6 - ) - end - - def test_string_embexpr - assert_node_metadata( - :string_embexpr, - parse('"foo #{bar} baz"').dig(:body, 1), - sc: 5, - ec: 11 - ) - end - - def test_string_literal - assert_metadata :string_literal, '"foo"' - end - - def test_super - assert_metadata :super, 'super foo' - end - - def test_symbol_literal - assert_metadata :symbol_literal, ':foo' - end - - def test_symbols - assert_node_metadata( - :symbols, - parse('%I[f#{o}o b#{a}r b#{a}z]').dig(:body, 0), - sc: 0, - ec: 24 - ) - end - - def test_top_const_field - assert_node_metadata( - :top_const_field, - parse('::Foo = bar').dig(:body, 0), - sc: 0, - ec: 5 - ) - end - - def test_top_const_ref - assert_metadata :top_const_ref, '::Foo' - end - - def test_unary - assert_metadata :unary, '-foo' - assert_metadata :unary, 'not foo' - end - - def test_undef - assert_metadata :undef, 'undef foo, bar' - end - - def test_unless - assert_metadata :unless, <<~SOURCE - unless foo - unless bar; end - end - SOURCE - end - - def test_unless_mod - assert_metadata :unless_mod, 'foo unless bar' - end - - def test_until - assert_metadata :until, <<~SOURCE - until foo - until bar; end - end - SOURCE - end - - def test_until_mod - assert_metadata :until_mod, 'foo until bar' - end - - def test_while - assert_metadata :while, <<~SOURCE - while foo - while bar; end - end - SOURCE - end - - def test_var_alias - assert_metadata :var_alias, 'alias $foo $bar' - end - - def test_var_field - assert_node_metadata( - :var_field, - parse('foo = 1').dig(:body, 0), - sc: 0, - ec: 3 - ) - end - - def test_var_ref - assert_metadata :var_ref, 'true' - end - - def test_vcall - assert_metadata :vcall, 'foo' - end - - def test_void_stmt - assert_node_metadata(:void_stmt, parse('; ;'), sc: 0, ec: 0) - end - - def test_when - assert_node_metadata( - :when, - parse('case foo; when bar; baz; end').dig(:body, 1), - sc: 10, - ec: 28 - ) - end - - def test_while_mod - assert_metadata :while_mod, 'foo while bar' - end - - def test_words - assert_node_metadata( - :words, - parse('%W[f#{o}o b#{a}r b#{a}z]').dig(:body, 0), - sc: 0, - ec: 24 - ) - end - - def test_xstring - assert_metadata :xstring_literal, <<~SOURCE - ` - foo - bar - ` - SOURCE - end - - def test_yield - assert_metadata :yield, 'yield foo' - end - - def test_yield0 - assert_metadata :yield0, 'yield' - end - - def test_zsuper - assert_metadata :zsuper, 'super' - end - - if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7') - def test_args_forward - content = <<~SOURCE - def foo(...) - bar(...) - end - SOURCE - - assert_node_metadata( - :args_forward, - parse(content).dig(:body, 1, :body, 0, :body, 2), - sc: 8, - ec: 11 - ) - end - - def test_aryptn - content = <<~SOURCE - case foo - in bar, baz - qux - end - SOURCE - - assert_node_metadata( - :aryptn, - parse(content).dig(:body, 1, :body, 0), - sc: 12, - ec: 20 - ) - end - - def test_in - content = <<~SOURCE - case foo - in bar - baz - end - SOURCE - - assert_node_metadata(:in, parse(content).dig(:body, 1), sc: 9, ec: 25) - end - end - - private - - def assert_metadata(type, ruby) - assert_node_metadata( - type, - parse(ruby), - sc: 0, - ec: ruby.chomp.size, - sl: 1, - el: [1, ruby.count("\n")].max - ) - end - - def assert_node_metadata(type, node, metadata) - assert_equal type, node[:type] - - metadata.each { |key, value| assert_equal value, node[key] } - end - - def parse(ruby) - Prettier::Parser.parse(ruby).dig(:body, 0, :body, 0) - end -end diff --git a/test/rb/parser_test.rb b/test/rb/parser_test.rb deleted file mode 100644 index f2a5dae7..00000000 --- a/test/rb/parser_test.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -require 'test_helper' - -class ParserTest < Minitest::Test - def test_events - # This is a list of all of the parser events that Ripper will emit - all_events = Ripper::PARSER_EVENTS - - # This is a list of all of the parser events for which we have an explicitly - # defined event handler in our parser. - handled_events = - Prettier::Parser.private_instance_methods.grep(/\Aon_(.+)/) { $1.to_sym } - - # Assert here that there are no missing events. - assert_empty(all_events - handled_events) - end -end diff --git a/test/rb/rake_test.rb b/test/rb/rake_test.rb index ab3335c3..65891544 100644 --- a/test/rb/rake_test.rb +++ b/test/rb/rake_test.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true -require 'test_helper' -require 'prettier/rake/task' +require "test_helper" +require "prettier/rake/task" class RakeTest < Minitest::Test Invoke = Struct.new(:args) def test_task - source_files = '{app,config,lib}/**/*.rb' + source_files = "{app,config,lib}/**/*.rb" Prettier::Rake::Task.new do |t| t.name = :format t.write = true @@ -16,9 +16,9 @@ def test_task invoke = nil Prettier.stub(:run, ->(args) { invoke = Invoke.new(args) }) do - Rake::Task['format'].invoke + Rake::Task["format"].invoke end - assert_equal ['--write', source_files], invoke.args + assert_equal ["--write", source_files], invoke.args end end diff --git a/test/rb/test_helper.rb b/test/rb/test_helper.rb index 4d77642c..f223f7f0 100644 --- a/test/rb/test_helper.rb +++ b/test/rb/test_helper.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true -$LOAD_PATH.unshift(File.expand_path('../../lib', __dir__)) +$LOAD_PATH.unshift(File.expand_path("../../lib", __dir__)) -require 'prettier' -require_relative '../../src/ruby/parser' - -require 'minitest/autorun' +require "prettier" +require "minitest/autorun" diff --git a/test/rb/version_test.rb b/test/rb/version_test.rb index 9d55356e..289590be 100644 --- a/test/rb/version_test.rb +++ b/test/rb/version_test.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'test_helper' +require "test_helper" class VersionTest < Minitest::Test def test_version diff --git a/tsconfig.build.json b/tsconfig.build.json deleted file mode 100644 index f4f4548c..00000000 --- a/tsconfig.build.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "./tsconfig.json", - "exclude": ["bin", "test"] -} diff --git a/tsconfig.json b/tsconfig.json deleted file mode 100644 index 043f24e5..00000000 --- a/tsconfig.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "compilerOptions": { - "allowJs": false, - "esModuleInterop": true, - "module": "commonjs", - "moduleResolution": "node", - "outDir": "dist", - "sourceMap": false, - "strict": true, - "target": "es2019" - } -} diff --git a/yarn.lock b/yarn.lock index c21ee788..dd883b5b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,184 +2,168 @@ # yarn lockfile v1 -"@babel/code-frame@7.12.11": - version "7.12.11" - resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.12.11.tgz#f4ad435aa263db935b8f10f2c552d23fb716a63f" - integrity sha512-Zt1yodBx1UcyiePMSkWnU4hPqhwq7hGi2nFL1LeA3EUl+q2LQx16MISgJ0+z7dnmgvP9QtIleuETGOiOH1RcIw== - dependencies: - "@babel/highlight" "^7.10.4" - -"@babel/code-frame@^7.12.13", "@babel/code-frame@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.14.5.tgz#23b08d740e83f49c5e59945fbf1b43e80bbf4edb" - integrity sha512-9pzDqyc6OLDaqe+zbACgFkb6fKMNG6CObKpnYXChRsvYGyEdc7CA2BaqeOM+vOtCS5ndmJicPJhKAwYRI6UfFw== - dependencies: - "@babel/highlight" "^7.14.5" - -"@babel/compat-data@^7.15.0": - version "7.15.0" - resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.15.0.tgz#2dbaf8b85334796cafbb0f5793a90a2fc010b176" - integrity sha512-0NqAC1IJE0S0+lL1SWFMxMkz1pKCNCjI4tr2Zx4LJSXxCLAdr6KyArnY+sno5m3yH9g737ygOyPABDsnXkpxiA== - -"@babel/core@^7.1.0", "@babel/core@^7.7.2", "@babel/core@^7.7.5": - version "7.15.5" - resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.15.5.tgz#f8ed9ace730722544609f90c9bb49162dc3bf5b9" - integrity sha512-pYgXxiwAgQpgM1bNkZsDEq85f0ggXMA5L7c+o3tskGMh2BunCI9QUwB9Z4jpvXUOuMdyGKiGKQiRe11VS6Jzvg== - dependencies: - "@babel/code-frame" "^7.14.5" - "@babel/generator" "^7.15.4" - "@babel/helper-compilation-targets" "^7.15.4" - "@babel/helper-module-transforms" "^7.15.4" - "@babel/helpers" "^7.15.4" - "@babel/parser" "^7.15.5" - "@babel/template" "^7.15.4" - "@babel/traverse" "^7.15.4" - "@babel/types" "^7.15.4" - convert-source-map "^1.7.0" +"@aashutoshrathi/word-wrap@^1.2.3": + version "1.2.6" + resolved "https://registry.yarnpkg.com/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz#bd9154aec9983f77b3a034ecaa015c2e4201f6cf" + integrity sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA== + +"@ampproject/remapping@^2.2.0": + version "2.2.1" + resolved "https://registry.yarnpkg.com/@ampproject/remapping/-/remapping-2.2.1.tgz#99e8e11851128b8702cd57c33684f1d0f260b630" + integrity sha512-lFMjJTrFL3j7L9yBxwYfCq2k6qqwHyzuUl/XBnif78PWTJYyL/dfowQHWE3sp6U6ZzqWiiIZnpTMO96zhkjwtg== + dependencies: + "@jridgewell/gen-mapping" "^0.3.0" + "@jridgewell/trace-mapping" "^0.3.9" + +"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.12.13", "@babel/code-frame@^7.22.13", "@babel/code-frame@^7.23.4": + version "7.23.4" + resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.23.4.tgz#03ae5af150be94392cb5c7ccd97db5a19a5da6aa" + integrity sha512-r1IONyb6Ia+jYR2vvIDhdWdlTGhqbBoFqLTQidzZ4kepUFH15ejXvFHxCVbtl7BOXIudsIubf4E81xeA3h3IXA== + dependencies: + "@babel/highlight" "^7.23.4" + chalk "^2.4.2" + +"@babel/compat-data@^7.22.9": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.23.3.tgz#3febd552541e62b5e883a25eb3effd7c7379db11" + integrity sha512-BmR4bWbDIoFJmJ9z2cZ8Gmm2MXgEDgjdWgpKmKWUt54UGFJdlj31ECtbaDvCG/qVdG3AQ1SfpZEs01lUFbzLOQ== + +"@babel/core@^7.11.6", "@babel/core@^7.12.3": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.23.3.tgz#5ec09c8803b91f51cc887dedc2654a35852849c9" + integrity sha512-Jg+msLuNuCJDyBvFv5+OKOUjWMZgd85bKjbICd3zWrKAo+bJ49HJufi7CQE0q0uR8NGyO6xkCACScNqyjHSZew== + dependencies: + "@ampproject/remapping" "^2.2.0" + "@babel/code-frame" "^7.22.13" + "@babel/generator" "^7.23.3" + "@babel/helper-compilation-targets" "^7.22.15" + "@babel/helper-module-transforms" "^7.23.3" + "@babel/helpers" "^7.23.2" + "@babel/parser" "^7.23.3" + "@babel/template" "^7.22.15" + "@babel/traverse" "^7.23.3" + "@babel/types" "^7.23.3" + convert-source-map "^2.0.0" debug "^4.1.0" gensync "^1.0.0-beta.2" - json5 "^2.1.2" - semver "^6.3.0" - source-map "^0.5.0" + json5 "^2.2.3" + semver "^6.3.1" -"@babel/generator@^7.15.4", "@babel/generator@^7.7.2": - version "7.15.4" - resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.15.4.tgz#85acb159a267ca6324f9793986991ee2022a05b0" - integrity sha512-d3itta0tu+UayjEORPNz6e1T3FtvWlP5N4V5M+lhp/CxT4oAA7/NcScnpRyspUMLK6tu9MNHmQHxRykuN2R7hw== +"@babel/generator@^7.23.3", "@babel/generator@^7.23.4", "@babel/generator@^7.7.2": + version "7.23.4" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.23.4.tgz#4a41377d8566ec18f807f42962a7f3551de83d1c" + integrity sha512-esuS49Cga3HcThFNebGhlgsrVLkvhqvYDTzgjfFFlHJcIfLe5jFmRRfCQ1KuBfc4Jrtn3ndLgKWAKjBE+IraYQ== dependencies: - "@babel/types" "^7.15.4" + "@babel/types" "^7.23.4" + "@jridgewell/gen-mapping" "^0.3.2" + "@jridgewell/trace-mapping" "^0.3.17" jsesc "^2.5.1" - source-map "^0.5.0" - -"@babel/helper-compilation-targets@^7.15.4": - version "7.15.4" - resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.15.4.tgz#cf6d94f30fbefc139123e27dd6b02f65aeedb7b9" - integrity sha512-rMWPCirulnPSe4d+gwdWXLfAXTTBj8M3guAf5xFQJ0nvFY7tfNAFnWdqaHegHlgDZOCT4qvhF3BYlSJag8yhqQ== - dependencies: - "@babel/compat-data" "^7.15.0" - "@babel/helper-validator-option" "^7.14.5" - browserslist "^4.16.6" - semver "^6.3.0" - -"@babel/helper-function-name@^7.15.4": - version "7.15.4" - resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.15.4.tgz#845744dafc4381a4a5fb6afa6c3d36f98a787ebc" - integrity sha512-Z91cOMM4DseLIGOnog+Z8OI6YseR9bua+HpvLAQ2XayUGU+neTtX+97caALaLdyu53I/fjhbeCnWnRH1O3jFOw== - dependencies: - "@babel/helper-get-function-arity" "^7.15.4" - "@babel/template" "^7.15.4" - "@babel/types" "^7.15.4" - -"@babel/helper-get-function-arity@^7.15.4": - version "7.15.4" - resolved "https://registry.yarnpkg.com/@babel/helper-get-function-arity/-/helper-get-function-arity-7.15.4.tgz#098818934a137fce78b536a3e015864be1e2879b" - integrity sha512-1/AlxSF92CmGZzHnC515hm4SirTxtpDnLEJ0UyEMgTMZN+6bxXKg04dKhiRx5Enel+SUA1G1t5Ed/yQia0efrA== - dependencies: - "@babel/types" "^7.15.4" - -"@babel/helper-hoist-variables@^7.15.4": - version "7.15.4" - resolved "https://registry.yarnpkg.com/@babel/helper-hoist-variables/-/helper-hoist-variables-7.15.4.tgz#09993a3259c0e918f99d104261dfdfc033f178df" - integrity sha512-VTy085egb3jUGVK9ycIxQiPbquesq0HUQ+tPO0uv5mPEBZipk+5FkRKiWq5apuyTE9FUrjENB0rCf8y+n+UuhA== - dependencies: - "@babel/types" "^7.15.4" - -"@babel/helper-member-expression-to-functions@^7.15.4": - version "7.15.4" - resolved "https://registry.yarnpkg.com/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.15.4.tgz#bfd34dc9bba9824a4658b0317ec2fd571a51e6ef" - integrity sha512-cokOMkxC/BTyNP1AlY25HuBWM32iCEsLPI4BHDpJCHHm1FU2E7dKWWIXJgQgSFiu4lp8q3bL1BIKwqkSUviqtA== - dependencies: - "@babel/types" "^7.15.4" - -"@babel/helper-module-imports@^7.15.4": - version "7.15.4" - resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.15.4.tgz#e18007d230632dea19b47853b984476e7b4e103f" - integrity sha512-jeAHZbzUwdW/xHgHQ3QmWR4Jg6j15q4w/gCfwZvtqOxoo5DKtLHk8Bsf4c5RZRC7NmLEs+ohkdq8jFefuvIxAA== - dependencies: - "@babel/types" "^7.15.4" - -"@babel/helper-module-transforms@^7.15.4": - version "7.15.7" - resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.15.7.tgz#7da80c8cbc1f02655d83f8b79d25866afe50d226" - integrity sha512-ZNqjjQG/AuFfekFTY+7nY4RgBSklgTu970c7Rj3m/JOhIu5KPBUuTA9AY6zaKcUvk4g6EbDXdBnhi35FAssdSw== - dependencies: - "@babel/helper-module-imports" "^7.15.4" - "@babel/helper-replace-supers" "^7.15.4" - "@babel/helper-simple-access" "^7.15.4" - "@babel/helper-split-export-declaration" "^7.15.4" - "@babel/helper-validator-identifier" "^7.15.7" - "@babel/template" "^7.15.4" - "@babel/traverse" "^7.15.4" - "@babel/types" "^7.15.6" - -"@babel/helper-optimise-call-expression@^7.15.4": - version "7.15.4" - resolved "https://registry.yarnpkg.com/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.15.4.tgz#f310a5121a3b9cc52d9ab19122bd729822dee171" - integrity sha512-E/z9rfbAOt1vDW1DR7k4SzhzotVV5+qMciWV6LaG1g4jeFrkDlJedjtV4h0i4Q/ITnUu+Pk08M7fczsB9GXBDw== - dependencies: - "@babel/types" "^7.15.4" - -"@babel/helper-plugin-utils@^7.0.0", "@babel/helper-plugin-utils@^7.10.4", "@babel/helper-plugin-utils@^7.12.13", "@babel/helper-plugin-utils@^7.14.5", "@babel/helper-plugin-utils@^7.8.0": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.14.5.tgz#5ac822ce97eec46741ab70a517971e443a70c5a9" - integrity sha512-/37qQCE3K0vvZKwoK4XU/irIJQdIfCJuhU5eKnNxpFDsOkgFaUAwbv+RYw6eYgsC0E4hS7r5KqGULUogqui0fQ== - -"@babel/helper-replace-supers@^7.15.4": - version "7.15.4" - resolved "https://registry.yarnpkg.com/@babel/helper-replace-supers/-/helper-replace-supers-7.15.4.tgz#52a8ab26ba918c7f6dee28628b07071ac7b7347a" - integrity sha512-/ztT6khaXF37MS47fufrKvIsiQkx1LBRvSJNzRqmbyeZnTwU9qBxXYLaaT/6KaxfKhjs2Wy8kG8ZdsFUuWBjzw== - dependencies: - "@babel/helper-member-expression-to-functions" "^7.15.4" - "@babel/helper-optimise-call-expression" "^7.15.4" - "@babel/traverse" "^7.15.4" - "@babel/types" "^7.15.4" - -"@babel/helper-simple-access@^7.15.4": - version "7.15.4" - resolved "https://registry.yarnpkg.com/@babel/helper-simple-access/-/helper-simple-access-7.15.4.tgz#ac368905abf1de8e9781434b635d8f8674bcc13b" - integrity sha512-UzazrDoIVOZZcTeHHEPYrr1MvTR/K+wgLg6MY6e1CJyaRhbibftF6fR2KU2sFRtI/nERUZR9fBd6aKgBlIBaPg== - dependencies: - "@babel/types" "^7.15.4" - -"@babel/helper-split-export-declaration@^7.15.4": - version "7.15.4" - resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.15.4.tgz#aecab92dcdbef6a10aa3b62ab204b085f776e257" - integrity sha512-HsFqhLDZ08DxCpBdEVtKmywj6PQbwnF6HHybur0MAnkAKnlS6uHkwnmRIkElB2Owpfb4xL4NwDmDLFubueDXsw== - dependencies: - "@babel/types" "^7.15.4" - -"@babel/helper-validator-identifier@^7.14.5", "@babel/helper-validator-identifier@^7.14.9", "@babel/helper-validator-identifier@^7.15.7": - version "7.15.7" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.15.7.tgz#220df993bfe904a4a6b02ab4f3385a5ebf6e2389" - integrity sha512-K4JvCtQqad9OY2+yTU8w+E82ywk/fe+ELNlt1G8z3bVGlZfn/hOcQQsUhGhW/N+tb3fxK800wLtKOE/aM0m72w== - -"@babel/helper-validator-option@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.14.5.tgz#6e72a1fff18d5dfcb878e1e62f1a021c4b72d5a3" - integrity sha512-OX8D5eeX4XwcroVW45NMvoYaIuFI+GQpA2a8Gi+X/U/cDUIRsV37qQfF905F0htTRCREQIB4KqPeaveRJUl3Ow== - -"@babel/helpers@^7.15.4": - version "7.15.4" - resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.15.4.tgz#5f40f02050a3027121a3cf48d497c05c555eaf43" - integrity sha512-V45u6dqEJ3w2rlryYYXf6i9rQ5YMNu4FLS6ngs8ikblhu2VdR1AqAd6aJjBzmf2Qzh6KOLqKHxEN9+TFbAkAVQ== - dependencies: - "@babel/template" "^7.15.4" - "@babel/traverse" "^7.15.4" - "@babel/types" "^7.15.4" -"@babel/highlight@^7.10.4", "@babel/highlight@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.14.5.tgz#6861a52f03966405001f6aa534a01a24d99e8cd9" - integrity sha512-qf9u2WFWVV0MppaL877j2dBtQIDgmidgjGk5VIMw3OadXvYaXn66U1BFlH2t4+t3i+8PhedppRv+i40ABzd+gg== - dependencies: - "@babel/helper-validator-identifier" "^7.14.5" - chalk "^2.0.0" +"@babel/helper-compilation-targets@^7.22.15": + version "7.22.15" + resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.22.15.tgz#0698fc44551a26cf29f18d4662d5bf545a6cfc52" + integrity sha512-y6EEzULok0Qvz8yyLkCvVX+02ic+By2UdOhylwUOvOn9dvYc9mKICJuuU1n1XBI02YWsNsnrY1kc6DVbjcXbtw== + dependencies: + "@babel/compat-data" "^7.22.9" + "@babel/helper-validator-option" "^7.22.15" + browserslist "^4.21.9" + lru-cache "^5.1.1" + semver "^6.3.1" + +"@babel/helper-environment-visitor@^7.22.20": + version "7.22.20" + resolved "https://registry.yarnpkg.com/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.20.tgz#96159db61d34a29dba454c959f5ae4a649ba9167" + integrity sha512-zfedSIzFhat/gFhWfHtgWvlec0nqB9YEIVrpuwjruLlXfUSnA8cJB0miHKwqDnQ7d32aKo2xt88/xZptwxbfhA== + +"@babel/helper-function-name@^7.23.0": + version "7.23.0" + resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.23.0.tgz#1f9a3cdbd5b2698a670c30d2735f9af95ed52759" + integrity sha512-OErEqsrxjZTJciZ4Oo+eoZqeW9UIiOcuYKRJA4ZAgV9myA+pOXhhmpfNCKjEH/auVfEYVFJ6y1Tc4r0eIApqiw== + dependencies: + "@babel/template" "^7.22.15" + "@babel/types" "^7.23.0" + +"@babel/helper-hoist-variables@^7.22.5": + version "7.22.5" + resolved "https://registry.yarnpkg.com/@babel/helper-hoist-variables/-/helper-hoist-variables-7.22.5.tgz#c01a007dac05c085914e8fb652b339db50d823bb" + integrity sha512-wGjk9QZVzvknA6yKIUURb8zY3grXCcOZt+/7Wcy8O2uctxhplmUPkOdlgoNhmdVee2c92JXbf1xpMtVNbfoxRw== + dependencies: + "@babel/types" "^7.22.5" + +"@babel/helper-module-imports@^7.22.15": + version "7.22.15" + resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.22.15.tgz#16146307acdc40cc00c3b2c647713076464bdbf0" + integrity sha512-0pYVBnDKZO2fnSPCrgM/6WMc7eS20Fbok+0r88fp+YtWVLZrp4CkafFGIp+W0VKw4a22sgebPT99y+FDNMdP4w== + dependencies: + "@babel/types" "^7.22.15" + +"@babel/helper-module-transforms@^7.23.3": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.23.3.tgz#d7d12c3c5d30af5b3c0fcab2a6d5217773e2d0f1" + integrity sha512-7bBs4ED9OmswdfDzpz4MpWgSrV7FXlc3zIagvLFjS5H+Mk7Snr21vQ6QwrsoCGMfNC4e4LQPdoULEt4ykz0SRQ== + dependencies: + "@babel/helper-environment-visitor" "^7.22.20" + "@babel/helper-module-imports" "^7.22.15" + "@babel/helper-simple-access" "^7.22.5" + "@babel/helper-split-export-declaration" "^7.22.6" + "@babel/helper-validator-identifier" "^7.22.20" + +"@babel/helper-plugin-utils@^7.0.0", "@babel/helper-plugin-utils@^7.10.4", "@babel/helper-plugin-utils@^7.12.13", "@babel/helper-plugin-utils@^7.14.5", "@babel/helper-plugin-utils@^7.22.5", "@babel/helper-plugin-utils@^7.8.0": + version "7.22.5" + resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.22.5.tgz#dd7ee3735e8a313b9f7b05a773d892e88e6d7295" + integrity sha512-uLls06UVKgFG9QD4OeFYLEGteMIAa5kpTPcFL28yuCIIzsf6ZyKZMllKVOCZFhiZ5ptnwX4mtKdWCBE/uT4amg== + +"@babel/helper-simple-access@^7.22.5": + version "7.22.5" + resolved "https://registry.yarnpkg.com/@babel/helper-simple-access/-/helper-simple-access-7.22.5.tgz#4938357dc7d782b80ed6dbb03a0fba3d22b1d5de" + integrity sha512-n0H99E/K+Bika3++WNL17POvo4rKWZ7lZEp1Q+fStVbUi8nxPQEBOlTmCOxW/0JsS56SKKQ+ojAe2pHKJHN35w== + dependencies: + "@babel/types" "^7.22.5" + +"@babel/helper-split-export-declaration@^7.22.6": + version "7.22.6" + resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.22.6.tgz#322c61b7310c0997fe4c323955667f18fcefb91c" + integrity sha512-AsUnxuLhRYsisFiaJwvp1QF+I3KjD5FOxut14q/GzovUe6orHLesW2C7d754kRm53h5gqrz6sFl6sxc4BVtE/g== + dependencies: + "@babel/types" "^7.22.5" + +"@babel/helper-string-parser@^7.23.4": + version "7.23.4" + resolved "https://registry.yarnpkg.com/@babel/helper-string-parser/-/helper-string-parser-7.23.4.tgz#9478c707febcbbe1ddb38a3d91a2e054ae622d83" + integrity sha512-803gmbQdqwdf4olxrX4AJyFBV/RTr3rSmOj0rKwesmzlfhYNDEs+/iOcznzpNWlJlIlTJC2QfPFcHB6DlzdVLQ== + +"@babel/helper-validator-identifier@^7.22.20": + version "7.22.20" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz#c4ae002c61d2879e724581d96665583dbc1dc0e0" + integrity sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A== + +"@babel/helper-validator-option@^7.22.15": + version "7.22.15" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.22.15.tgz#694c30dfa1d09a6534cdfcafbe56789d36aba040" + integrity sha512-bMn7RmyFjY/mdECUbgn9eoSY4vqvacUnS9i9vGAGttgFWesO6B4CYWA7XlpbWgBt71iv/hfbPlynohStqnu5hA== + +"@babel/helpers@^7.23.2": + version "7.23.4" + resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.23.4.tgz#7d2cfb969aa43222032193accd7329851facf3c1" + integrity sha512-HfcMizYz10cr3h29VqyfGL6ZWIjTwWfvYBMsBVGwpcbhNGe3wQ1ZXZRPzZoAHhd9OqHadHqjQ89iVKINXnbzuw== + dependencies: + "@babel/template" "^7.22.15" + "@babel/traverse" "^7.23.4" + "@babel/types" "^7.23.4" + +"@babel/highlight@^7.23.4": + version "7.23.4" + resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.23.4.tgz#edaadf4d8232e1a961432db785091207ead0621b" + integrity sha512-acGdbYSfp2WheJoJm/EBBBLh/ID8KDc64ISZ9DYtBmC8/Q204PZJLHyzeB5qMzJ5trcOkybd78M4x2KWsUq++A== + dependencies: + "@babel/helper-validator-identifier" "^7.22.20" + chalk "^2.4.2" js-tokens "^4.0.0" -"@babel/parser@^7.1.0", "@babel/parser@^7.15.4", "@babel/parser@^7.15.5", "@babel/parser@^7.7.2": - version "7.15.7" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.15.7.tgz#0c3ed4a2eb07b165dfa85b3cc45c727334c4edae" - integrity sha512-rycZXvQ+xS9QyIcJ9HXeDWf1uxqlbVFAUq0Rq0dbc50Zb/+wUe/ehyfzGfm9KZZF0kBejYgxltBXocP+gKdL2g== +"@babel/parser@^7.1.0", "@babel/parser@^7.14.7", "@babel/parser@^7.20.7", "@babel/parser@^7.22.15", "@babel/parser@^7.23.3", "@babel/parser@^7.23.4": + version "7.23.4" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.23.4.tgz#409fbe690c333bb70187e2de4021e1e47a026661" + integrity sha512-vf3Xna6UEprW+7t6EtOmFpHNAuxw3xqPZghy+brsnusscJRW5BMUzzHZc5ICjULee81WeUV2jjakG09MDglJXQ== "@babel/plugin-syntax-async-generators@^7.8.4": version "7.8.4" @@ -216,6 +200,13 @@ dependencies: "@babel/helper-plugin-utils" "^7.8.0" +"@babel/plugin-syntax-jsx@^7.7.2": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.23.3.tgz#8f2e4f8a9b5f9aa16067e142c1ac9cd9f810f473" + integrity sha512-EB2MELswq55OHUoRZLGg/zC7QWUKfNLpE57m/S2yr1uEneIgsTgrSzXP3NXEsMkVn76OlaVVnzN+ugObuYGwhg== + dependencies: + "@babel/helper-plugin-utils" "^7.22.5" + "@babel/plugin-syntax-logical-assignment-operators@^7.8.3": version "7.10.4" resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz#ca91ef46303530448b906652bac2e9fe9941f699" @@ -266,42 +257,44 @@ "@babel/helper-plugin-utils" "^7.14.5" "@babel/plugin-syntax-typescript@^7.7.2": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.14.5.tgz#b82c6ce471b165b5ce420cf92914d6fb46225716" - integrity sha512-u6OXzDaIXjEstBRRoBCQ/uKQKlbuaeE5in0RvWdA4pN6AhqxTIwUsnHPU1CFZA/amYObMsuWhYfRl3Ch90HD0Q== - dependencies: - "@babel/helper-plugin-utils" "^7.14.5" - -"@babel/template@^7.15.4", "@babel/template@^7.3.3": - version "7.15.4" - resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.15.4.tgz#51898d35dcf3faa670c4ee6afcfd517ee139f194" - integrity sha512-UgBAfEa1oGuYgDIPM2G+aHa4Nlo9Lh6mGD2bDBGMTbYnc38vulXPuC1MGjYILIEmlwl6Rd+BPR9ee3gm20CBtg== - dependencies: - "@babel/code-frame" "^7.14.5" - "@babel/parser" "^7.15.4" - "@babel/types" "^7.15.4" - -"@babel/traverse@^7.1.0", "@babel/traverse@^7.15.4", "@babel/traverse@^7.7.2": - version "7.15.4" - resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.15.4.tgz#ff8510367a144bfbff552d9e18e28f3e2889c22d" - integrity sha512-W6lQD8l4rUbQR/vYgSuCAE75ADyyQvOpFVsvPPdkhf6lATXAsQIG9YdtOcu8BB1dZ0LKu+Zo3c1wEcbKeuhdlA== - dependencies: - "@babel/code-frame" "^7.14.5" - "@babel/generator" "^7.15.4" - "@babel/helper-function-name" "^7.15.4" - "@babel/helper-hoist-variables" "^7.15.4" - "@babel/helper-split-export-declaration" "^7.15.4" - "@babel/parser" "^7.15.4" - "@babel/types" "^7.15.4" + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.23.3.tgz#24f460c85dbbc983cd2b9c4994178bcc01df958f" + integrity sha512-9EiNjVJOMwCO+43TqoTrgQ8jMwcAd0sWyXi9RPfIsLTj4R2MADDDQXELhffaUx/uJv2AYcxBgPwH6j4TIA4ytQ== + dependencies: + "@babel/helper-plugin-utils" "^7.22.5" + +"@babel/template@^7.22.15", "@babel/template@^7.3.3": + version "7.22.15" + resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.22.15.tgz#09576efc3830f0430f4548ef971dde1350ef2f38" + integrity sha512-QPErUVm4uyJa60rkI73qneDacvdvzxshT3kksGqlGWYdOTIUOwJ7RDUL8sGqslY1uXWSL6xMFKEXDS3ox2uF0w== + dependencies: + "@babel/code-frame" "^7.22.13" + "@babel/parser" "^7.22.15" + "@babel/types" "^7.22.15" + +"@babel/traverse@^7.23.3", "@babel/traverse@^7.23.4": + version "7.23.4" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.23.4.tgz#c2790f7edf106d059a0098770fe70801417f3f85" + integrity sha512-IYM8wSUwunWTB6tFC2dkKZhxbIjHoWemdK+3f8/wq8aKhbUscxD5MX72ubd90fxvFknaLPeGw5ycU84V1obHJg== + dependencies: + "@babel/code-frame" "^7.23.4" + "@babel/generator" "^7.23.4" + "@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.4" + "@babel/types" "^7.23.4" debug "^4.1.0" globals "^11.1.0" -"@babel/types@^7.0.0", "@babel/types@^7.15.4", "@babel/types@^7.15.6", "@babel/types@^7.3.0", "@babel/types@^7.3.3": - version "7.15.6" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.15.6.tgz#99abdc48218b2881c058dd0a7ab05b99c9be758f" - integrity sha512-BPU+7QhqNjmWyDO0/vitH/CuhpV8ZmK1wpKva8nuyNF5MJfuRNWMc+hc14+u9xT93kvykMdncrJT19h74uB1Ig== +"@babel/types@^7.0.0", "@babel/types@^7.20.7", "@babel/types@^7.22.15", "@babel/types@^7.22.5", "@babel/types@^7.23.0", "@babel/types@^7.23.3", "@babel/types@^7.23.4", "@babel/types@^7.3.3": + version "7.23.4" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.23.4.tgz#7206a1810fc512a7f7f7d4dace4cb4c1c9dbfb8e" + integrity sha512-7uIFwVYpoplT5jp/kVv6EF93VaJ8H+Yn5IczYiaAi98ajzjfoZfslet/e0sLh+wVBjb2qqIut1b0S26VSafsSQ== dependencies: - "@babel/helper-validator-identifier" "^7.14.9" + "@babel/helper-string-parser" "^7.23.4" + "@babel/helper-validator-identifier" "^7.22.20" to-fast-properties "^2.0.0" "@bcoe/v8-coverage@^0.2.3": @@ -309,46 +302,94 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@cspotcode/source-map-consumer@0.8.0": - version "0.8.0" - resolved "https://registry.yarnpkg.com/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz#33bf4b7b39c178821606f669bbc447a6a629786b" - integrity sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg== +"@eslint-community/eslint-utils@^4.2.0": + version "4.4.0" + resolved "https://registry.yarnpkg.com/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz#a23514e8fb9af1269d5f7788aa556798d61c6b59" + integrity sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA== + dependencies: + eslint-visitor-keys "^3.3.0" -"@cspotcode/source-map-support@0.7.0": - version "0.7.0" - resolved "https://registry.yarnpkg.com/@cspotcode/source-map-support/-/source-map-support-0.7.0.tgz#4789840aa859e46d2f3173727ab707c66bf344f5" - integrity sha512-X4xqRHqN8ACt2aHVe51OxeA2HjbcL4MqFqXkrmQszJ1NOUuUu5u6Vqx/0lZSVNku7velL5FC/s5uEAj1lsBMhA== +"@eslint-community/regexpp@^4.12.1": + version "4.12.1" + resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.12.1.tgz#cfc6cffe39df390a3841cde2abccf92eaa7ae0e0" + integrity sha512-CCZCDJuduB9OUkFkY2IgppNZMi2lBQgD2qzwXkEia16cge2pijY/aXi96CJMquDMn3nJdlPV1A5KrJEXwfLNzQ== + +"@eslint/config-array@^0.19.2": + version "0.19.2" + resolved "https://registry.yarnpkg.com/@eslint/config-array/-/config-array-0.19.2.tgz#3060b809e111abfc97adb0bb1172778b90cb46aa" + integrity sha512-GNKqxfHG2ySmJOBSHg7LxeUx4xpuCoFjacmlCoYWEbaPXLwvfIjixRI12xCQZeULksQb23uiA8F40w5TojpV7w== + dependencies: + "@eslint/object-schema" "^2.1.6" + debug "^4.3.1" + minimatch "^3.1.2" + +"@eslint/core@^0.12.0": + version "0.12.0" + resolved "https://registry.yarnpkg.com/@eslint/core/-/core-0.12.0.tgz#5f960c3d57728be9f6c65bd84aa6aa613078798e" + integrity sha512-cmrR6pytBuSMTaBweKoGMwu3EiHiEC+DoyupPmlZ0HxBJBtIxwe+j/E4XPIKNx+Q74c8lXKPwYawBf5glsTkHg== dependencies: - "@cspotcode/source-map-consumer" "0.8.0" + "@types/json-schema" "^7.0.15" -"@eslint/eslintrc@^0.4.3": - version "0.4.3" - resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-0.4.3.tgz#9e42981ef035beb3dd49add17acb96e8ff6f394c" - integrity sha512-J6KFFz5QCYUJq3pf0mjEcCJVERbzv71PUIDczuh9JkwGEzced6CO5ADLHB1rbf/+oPBtoPfMYNOpGDzCANlbXw== +"@eslint/eslintrc@^3.3.0": + version "3.3.0" + resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-3.3.0.tgz#96a558f45842989cca7ea1ecd785ad5491193846" + integrity sha512-yaVPAiNAalnCZedKLdR21GOGILMLKPyqSLWaAjQFvYA2i/ciDi8ArYVr69Anohb6cH2Ukhqti4aFnYyPm8wdwQ== dependencies: ajv "^6.12.4" - debug "^4.1.1" - espree "^7.3.0" - globals "^13.9.0" - ignore "^4.0.6" + debug "^4.3.2" + espree "^10.0.1" + globals "^14.0.0" + ignore "^5.2.0" import-fresh "^3.2.1" - js-yaml "^3.13.1" - minimatch "^3.0.4" + js-yaml "^4.1.0" + minimatch "^3.1.2" strip-json-comments "^3.1.1" -"@humanwhocodes/config-array@^0.5.0": - version "0.5.0" - resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.5.0.tgz#1407967d4c6eecd7388f83acf1eaf4d0c6e58ef9" - integrity sha512-FagtKFz74XrTl7y6HCzQpwDfXP0yhxe9lHLD1UZxjvZIcbyRz8zTFF/yYNfSfzU414eDwZ1SrO0Qvtyf+wFMQg== +"@eslint/js@9.21.0", "@eslint/js@^9.21.0": + version "9.21.0" + resolved "https://registry.yarnpkg.com/@eslint/js/-/js-9.21.0.tgz#4303ef4e07226d87c395b8fad5278763e9c15c08" + integrity sha512-BqStZ3HX8Yz6LvsF5ByXYrtigrV5AXADWLAGc7PH/1SxOb7/FIYYMszZZWiUou/GB9P2lXWk2SV4d+Z8h0nknw== + +"@eslint/object-schema@^2.1.6": + version "2.1.6" + resolved "https://registry.yarnpkg.com/@eslint/object-schema/-/object-schema-2.1.6.tgz#58369ab5b5b3ca117880c0f6c0b0f32f6950f24f" + integrity sha512-RBMg5FRL0I0gs51M/guSAj5/e14VQ4tpZnQNWwuDT66P14I43ItmPfIZRhO9fUVIPOAQXU47atlywZ/czoqFPA== + +"@eslint/plugin-kit@^0.2.7": + version "0.2.7" + resolved "https://registry.yarnpkg.com/@eslint/plugin-kit/-/plugin-kit-0.2.7.tgz#9901d52c136fb8f375906a73dcc382646c3b6a27" + integrity sha512-JubJ5B2pJ4k4yGxaNLdbjrnk9d/iDz6/q8wOilpIowd6PJPgaxCuHBnBszq7Ce2TyMrywm5r4PnKm6V3iiZF+g== dependencies: - "@humanwhocodes/object-schema" "^1.2.0" - debug "^4.1.1" - minimatch "^3.0.4" + "@eslint/core" "^0.12.0" + levn "^0.4.1" -"@humanwhocodes/object-schema@^1.2.0": - version "1.2.0" - resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-1.2.0.tgz#87de7af9c231826fdd68ac7258f77c429e0e5fcf" - integrity sha512-wdppn25U8z/2yiaT6YGquE6X8sSv7hNMWSXYSSU1jGv/yd6XqjXgTDJ8KP4NgjTXfJ3GbRjeeb8RTV7a/VpM+w== +"@humanfs/core@^0.19.1": + version "0.19.1" + resolved "https://registry.yarnpkg.com/@humanfs/core/-/core-0.19.1.tgz#17c55ca7d426733fe3c561906b8173c336b40a77" + integrity sha512-5DyQ4+1JEUzejeK1JGICcideyfUbGixgS9jNgex5nqkW+cY7WZhxBigmieN5Qnw9ZosSNVC9KQKyb+GUaGyKUA== + +"@humanfs/node@^0.16.6": + version "0.16.6" + resolved "https://registry.yarnpkg.com/@humanfs/node/-/node-0.16.6.tgz#ee2a10eaabd1131987bf0488fd9b820174cd765e" + integrity sha512-YuI2ZHQL78Q5HbhDiBA1X4LmYdXCKCMQIfw0pw7piHJwyREFebJUvrQN4cMssyES6x+vfUbx1CIpaQUKYdQZOw== + dependencies: + "@humanfs/core" "^0.19.1" + "@humanwhocodes/retry" "^0.3.0" + +"@humanwhocodes/module-importer@^1.0.1": + version "1.0.1" + resolved "https://registry.yarnpkg.com/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz#af5b2691a22b44be847b0ca81641c5fb6ad0172c" + integrity sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA== + +"@humanwhocodes/retry@^0.3.0": + version "0.3.1" + resolved "https://registry.yarnpkg.com/@humanwhocodes/retry/-/retry-0.3.1.tgz#c72a5c76a9fbaf3488e231b13dc52c0da7bab42a" + integrity sha512-JBxkERygn7Bv/GbN5Rv8Ul6LVknS+5Bp6RgDC/O8gEBU/yeH5Ui5C/OlWrTb6qct7LjjfT6Re2NxB0ln0yYybA== + +"@humanwhocodes/retry@^0.4.2": + version "0.4.2" + resolved "https://registry.yarnpkg.com/@humanwhocodes/retry/-/retry-0.4.2.tgz#1860473de7dfa1546767448f333db80cb0ff2161" + integrity sha512-xeO57FpIu4p1Ri3Jq/EXq4ClRm86dVF2z/+kvFnyqVYRavTZmaFaUBbWCOuuTh0o/g7DSsk6kc2vrS4Vl5oPOQ== "@istanbuljs/load-nyc-config@^1.0.0": version "1.1.0" @@ -366,466 +407,358 @@ resolved "https://registry.yarnpkg.com/@istanbuljs/schema/-/schema-0.1.3.tgz#e45e384e4b8ec16bce2fd903af78450f6bf7ec98" integrity sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA== -"@jest/console@^27.3.1": - version "27.3.1" - resolved "https://registry.yarnpkg.com/@jest/console/-/console-27.3.1.tgz#e8ea3a475d3f8162f23d69efbfaa9cbe486bee93" - integrity sha512-RkFNWmv0iui+qsOr/29q9dyfKTTT5DCuP31kUwg7rmOKPT/ozLeGLKJKVIiOfbiKyleUZKIrHwhmiZWVe8IMdw== +"@jest/console@^29.7.0": + version "29.7.0" + resolved "https://registry.yarnpkg.com/@jest/console/-/console-29.7.0.tgz#cd4822dbdb84529265c5a2bdb529a3c9cc950ffc" + integrity sha512-5Ni4CU7XHQi32IJ398EEP4RrB8eV09sXP2ROqD4bksHrnTree52PsxvX8tpL8LvTZ3pFzXyPbNQReSN41CAhOg== dependencies: - "@jest/types" "^27.2.5" + "@jest/types" "^29.6.3" "@types/node" "*" chalk "^4.0.0" - jest-message-util "^27.3.1" - jest-util "^27.3.1" + jest-message-util "^29.7.0" + jest-util "^29.7.0" slash "^3.0.0" -"@jest/core@^27.3.1": - version "27.3.1" - resolved "https://registry.yarnpkg.com/@jest/core/-/core-27.3.1.tgz#04992ef1b58b17c459afb87ab56d81e63d386925" - integrity sha512-DMNE90RR5QKx0EA+wqe3/TNEwiRpOkhshKNxtLxd4rt3IZpCt+RSL+FoJsGeblRZmqdK4upHA/mKKGPPRAifhg== +"@jest/core@^29.7.0": + version "29.7.0" + resolved "https://registry.yarnpkg.com/@jest/core/-/core-29.7.0.tgz#b6cccc239f30ff36609658c5a5e2291757ce448f" + integrity sha512-n7aeXWKMnGtDA48y8TLWJPJmLmmZ642Ceo78cYWEpiD7FzDgmNDV/GCVRorPABdXLJZ/9wzzgZAlHjXjxDHGsg== dependencies: - "@jest/console" "^27.3.1" - "@jest/reporters" "^27.3.1" - "@jest/test-result" "^27.3.1" - "@jest/transform" "^27.3.1" - "@jest/types" "^27.2.5" + "@jest/console" "^29.7.0" + "@jest/reporters" "^29.7.0" + "@jest/test-result" "^29.7.0" + "@jest/transform" "^29.7.0" + "@jest/types" "^29.6.3" "@types/node" "*" ansi-escapes "^4.2.1" chalk "^4.0.0" - emittery "^0.8.1" + ci-info "^3.2.0" exit "^0.1.2" - graceful-fs "^4.2.4" - jest-changed-files "^27.3.0" - jest-config "^27.3.1" - jest-haste-map "^27.3.1" - jest-message-util "^27.3.1" - jest-regex-util "^27.0.6" - jest-resolve "^27.3.1" - jest-resolve-dependencies "^27.3.1" - jest-runner "^27.3.1" - jest-runtime "^27.3.1" - jest-snapshot "^27.3.1" - jest-util "^27.3.1" - jest-validate "^27.3.1" - jest-watcher "^27.3.1" + graceful-fs "^4.2.9" + jest-changed-files "^29.7.0" + jest-config "^29.7.0" + jest-haste-map "^29.7.0" + jest-message-util "^29.7.0" + jest-regex-util "^29.6.3" + jest-resolve "^29.7.0" + jest-resolve-dependencies "^29.7.0" + jest-runner "^29.7.0" + jest-runtime "^29.7.0" + jest-snapshot "^29.7.0" + jest-util "^29.7.0" + jest-validate "^29.7.0" + jest-watcher "^29.7.0" micromatch "^4.0.4" - rimraf "^3.0.0" + pretty-format "^29.7.0" slash "^3.0.0" strip-ansi "^6.0.0" -"@jest/environment@^27.3.1": - version "27.3.1" - resolved "https://registry.yarnpkg.com/@jest/environment/-/environment-27.3.1.tgz#2182defbce8d385fd51c5e7c7050f510bd4c86b1" - integrity sha512-BCKCj4mOVLme6Tanoyc9k0ultp3pnmuyHw73UHRPeeZxirsU/7E3HC4le/VDb/SMzE1JcPnto+XBKFOcoiJzVw== +"@jest/environment@^29.7.0": + version "29.7.0" + resolved "https://registry.yarnpkg.com/@jest/environment/-/environment-29.7.0.tgz#24d61f54ff1f786f3cd4073b4b94416383baf2a7" + integrity sha512-aQIfHDq33ExsN4jP1NWGXhxgQ/wixs60gDiKO+XVMd8Mn0NWPWgc34ZQDTb2jKaUWQ7MuwoitXAsN2XVXNMpAw== dependencies: - "@jest/fake-timers" "^27.3.1" - "@jest/types" "^27.2.5" + "@jest/fake-timers" "^29.7.0" + "@jest/types" "^29.6.3" "@types/node" "*" - jest-mock "^27.3.0" + jest-mock "^29.7.0" + +"@jest/expect-utils@^29.7.0": + version "29.7.0" + resolved "https://registry.yarnpkg.com/@jest/expect-utils/-/expect-utils-29.7.0.tgz#023efe5d26a8a70f21677d0a1afc0f0a44e3a1c6" + integrity sha512-GlsNBWiFQFCVi9QVSx7f5AgMeLxe9YCCs5PuP2O2LdjDAA8Jh9eX7lA1Jq/xdXw3Wb3hyvlFNfZIfcRetSzYcA== + dependencies: + jest-get-type "^29.6.3" + +"@jest/expect@^29.7.0": + version "29.7.0" + resolved "https://registry.yarnpkg.com/@jest/expect/-/expect-29.7.0.tgz#76a3edb0cb753b70dfbfe23283510d3d45432bf2" + integrity sha512-8uMeAMycttpva3P1lBHB8VciS9V0XAr3GymPpipdyQXbBcuhkLQOSe8E/p92RyAdToS6ZD1tFkX+CkhoECE0dQ== + dependencies: + expect "^29.7.0" + jest-snapshot "^29.7.0" -"@jest/fake-timers@^27.3.1": - version "27.3.1" - resolved "https://registry.yarnpkg.com/@jest/fake-timers/-/fake-timers-27.3.1.tgz#1fad860ee9b13034762cdb94266e95609dfce641" - integrity sha512-M3ZFgwwlqJtWZ+QkBG5NmC23A9w+A6ZxNsO5nJxJsKYt4yguBd3i8TpjQz5NfCX91nEve1KqD9RA2Q+Q1uWqoA== +"@jest/fake-timers@^29.7.0": + version "29.7.0" + resolved "https://registry.yarnpkg.com/@jest/fake-timers/-/fake-timers-29.7.0.tgz#fd91bf1fffb16d7d0d24a426ab1a47a49881a565" + integrity sha512-q4DH1Ha4TTFPdxLsqDXK1d3+ioSL7yL5oCMJZgDYm6i+6CygW5E5xVr/D1HdsGxjt1ZWSfUAs9OxSB/BNelWrQ== dependencies: - "@jest/types" "^27.2.5" - "@sinonjs/fake-timers" "^8.0.1" + "@jest/types" "^29.6.3" + "@sinonjs/fake-timers" "^10.0.2" "@types/node" "*" - jest-message-util "^27.3.1" - jest-mock "^27.3.0" - jest-util "^27.3.1" + jest-message-util "^29.7.0" + jest-mock "^29.7.0" + jest-util "^29.7.0" -"@jest/globals@^27.3.1": - version "27.3.1" - resolved "https://registry.yarnpkg.com/@jest/globals/-/globals-27.3.1.tgz#ce1dfb03d379237a9da6c1b99ecfaca1922a5f9e" - integrity sha512-Q651FWiWQAIFiN+zS51xqhdZ8g9b88nGCobC87argAxA7nMfNQq0Q0i9zTfQYgLa6qFXk2cGANEqfK051CZ8Pg== +"@jest/globals@^29.7.0": + version "29.7.0" + resolved "https://registry.yarnpkg.com/@jest/globals/-/globals-29.7.0.tgz#8d9290f9ec47ff772607fa864ca1d5a2efae1d4d" + integrity sha512-mpiz3dutLbkW2MNFubUGUEVLkTGiqW6yLVTA+JbP6fI6J5iL9Y0Nlg8k95pcF8ctKwCS7WVxteBs29hhfAotzQ== dependencies: - "@jest/environment" "^27.3.1" - "@jest/types" "^27.2.5" - expect "^27.3.1" + "@jest/environment" "^29.7.0" + "@jest/expect" "^29.7.0" + "@jest/types" "^29.6.3" + jest-mock "^29.7.0" -"@jest/reporters@^27.3.1": - version "27.3.1" - resolved "https://registry.yarnpkg.com/@jest/reporters/-/reporters-27.3.1.tgz#28b5c1f5789481e23788048fa822ed15486430b9" - integrity sha512-m2YxPmL9Qn1emFVgZGEiMwDntDxRRQ2D58tiDQlwYTg5GvbFOKseYCcHtn0WsI8CG4vzPglo3nqbOiT8ySBT/w== +"@jest/reporters@^29.7.0": + version "29.7.0" + resolved "https://registry.yarnpkg.com/@jest/reporters/-/reporters-29.7.0.tgz#04b262ecb3b8faa83b0b3d321623972393e8f4c7" + integrity sha512-DApq0KJbJOEzAFYjHADNNxAE3KbhxQB1y5Kplb5Waqw6zVbuWatSnMjE5gs8FUgEPmNsnZA3NCWl9NG0ia04Pg== dependencies: "@bcoe/v8-coverage" "^0.2.3" - "@jest/console" "^27.3.1" - "@jest/test-result" "^27.3.1" - "@jest/transform" "^27.3.1" - "@jest/types" "^27.2.5" + "@jest/console" "^29.7.0" + "@jest/test-result" "^29.7.0" + "@jest/transform" "^29.7.0" + "@jest/types" "^29.6.3" + "@jridgewell/trace-mapping" "^0.3.18" "@types/node" "*" chalk "^4.0.0" collect-v8-coverage "^1.0.0" exit "^0.1.2" - glob "^7.1.2" - graceful-fs "^4.2.4" + glob "^7.1.3" + graceful-fs "^4.2.9" istanbul-lib-coverage "^3.0.0" - istanbul-lib-instrument "^4.0.3" + istanbul-lib-instrument "^6.0.0" istanbul-lib-report "^3.0.0" istanbul-lib-source-maps "^4.0.0" - istanbul-reports "^3.0.2" - jest-haste-map "^27.3.1" - jest-resolve "^27.3.1" - jest-util "^27.3.1" - jest-worker "^27.3.1" + istanbul-reports "^3.1.3" + jest-message-util "^29.7.0" + jest-util "^29.7.0" + jest-worker "^29.7.0" slash "^3.0.0" - source-map "^0.6.0" string-length "^4.0.1" - terminal-link "^2.0.0" - v8-to-istanbul "^8.1.0" + strip-ansi "^6.0.0" + v8-to-istanbul "^9.0.1" + +"@jest/schemas@^29.6.3": + version "29.6.3" + resolved "https://registry.yarnpkg.com/@jest/schemas/-/schemas-29.6.3.tgz#430b5ce8a4e0044a7e3819663305a7b3091c8e03" + integrity sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA== + dependencies: + "@sinclair/typebox" "^0.27.8" -"@jest/source-map@^27.0.6": - version "27.0.6" - resolved "https://registry.yarnpkg.com/@jest/source-map/-/source-map-27.0.6.tgz#be9e9b93565d49b0548b86e232092491fb60551f" - integrity sha512-Fek4mi5KQrqmlY07T23JRi0e7Z9bXTOOD86V/uS0EIW4PClvPDqZOyFlLpNJheS6QI0FNX1CgmPjtJ4EA/2M+g== +"@jest/source-map@^29.6.3": + version "29.6.3" + resolved "https://registry.yarnpkg.com/@jest/source-map/-/source-map-29.6.3.tgz#d90ba772095cf37a34a5eb9413f1b562a08554c4" + integrity sha512-MHjT95QuipcPrpLM+8JMSzFx6eHp5Bm+4XeFDJlwsvVBjmKNiIAvasGK2fxz2WbGRlnvqehFbh07MMa7n3YJnw== dependencies: + "@jridgewell/trace-mapping" "^0.3.18" callsites "^3.0.0" - graceful-fs "^4.2.4" - source-map "^0.6.0" + graceful-fs "^4.2.9" -"@jest/test-result@^27.3.1": - version "27.3.1" - resolved "https://registry.yarnpkg.com/@jest/test-result/-/test-result-27.3.1.tgz#89adee8b771877c69b3b8d59f52f29dccc300194" - integrity sha512-mLn6Thm+w2yl0opM8J/QnPTqrfS4FoXsXF2WIWJb2O/GBSyResL71BRuMYbYRsGt7ELwS5JGcEcGb52BNrumgg== +"@jest/test-result@^29.7.0": + version "29.7.0" + resolved "https://registry.yarnpkg.com/@jest/test-result/-/test-result-29.7.0.tgz#8db9a80aa1a097bb2262572686734baed9b1657c" + integrity sha512-Fdx+tv6x1zlkJPcWXmMDAG2HBnaR9XPSd5aDWQVsfrZmLVT3lU1cwyxLgRmXR9yrq4NBoEm9BMsfgFzTQAbJYA== dependencies: - "@jest/console" "^27.3.1" - "@jest/types" "^27.2.5" + "@jest/console" "^29.7.0" + "@jest/types" "^29.6.3" "@types/istanbul-lib-coverage" "^2.0.0" collect-v8-coverage "^1.0.0" -"@jest/test-sequencer@^27.3.1": - version "27.3.1" - resolved "https://registry.yarnpkg.com/@jest/test-sequencer/-/test-sequencer-27.3.1.tgz#4b3bde2dbb05ee74afdae608cf0768e3354683b1" - integrity sha512-siySLo07IMEdSjA4fqEnxfIX8lB/lWYsBPwNFtkOvsFQvmBrL3yj3k3uFNZv/JDyApTakRpxbKLJ3CT8UGVCrA== +"@jest/test-sequencer@^29.7.0": + version "29.7.0" + resolved "https://registry.yarnpkg.com/@jest/test-sequencer/-/test-sequencer-29.7.0.tgz#6cef977ce1d39834a3aea887a1726628a6f072ce" + integrity sha512-GQwJ5WZVrKnOJuiYiAF52UNUJXgTZx1NHjFSEB0qEMmSZKAkdMoIzw/Cj6x6NF4AvV23AUqDpFzQkN/eYCYTxw== dependencies: - "@jest/test-result" "^27.3.1" - graceful-fs "^4.2.4" - jest-haste-map "^27.3.1" - jest-runtime "^27.3.1" + "@jest/test-result" "^29.7.0" + graceful-fs "^4.2.9" + jest-haste-map "^29.7.0" + slash "^3.0.0" -"@jest/transform@^27.3.1": - version "27.3.1" - resolved "https://registry.yarnpkg.com/@jest/transform/-/transform-27.3.1.tgz#ff80eafbeabe811e9025e4b6f452126718455220" - integrity sha512-3fSvQ02kuvjOI1C1ssqMVBKJpZf6nwoCiSu00zAKh5nrp3SptNtZy/8s5deayHnqxhjD9CWDJ+yqQwuQ0ZafXQ== +"@jest/transform@^29.7.0": + version "29.7.0" + resolved "https://registry.yarnpkg.com/@jest/transform/-/transform-29.7.0.tgz#df2dd9c346c7d7768b8a06639994640c642e284c" + integrity sha512-ok/BTPFzFKVMwO5eOHRrvnBVHdRy9IrsrW1GpMaQ9MCnilNLXQKmAX8s1YXDFaai9xJpac2ySzV0YeRRECr2Vw== dependencies: - "@babel/core" "^7.1.0" - "@jest/types" "^27.2.5" - babel-plugin-istanbul "^6.0.0" + "@babel/core" "^7.11.6" + "@jest/types" "^29.6.3" + "@jridgewell/trace-mapping" "^0.3.18" + babel-plugin-istanbul "^6.1.1" chalk "^4.0.0" - convert-source-map "^1.4.0" - fast-json-stable-stringify "^2.0.0" - graceful-fs "^4.2.4" - jest-haste-map "^27.3.1" - jest-regex-util "^27.0.6" - jest-util "^27.3.1" + convert-source-map "^2.0.0" + fast-json-stable-stringify "^2.1.0" + graceful-fs "^4.2.9" + jest-haste-map "^29.7.0" + jest-regex-util "^29.6.3" + jest-util "^29.7.0" micromatch "^4.0.4" - pirates "^4.0.1" + pirates "^4.0.4" slash "^3.0.0" - source-map "^0.6.1" - write-file-atomic "^3.0.0" + write-file-atomic "^4.0.2" -"@jest/types@^27.1.1": - version "27.1.1" - resolved "https://registry.yarnpkg.com/@jest/types/-/types-27.1.1.tgz#77a3fc014f906c65752d12123a0134359707c0ad" - integrity sha512-yqJPDDseb0mXgKqmNqypCsb85C22K1aY5+LUxh7syIM9n/b0AsaltxNy+o6tt29VcfGDpYEve175bm3uOhcehA== +"@jest/types@^29.6.3": + version "29.6.3" + resolved "https://registry.yarnpkg.com/@jest/types/-/types-29.6.3.tgz#1131f8cf634e7e84c5e77bab12f052af585fba59" + integrity sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw== dependencies: + "@jest/schemas" "^29.6.3" "@types/istanbul-lib-coverage" "^2.0.0" "@types/istanbul-reports" "^3.0.0" "@types/node" "*" - "@types/yargs" "^16.0.0" + "@types/yargs" "^17.0.8" chalk "^4.0.0" -"@jest/types@^27.2.5": - version "27.2.5" - resolved "https://registry.yarnpkg.com/@jest/types/-/types-27.2.5.tgz#420765c052605e75686982d24b061b4cbba22132" - integrity sha512-nmuM4VuDtCZcY+eTpw+0nvstwReMsjPoj7ZR80/BbixulhLaiX+fbv8oeLW8WZlJMcsGQsTmMKT/iTZu1Uy/lQ== +"@jridgewell/gen-mapping@^0.3.0", "@jridgewell/gen-mapping@^0.3.2": + version "0.3.3" + resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz#7e02e6eb5df901aaedb08514203b096614024098" + integrity sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ== dependencies: - "@types/istanbul-lib-coverage" "^2.0.0" - "@types/istanbul-reports" "^3.0.0" - "@types/node" "*" - "@types/yargs" "^16.0.0" - chalk "^4.0.0" + "@jridgewell/set-array" "^1.0.1" + "@jridgewell/sourcemap-codec" "^1.4.10" + "@jridgewell/trace-mapping" "^0.3.9" -"@nodelib/fs.scandir@2.1.5": - version "2.1.5" - resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" - integrity sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g== - dependencies: - "@nodelib/fs.stat" "2.0.5" - run-parallel "^1.1.9" +"@jridgewell/resolve-uri@^3.1.0": + version "3.1.1" + resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz#c08679063f279615a3326583ba3a90d1d82cc721" + integrity sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA== -"@nodelib/fs.stat@2.0.5", "@nodelib/fs.stat@^2.0.2": - version "2.0.5" - resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz#5bd262af94e9d25bd1e71b05deed44876a222e8b" - integrity sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A== +"@jridgewell/set-array@^1.0.1": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@jridgewell/set-array/-/set-array-1.1.2.tgz#7c6cf998d6d20b914c0a55a91ae928ff25965e72" + integrity sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw== -"@nodelib/fs.walk@^1.2.3": - version "1.2.8" - resolved "https://registry.yarnpkg.com/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz#e95737e8bb6746ddedf69c556953494f196fe69a" - integrity sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg== +"@jridgewell/sourcemap-codec@^1.4.10", "@jridgewell/sourcemap-codec@^1.4.14": + version "1.4.15" + resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz#d7c6e6755c78567a951e04ab52ef0fd26de59f32" + integrity sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg== + +"@jridgewell/trace-mapping@^0.3.12", "@jridgewell/trace-mapping@^0.3.17", "@jridgewell/trace-mapping@^0.3.18", "@jridgewell/trace-mapping@^0.3.9": + version "0.3.20" + resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.20.tgz#72e45707cf240fa6b081d0366f8265b0cd10197f" + integrity sha512-R8LcPeWZol2zR8mmH3JeKQ6QRCFb7XgUhV9ZlGhHLGyg4wpPiPZNQOOWhFZhxKw8u//yTbNGI42Bx/3paXEQ+Q== dependencies: - "@nodelib/fs.scandir" "2.1.5" - fastq "^1.6.0" + "@jridgewell/resolve-uri" "^3.1.0" + "@jridgewell/sourcemap-codec" "^1.4.14" + +"@sinclair/typebox@^0.27.8": + version "0.27.8" + resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.27.8.tgz#6667fac16c436b5434a387a34dedb013198f6e6e" + integrity sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA== -"@sinonjs/commons@^1.7.0": - version "1.8.3" - resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.8.3.tgz#3802ddd21a50a949b6721ddd72da36e67e7f1b2d" - integrity sha512-xkNcLAn/wZaX14RPlwizcKicDk9G3F8m2nU3L7Ukm5zBgTwiT0wsoFAHx9Jq56fJA1z/7uKGtCRu16sOUCLIHQ== +"@sinonjs/commons@^3.0.0": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-3.0.0.tgz#beb434fe875d965265e04722ccfc21df7f755d72" + integrity sha512-jXBtWAF4vmdNmZgD5FoKsVLv3rPgDnLgPbU84LIJ3otV44vJlDRokVng5v8NFJdCf/da9legHcKaRuZs4L7faA== dependencies: type-detect "4.0.8" -"@sinonjs/fake-timers@^8.0.1": - version "8.0.1" - resolved "https://registry.yarnpkg.com/@sinonjs/fake-timers/-/fake-timers-8.0.1.tgz#1c1c9a91419f804e59ae8df316a07dd1c3a76b94" - integrity sha512-AU7kwFxreVd6OAXcAFlKSmZquiRUU0FvYm44k1Y1QbK7Co4m0aqfGMhjykIeQp/H6rcl+nFmj0zfdUcGVs9Dew== +"@sinonjs/fake-timers@^10.0.2": + version "10.3.0" + resolved "https://registry.yarnpkg.com/@sinonjs/fake-timers/-/fake-timers-10.3.0.tgz#55fdff1ecab9f354019129daf4df0dd4d923ea66" + integrity sha512-V4BG07kuYSUkTCSBHG8G8TNhM+F19jXFWnQtzj+we8DrkpSBCee9Z3Ms8yiGer/dlmhe35/Xdgyo3/0rQKg7YA== dependencies: - "@sinonjs/commons" "^1.7.0" - -"@tootallnate/once@1": - version "1.1.2" - resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-1.1.2.tgz#ccb91445360179a04e7fe6aff78c00ffc1eeaf82" - integrity sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw== - -"@tsconfig/node10@^1.0.7": - version "1.0.8" - resolved "https://registry.yarnpkg.com/@tsconfig/node10/-/node10-1.0.8.tgz#c1e4e80d6f964fbecb3359c43bd48b40f7cadad9" - integrity sha512-6XFfSQmMgq0CFLY1MslA/CPUfhIL919M1rMsa5lP2P097N2Wd1sSX0tx1u4olM16fLNhtHZpRhedZJphNJqmZg== - -"@tsconfig/node12@^1.0.7": - version "1.0.9" - resolved "https://registry.yarnpkg.com/@tsconfig/node12/-/node12-1.0.9.tgz#62c1f6dee2ebd9aead80dc3afa56810e58e1a04c" - integrity sha512-/yBMcem+fbvhSREH+s14YJi18sp7J9jpuhYByADT2rypfajMZZN4WQ6zBGgBKp53NKmqI36wFYDb3yaMPurITw== + "@sinonjs/commons" "^3.0.0" -"@tsconfig/node14@^1.0.0": - version "1.0.1" - resolved "https://registry.yarnpkg.com/@tsconfig/node14/-/node14-1.0.1.tgz#95f2d167ffb9b8d2068b0b235302fafd4df711f2" - integrity sha512-509r2+yARFfHHE7T6Puu2jjkoycftovhXRqW328PDXTVGKihlb1P8Z9mMZH04ebyajfRY7dedfGynlrFHJUQCg== - -"@tsconfig/node16@^1.0.2": - version "1.0.2" - resolved "https://registry.yarnpkg.com/@tsconfig/node16/-/node16-1.0.2.tgz#423c77877d0569db20e1fc80885ac4118314010e" - integrity sha512-eZxlbI8GZscaGS7kkc/trHTT5xgrjH3/1n2JDwusC9iahPKWMRvRjJSAN5mCXviuTGQ/lHnhvv8Q1YTpnfz9gA== - -"@types/babel__core@^7.0.0", "@types/babel__core@^7.1.14": - version "7.1.16" - resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.1.16.tgz#bc12c74b7d65e82d29876b5d0baf5c625ac58702" - integrity sha512-EAEHtisTMM+KaKwfWdC3oyllIqswlznXCIVCt7/oRNrh+DhgT4UEBNC/jlADNjvw7UnfbcdkGQcPVZ1xYiLcrQ== +"@types/babel__core@^7.1.14": + version "7.20.4" + resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.20.4.tgz#26a87347e6c6f753b3668398e34496d6d9ac6ac0" + integrity sha512-mLnSC22IC4vcWiuObSRjrLd9XcBTGf59vUSoq2jkQDJ/QQ8PMI9rSuzE+aEV8karUMbskw07bKYoUJCKTUaygg== dependencies: - "@babel/parser" "^7.1.0" - "@babel/types" "^7.0.0" + "@babel/parser" "^7.20.7" + "@babel/types" "^7.20.7" "@types/babel__generator" "*" "@types/babel__template" "*" "@types/babel__traverse" "*" "@types/babel__generator@*": - version "7.6.3" - resolved "https://registry.yarnpkg.com/@types/babel__generator/-/babel__generator-7.6.3.tgz#f456b4b2ce79137f768aa130d2423d2f0ccfaba5" - integrity sha512-/GWCmzJWqV7diQW54smJZzWbSFf4QYtF71WCKhcx6Ru/tFyQIY2eiiITcCAeuPbNSvT9YCGkVMqqvSk2Z0mXiA== + version "7.6.7" + resolved "https://registry.yarnpkg.com/@types/babel__generator/-/babel__generator-7.6.7.tgz#a7aebf15c7bc0eb9abd638bdb5c0b8700399c9d0" + integrity sha512-6Sfsq+EaaLrw4RmdFWE9Onp63TOUue71AWb4Gpa6JxzgTYtimbM086WnYTy2U67AofR++QKCo08ZP6pwx8YFHQ== dependencies: "@babel/types" "^7.0.0" "@types/babel__template@*": - version "7.4.1" - resolved "https://registry.yarnpkg.com/@types/babel__template/-/babel__template-7.4.1.tgz#3d1a48fd9d6c0edfd56f2ff578daed48f36c8969" - integrity sha512-azBFKemX6kMg5Io+/rdGT0dkGreboUVR0Cdm3fz9QJWpaQGJRQXl7C+6hOTCZcMll7KFyEQpgbYI2lHdsS4U7g== + version "7.4.4" + resolved "https://registry.yarnpkg.com/@types/babel__template/-/babel__template-7.4.4.tgz#5672513701c1b2199bc6dad636a9d7491586766f" + integrity sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A== dependencies: "@babel/parser" "^7.1.0" "@babel/types" "^7.0.0" -"@types/babel__traverse@*", "@types/babel__traverse@^7.0.4", "@types/babel__traverse@^7.0.6": - version "7.14.2" - resolved "https://registry.yarnpkg.com/@types/babel__traverse/-/babel__traverse-7.14.2.tgz#ffcd470bbb3f8bf30481678fb5502278ca833a43" - integrity sha512-K2waXdXBi2302XUdcHcR1jCeU0LL4TD9HRs/gk0N2Xvrht+G/BfJa4QObBQZfhMdxiCpV3COl5Nfq4uKTeTnJA== +"@types/babel__traverse@*", "@types/babel__traverse@^7.0.6": + version "7.20.4" + resolved "https://registry.yarnpkg.com/@types/babel__traverse/-/babel__traverse-7.20.4.tgz#ec2c06fed6549df8bc0eb4615b683749a4a92e1b" + integrity sha512-mSM/iKUk5fDDrEV/e83qY+Cr3I1+Q3qqTuEn++HAWYjEa1+NxZr6CNrcJGf2ZTnq4HoFGC3zaTPZTobCzCFukA== dependencies: - "@babel/types" "^7.3.0" + "@babel/types" "^7.20.7" + +"@types/estree@^1.0.6": + version "1.0.6" + resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.6.tgz#628effeeae2064a1b4e79f78e81d87b7e5fc7b50" + integrity sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw== -"@types/graceful-fs@^4.1.2": - version "4.1.5" - resolved "https://registry.yarnpkg.com/@types/graceful-fs/-/graceful-fs-4.1.5.tgz#21ffba0d98da4350db64891f92a9e5db3cdb4e15" - integrity sha512-anKkLmZZ+xm4p8JWBf4hElkM4XR+EZeA2M9BAkkTldmcyDY4mbdIJnRghDJH3Ov5ooY7/UAoENtmdMSkaAd7Cw== +"@types/graceful-fs@^4.1.3": + version "4.1.9" + resolved "https://registry.yarnpkg.com/@types/graceful-fs/-/graceful-fs-4.1.9.tgz#2a06bc0f68a20ab37b3e36aa238be6abdf49e8b4" + integrity sha512-olP3sd1qOEe5dXTSaFvQG+02VdRXcdytWLAZsAq1PecU8uqQAhkrnbli7DagjtXKW/Bl7YJbUsa8MPcuc8LHEQ== dependencies: "@types/node" "*" "@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.0", "@types/istanbul-lib-coverage@^2.0.1": - version "2.0.3" - resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.3.tgz#4ba8ddb720221f432e443bd5f9117fd22cfd4762" - integrity sha512-sz7iLqvVUg1gIedBOvlkxPlc8/uVzyS5OwGz1cKjXzkl3FpL3al0crU8YGU1WoHkxn0Wxbw5tyi6hvzJKNzFsw== + version "2.0.6" + resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.6.tgz#7739c232a1fee9b4d3ce8985f314c0c6d33549d7" + integrity sha512-2QF/t/auWm0lsy8XtKVPG19v3sSOQlJe/YHZgfjb/KBBHOGSV+J2q/S671rcq9uTBrLAXmZpqJiaQbMT+zNU1w== "@types/istanbul-lib-report@*": - version "3.0.0" - resolved "https://registry.yarnpkg.com/@types/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz#c14c24f18ea8190c118ee7562b7ff99a36552686" - integrity sha512-plGgXAPfVKFoYfa9NpYDAkseG+g6Jr294RqeqcqDixSbU34MZVJRi/P+7Y8GDpzkEwLaGZZOpKIEmeVZNtKsrg== + version "3.0.3" + resolved "https://registry.yarnpkg.com/@types/istanbul-lib-report/-/istanbul-lib-report-3.0.3.tgz#53047614ae72e19fc0401d872de3ae2b4ce350bf" + integrity sha512-NQn7AHQnk/RSLOxrBbGyJM/aVQ+pjj5HCgasFxc0K/KhoATfQ/47AyUl15I2yBUpihjmas+a+VJBOqecrFH+uA== dependencies: "@types/istanbul-lib-coverage" "*" "@types/istanbul-reports@^3.0.0": - version "3.0.1" - resolved "https://registry.yarnpkg.com/@types/istanbul-reports/-/istanbul-reports-3.0.1.tgz#9153fe98bba2bd565a63add9436d6f0d7f8468ff" - integrity sha512-c3mAZEuK0lvBp8tmuL74XRKn1+y2dcwOUpH7x4WrF6gk1GIgiluDRgMYQtw2OFcBvAJWlt6ASU3tSqxp0Uu0Aw== + version "3.0.4" + resolved "https://registry.yarnpkg.com/@types/istanbul-reports/-/istanbul-reports-3.0.4.tgz#0f03e3d2f670fbdac586e34b433783070cc16f54" + integrity sha512-pk2B1NWalF9toCRu6gjBzR69syFjP4Od8WRAX+0mmf9lAjCRicLOWc+ZrxZHx/0XRjotgkF9t6iaMJ+aXcOdZQ== dependencies: "@types/istanbul-lib-report" "*" -"@types/jest@^27.0.1": - version "27.0.2" - resolved "https://registry.yarnpkg.com/@types/jest/-/jest-27.0.2.tgz#ac383c4d4aaddd29bbf2b916d8d105c304a5fcd7" - integrity sha512-4dRxkS/AFX0c5XW6IPMNOydLn2tEhNhJV7DnYK+0bjoJZ+QTmfucBlihX7aoEsh/ocYtkLC73UbnBXBXIxsULA== - dependencies: - jest-diff "^27.0.0" - pretty-format "^27.0.0" - -"@types/json-schema@^7.0.7": - version "7.0.9" - resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.9.tgz#97edc9037ea0c38585320b28964dde3b39e4660d" - integrity sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ== - -"@types/minimatch@^3.0.3": - version "3.0.5" - resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.5.tgz#1001cc5e6a3704b83c236027e77f2f58ea010f40" - integrity sha512-Klz949h02Gz2uZCMGwDUSDS1YBlTdDDgbWHi+81l29tQALUtvz4rAYi5uoVhE5Lagoq6DeqAUlbrHvW/mXDgdQ== +"@types/json-schema@^7.0.15": + version "7.0.15" + resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841" + integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA== -"@types/node@*", "@types/node@^16.9.1": - version "16.11.6" - resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.6.tgz#6bef7a2a0ad684cf6e90fcfe31cecabd9ce0a3ae" - integrity sha512-ua7PgUoeQFjmWPcoo9khiPum3Pd60k4/2ZGXt18sm2Slk0W0xZTqt5Y0Ny1NyBiN1EVQ/+FaF9NcY4Qe6rwk5w== - -"@types/prettier@^2.1.5", "@types/prettier@^2.3.2": - version "2.4.1" - resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.4.1.tgz#e1303048d5389563e130f5bdd89d37a99acb75eb" - integrity sha512-Fo79ojj3vdEZOHg3wR9ksAMRz4P3S5fDB5e/YWZiFnyFQI1WY2Vftu9XoXVVtJfxB7Bpce/QTqWSSntkz2Znrw== +"@types/node@*": + version "20.9.2" + resolved "https://registry.yarnpkg.com/@types/node/-/node-20.9.2.tgz#002815c8e87fe0c9369121c78b52e800fadc0ac6" + integrity sha512-WHZXKFCEyIUJzAwh3NyyTHYSR35SevJ6mZ1nWwJafKtiQbqRTIKSRcw3Ma3acqgsent3RRDqeVwpHntMk+9irg== + dependencies: + undici-types "~5.26.4" "@types/stack-utils@^2.0.0": - version "2.0.1" - resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-2.0.1.tgz#20f18294f797f2209b5f65c8e3b5c8e8261d127c" - integrity sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw== + version "2.0.3" + resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-2.0.3.tgz#6209321eb2c1712a7e7466422b8cb1fc0d9dd5d8" + integrity sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw== "@types/yargs-parser@*": - version "20.2.1" - resolved "https://registry.yarnpkg.com/@types/yargs-parser/-/yargs-parser-20.2.1.tgz#3b9ce2489919d9e4fea439b76916abc34b2df129" - integrity sha512-7tFImggNeNBVMsn0vLrpn1H1uPrUBdnARPTpZoitY37ZrdJREzf7I16tMrlK3hen349gr1NYh8CmZQa7CTG6Aw== + version "21.0.3" + resolved "https://registry.yarnpkg.com/@types/yargs-parser/-/yargs-parser-21.0.3.tgz#815e30b786d2e8f0dcd85fd5bcf5e1a04d008f15" + integrity sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ== -"@types/yargs@^16.0.0": - version "16.0.4" - resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-16.0.4.tgz#26aad98dd2c2a38e421086ea9ad42b9e51642977" - integrity sha512-T8Yc9wt/5LbJyCaLiHPReJa0kApcIgJ7Bn735GjItUfh08Z1pJvu8QZqb9s+mMvKV6WUQRV7K2R46YbjMXTTJw== +"@types/yargs@^17.0.8": + version "17.0.31" + resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-17.0.31.tgz#8fd0089803fd55d8a285895a18b88cb71a99683c" + integrity sha512-bocYSx4DI8TmdlvxqGpVNXOgCNR1Jj0gNPhhAY+iz1rgKDAaYrAYdFYnhDV1IFuiuVc9HkOwyDcFxaTElF3/wg== dependencies: "@types/yargs-parser" "*" -"@typescript-eslint/eslint-plugin@^4.31.2": - version "4.33.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.33.0.tgz#c24dc7c8069c7706bc40d99f6fa87edcb2005276" - integrity sha512-aINiAxGVdOl1eJyVjaWn/YcVAq4Gi/Yo35qHGCnqbWVz61g39D0h23veY/MA0rFFGfxK7TySg2uwDeNv+JgVpg== - dependencies: - "@typescript-eslint/experimental-utils" "4.33.0" - "@typescript-eslint/scope-manager" "4.33.0" - debug "^4.3.1" - functional-red-black-tree "^1.0.1" - ignore "^5.1.8" - regexpp "^3.1.0" - semver "^7.3.5" - tsutils "^3.21.0" - -"@typescript-eslint/experimental-utils@4.33.0": - version "4.33.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-4.33.0.tgz#6f2a786a4209fa2222989e9380b5331b2810f7fd" - integrity sha512-zeQjOoES5JFjTnAhI5QY7ZviczMzDptls15GFsI6jyUOq0kOf9+WonkhtlIhh0RgHRnqj5gdNxW5j1EvAyYg6Q== - dependencies: - "@types/json-schema" "^7.0.7" - "@typescript-eslint/scope-manager" "4.33.0" - "@typescript-eslint/types" "4.33.0" - "@typescript-eslint/typescript-estree" "4.33.0" - eslint-scope "^5.1.1" - eslint-utils "^3.0.0" - -"@typescript-eslint/parser@^4.31.2": - version "4.33.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-4.33.0.tgz#dfe797570d9694e560528d18eecad86c8c744899" - integrity sha512-ZohdsbXadjGBSK0/r+d87X0SBmKzOq4/S5nzK6SBgJspFo9/CUDJ7hjayuze+JK7CZQLDMroqytp7pOcFKTxZA== - dependencies: - "@typescript-eslint/scope-manager" "4.33.0" - "@typescript-eslint/types" "4.33.0" - "@typescript-eslint/typescript-estree" "4.33.0" - debug "^4.3.1" - -"@typescript-eslint/scope-manager@4.33.0": - version "4.33.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.33.0.tgz#d38e49280d983e8772e29121cf8c6e9221f280a3" - integrity sha512-5IfJHpgTsTZuONKbODctL4kKuQje/bzBRkwHE8UOZ4f89Zeddg+EGZs8PD8NcN4LdM3ygHWYB3ukPAYjvl/qbQ== - dependencies: - "@typescript-eslint/types" "4.33.0" - "@typescript-eslint/visitor-keys" "4.33.0" - -"@typescript-eslint/types@4.33.0": - version "4.33.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.33.0.tgz#a1e59036a3b53ae8430ceebf2a919dc7f9af6d72" - integrity sha512-zKp7CjQzLQImXEpLt2BUw1tvOMPfNoTAfb8l51evhYbOEEzdWyQNmHWWGPR6hwKJDAi+1VXSBmnhL9kyVTTOuQ== - -"@typescript-eslint/typescript-estree@4.33.0": - version "4.33.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.33.0.tgz#0dfb51c2908f68c5c08d82aefeaf166a17c24609" - integrity sha512-rkWRY1MPFzjwnEVHsxGemDzqqddw2QbTJlICPD9p9I9LfsO8fdmfQPOX3uKfUaGRDFJbfrtm/sXhVXN4E+bzCA== - dependencies: - "@typescript-eslint/types" "4.33.0" - "@typescript-eslint/visitor-keys" "4.33.0" - debug "^4.3.1" - globby "^11.0.3" - is-glob "^4.0.1" - semver "^7.3.5" - tsutils "^3.21.0" - -"@typescript-eslint/visitor-keys@4.33.0": - version "4.33.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.33.0.tgz#2a22f77a41604289b7a186586e9ec48ca92ef1dd" - integrity sha512-uqi/2aSz9g2ftcHWf8uLPJA70rUv6yuMW5Bohw+bwcuzaxQIHaKFZCKGoGXIrc9vkTJ3+0txM73K0Hq3d5wgIg== - dependencies: - "@typescript-eslint/types" "4.33.0" - eslint-visitor-keys "^2.0.0" - -abab@^2.0.3, abab@^2.0.5: - version "2.0.5" - resolved "https://registry.yarnpkg.com/abab/-/abab-2.0.5.tgz#c0b678fb32d60fc1219c784d6a826fe385aeb79a" - integrity sha512-9IK9EadsbHo6jLWIpxpR6pL0sazTXV6+SQv25ZB+F7Bj9mJNaOc4nCRabwd5M/JwmUa8idz6Eci6eKfJryPs6Q== - -acorn-globals@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/acorn-globals/-/acorn-globals-6.0.0.tgz#46cdd39f0f8ff08a876619b55f5ac8a6dc770b45" - integrity sha512-ZQl7LOWaF5ePqqcX4hLuv/bLXYQNfNWw2c0/yX/TsPRKamzHcTGQnlCjHT3TsmkOUVEPS3crCxiPfdzE/Trlhg== - dependencies: - acorn "^7.1.1" - acorn-walk "^7.1.1" - -acorn-jsx@^5.3.1: +acorn-jsx@^5.3.2: version "5.3.2" resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz#7ed5bb55908b3b2f1bc55c6af1653bada7f07937" integrity sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ== -acorn-walk@^7.1.1: - version "7.2.0" - resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-7.2.0.tgz#0de889a601203909b0fbe07b8938dc21d2e967bc" - integrity sha512-OPdCF6GsMIP+Az+aWfAAOEt2/+iVDKE7oy6lJ098aoe59oAmK76qV6Gw60SbZ8jHuG2wH058GF4pLFbYamYrVA== - -acorn-walk@^8.1.1: - version "8.2.0" - resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.2.0.tgz#741210f2e2426454508853a2f44d0ab83b7f69c1" - integrity sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA== - -acorn@^7.1.1, acorn@^7.4.0: - version "7.4.1" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa" - integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A== +acorn@^8.11.3: + version "8.11.3" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.11.3.tgz#71e0b14e13a4ec160724b38fb7b0f233b1b81d7a" + integrity sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg== -acorn@^8.2.4, acorn@^8.4.1: - version "8.5.0" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.5.0.tgz#4512ccb99b3698c752591e9bb4472e38ad43cee2" - integrity sha512-yXbYeFy+jUuYd3/CDcg2NkIYE991XYX/bje7LmjJigUciaeO1JR4XxXgCIV1/Zc/dRuFEyw1L0pbA+qynJkW5Q== +acorn@^8.14.0: + version "8.14.1" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.14.1.tgz#721d5dc10f7d5b5609a891773d47731796935dfb" + integrity sha512-OvQ/2pUDKmgfCg++xsTX1wGxfTaszcHVcTctW4UJB4hibJx2HXxxO5UmVgyjMa+ZDsiaf5wWLXYpRWMmBI0QHg== -agent-base@6: - version "6.0.2" - resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-6.0.2.tgz#49fff58577cfee3f37176feab4c22e00f86d7f77" - integrity sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ== - dependencies: - debug "4" - -ajv@^6.10.0, ajv@^6.12.4: +ajv@^6.12.4: version "6.12.6" resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== @@ -835,21 +768,6 @@ ajv@^6.10.0, ajv@^6.12.4: json-schema-traverse "^0.4.1" uri-js "^4.2.2" -ajv@^8.0.1: - version "8.6.3" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-8.6.3.tgz#11a66527761dc3e9a3845ea775d2d3c0414e8764" - integrity sha512-SMJOdDP6LqTkD0Uq8qLi+gMwSt0imXLSV080qFVwJCpH9U6Mb+SUGHAXM0KNbcBPguytWyvFxcHgMLe2D2XSpw== - dependencies: - fast-deep-equal "^3.1.1" - json-schema-traverse "^1.0.0" - require-from-string "^2.0.2" - uri-js "^4.2.2" - -ansi-colors@^4.1.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.1.tgz#cbb9ae256bf750af1eab344f229aa27fe94ba348" - integrity sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA== - ansi-escapes@^4.2.1: version "4.3.2" resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-4.3.2.tgz#6b2291d1db7d98b6521d5f1efa42d0f3a9feb65e" @@ -857,7 +775,7 @@ ansi-escapes@^4.2.1: dependencies: type-fest "^0.21.3" -ansi-regex@^5.0.0, ansi-regex@^5.0.1: +ansi-regex@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== @@ -882,18 +800,13 @@ ansi-styles@^5.0.0: integrity sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA== anymatch@^3.0.3: - version "3.1.2" - resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.2.tgz#c0557c096af32f106198f4f4e2a383537e378716" - integrity sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg== + version "3.1.3" + resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.3.tgz#790c58b19ba1720a84205b57c618d5ad8524973e" + integrity sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw== dependencies: normalize-path "^3.0.0" picomatch "^2.0.4" -arg@^4.1.0: - version "4.1.3" - resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089" - integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA== - argparse@^1.0.7: version "1.0.10" resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" @@ -901,64 +814,43 @@ argparse@^1.0.7: dependencies: sprintf-js "~1.0.2" -array-differ@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/array-differ/-/array-differ-3.0.0.tgz#3cbb3d0f316810eafcc47624734237d6aee4ae6b" - integrity sha512-THtfYS6KtME/yIAhKjZ2ul7XI96lQGHRputJQHO80LAWQnuGP4iCIN8vdMRboGbIEYBwU33q8Tch1os2+X0kMg== - -array-union@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/array-union/-/array-union-2.1.0.tgz#b798420adbeb1de828d84acd8a2e23d3efe85e8d" - integrity sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw== - -arrify@^2.0.1: +argparse@^2.0.1: version "2.0.1" - resolved "https://registry.yarnpkg.com/arrify/-/arrify-2.0.1.tgz#c9655e9331e0abcd588d2a7cad7e9956f66701fa" - integrity sha512-3duEwti880xqi4eAMN8AyR4a0ByT90zoYdLlevfrvU43vb0YZwZVfxOgxWrLXXXpyugL0hNZc9G6BiB5B3nUug== - -astral-regex@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-2.0.0.tgz#483143c567aeed4785759c0865786dc77d7d2e31" - integrity sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ== - -asynckit@^0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" - integrity sha1-x57Zf380y48robyXkLzDZkdLS3k= + resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38" + integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q== -babel-jest@^27.3.1: - version "27.3.1" - resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-27.3.1.tgz#0636a3404c68e07001e434ac4956d82da8a80022" - integrity sha512-SjIF8hh/ir0peae2D6S6ZKRhUy7q/DnpH7k/V6fT4Bgs/LXXUztOpX4G2tCgq8mLo5HA9mN6NmlFMeYtKmIsTQ== +babel-jest@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-29.7.0.tgz#f4369919225b684c56085998ac63dbd05be020d5" + integrity sha512-BrvGY3xZSwEcCzKvKsCi2GgHqDqsYkOP4/by5xCgIwGXQxIEh+8ew3gmrE1y7XRR6LHZIj6yLYnUi/mm2KXKBg== dependencies: - "@jest/transform" "^27.3.1" - "@jest/types" "^27.2.5" + "@jest/transform" "^29.7.0" "@types/babel__core" "^7.1.14" - babel-plugin-istanbul "^6.0.0" - babel-preset-jest "^27.2.0" + babel-plugin-istanbul "^6.1.1" + babel-preset-jest "^29.6.3" chalk "^4.0.0" - graceful-fs "^4.2.4" + graceful-fs "^4.2.9" slash "^3.0.0" -babel-plugin-istanbul@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/babel-plugin-istanbul/-/babel-plugin-istanbul-6.0.0.tgz#e159ccdc9af95e0b570c75b4573b7c34d671d765" - integrity sha512-AF55rZXpe7trmEylbaE1Gv54wn6rwU03aptvRoVIGP8YykoSxqdVLV1TfwflBCE/QtHmqtP8SWlTENqbK8GCSQ== +babel-plugin-istanbul@^6.1.1: + version "6.1.1" + resolved "https://registry.yarnpkg.com/babel-plugin-istanbul/-/babel-plugin-istanbul-6.1.1.tgz#fa88ec59232fd9b4e36dbbc540a8ec9a9b47da73" + integrity sha512-Y1IQok9821cC9onCx5otgFfRm7Lm+I+wwxOx738M/WLPZ9Q42m4IG5W0FNX8WLL2gYMZo3JkuXIH2DOpWM+qwA== dependencies: "@babel/helper-plugin-utils" "^7.0.0" "@istanbuljs/load-nyc-config" "^1.0.0" "@istanbuljs/schema" "^0.1.2" - istanbul-lib-instrument "^4.0.0" + istanbul-lib-instrument "^5.0.4" test-exclude "^6.0.0" -babel-plugin-jest-hoist@^27.2.0: - version "27.2.0" - resolved "https://registry.yarnpkg.com/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-27.2.0.tgz#79f37d43f7e5c4fdc4b2ca3e10cc6cf545626277" - integrity sha512-TOux9khNKdi64mW+0OIhcmbAn75tTlzKhxmiNXevQaPbrBYK7YKjP1jl6NHTJ6XR5UgUrJbCnWlKVnJn29dfjw== +babel-plugin-jest-hoist@^29.6.3: + version "29.6.3" + resolved "https://registry.yarnpkg.com/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-29.6.3.tgz#aadbe943464182a8922c3c927c3067ff40d24626" + integrity sha512-ESAc/RJvGTFEzRwOTT4+lNDk/GNHMkKbNzsvT0qKRfDyyYTskxB5rnU2njIDYVxXCBHHEI1c0YwHob3WaYujOg== dependencies: "@babel/template" "^7.3.3" "@babel/types" "^7.3.3" - "@types/babel__core" "^7.0.0" + "@types/babel__core" "^7.1.14" "@types/babel__traverse" "^7.0.6" babel-preset-current-node-syntax@^1.0.0: @@ -979,12 +871,12 @@ babel-preset-current-node-syntax@^1.0.0: "@babel/plugin-syntax-optional-chaining" "^7.8.3" "@babel/plugin-syntax-top-level-await" "^7.8.3" -babel-preset-jest@^27.2.0: - version "27.2.0" - resolved "https://registry.yarnpkg.com/babel-preset-jest/-/babel-preset-jest-27.2.0.tgz#556bbbf340608fed5670ab0ea0c8ef2449fba885" - integrity sha512-z7MgQ3peBwN5L5aCqBKnF6iqdlvZvFUQynEhu0J+X9nHLU72jO3iY331lcYrg+AssJ8q7xsv5/3AICzVmJ/wvg== +babel-preset-jest@^29.6.3: + version "29.6.3" + resolved "https://registry.yarnpkg.com/babel-preset-jest/-/babel-preset-jest-29.6.3.tgz#fa05fa510e7d493896d7b0dd2033601c840f171c" + integrity sha512-0B3bhxR6snWXJZtR/RliHTDPRgn1sNHOR0yVtq/IiQFyuOVjFS+wuio/R4gSNkyYmKmJB4wGZv2NZanmKmTnNA== dependencies: - babel-plugin-jest-hoist "^27.2.0" + babel-plugin-jest-hoist "^29.6.3" babel-preset-current-node-syntax "^1.0.0" balanced-match@^1.0.0: @@ -1000,35 +892,22 @@ brace-expansion@^1.1.7: balanced-match "^1.0.0" concat-map "0.0.1" -braces@^3.0.1: +braces@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== dependencies: fill-range "^7.0.1" -browser-process-hrtime@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/browser-process-hrtime/-/browser-process-hrtime-1.0.0.tgz#3c9b4b7d782c8121e56f10106d84c0d0ffc94626" - integrity sha512-9o5UecI3GhkpM6DrXr69PblIuWxPKk9Y0jHBRhdocZ2y7YECBFCsHm79Pr3OyR2AvjhDkabFJaDJMYRazHgsow== - -browserslist@^4.16.6: - version "4.17.0" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.17.0.tgz#1fcd81ec75b41d6d4994fb0831b92ac18c01649c" - integrity sha512-g2BJ2a0nEYvEFQC208q8mVAhfNwpZ5Mu8BwgtCdZKO3qx98HChmeg448fPdUzld8aFmfLgVh7yymqV+q1lJZ5g== +browserslist@^4.21.9: + version "4.22.1" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.22.1.tgz#ba91958d1a59b87dab6fed8dfbcb3da5e2e9c619" + integrity sha512-FEVc202+2iuClEhZhrWy6ZiAcRLvNMyYcxZ8raemul1DYVOVdFsbqckWLdsixQZCpJlwe77Z3UTalE7jsjnKfQ== dependencies: - caniuse-lite "^1.0.30001254" - colorette "^1.3.0" - electron-to-chromium "^1.3.830" - escalade "^3.1.1" - node-releases "^1.1.75" - -bs-logger@0.x: - version "0.2.6" - resolved "https://registry.yarnpkg.com/bs-logger/-/bs-logger-0.2.6.tgz#eb7d365307a72cf974cc6cda76b68354ad336bd8" - integrity sha512-pd8DCoxmbgc7hyPKOvxtqNcjYoOsABPQdcCUjGp3d42VR2CX1ORhk2A87oqqu5R1kk+76nsxZupkmyd+MVtCog== - dependencies: - fast-json-stable-stringify "2.x" + caniuse-lite "^1.0.30001541" + electron-to-chromium "^1.4.535" + node-releases "^2.0.13" + update-browserslist-db "^1.0.13" bser@2.1.1: version "2.1.1" @@ -1053,16 +932,16 @@ camelcase@^5.3.1: integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg== camelcase@^6.2.0: - version "6.2.0" - resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.2.0.tgz#924af881c9d525ac9d87f40d964e5cea982a1809" - integrity sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg== + version "6.3.0" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a" + integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== -caniuse-lite@^1.0.30001254: - version "1.0.30001259" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001259.tgz#ae21691d3da9c4be6144403ac40f71d9f6efd790" - integrity sha512-V7mQTFhjITxuk9zBpI6nYsiTXhcPe05l+364nZjK7MFK/E7ibvYBSAXr4YcA6oPR8j3ZLM/LN+lUqUVAQEUZFg== +caniuse-lite@^1.0.30001541: + version "1.0.30001563" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001563.tgz#aa68a64188903e98f36eb9c56e48fba0c1fe2a32" + integrity sha512-na2WUmOxnwIZtwnFI2CZ/3er0wdNzU7hN+cPYz/z2ajHThnkWjNBOpEPP4n+4r2WPM847JaMotaJE3bnfzjyKw== -chalk@^2.0.0: +chalk@^2.4.2: version "2.4.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== @@ -1071,14 +950,6 @@ chalk@^2.0.0: escape-string-regexp "^1.0.5" supports-color "^5.3.0" -chalk@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-3.0.0.tgz#3f73c2bf526591f574cc492c51e2456349f844e4" - integrity sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg== - dependencies: - ansi-styles "^4.1.0" - supports-color "^7.1.0" - chalk@^4.0.0: version "4.1.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" @@ -1092,34 +963,34 @@ char-regex@^1.0.2: resolved "https://registry.yarnpkg.com/char-regex/-/char-regex-1.0.2.tgz#d744358226217f981ed58f479b1d6bcc29545dcf" integrity sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw== -ci-info@^3.1.1, ci-info@^3.2.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-3.2.0.tgz#2876cb948a498797b5236f0095bc057d0dca38b6" - integrity sha512-dVqRX7fLUm8J6FgHJ418XuIgDLZDkYcDFTeL6TA2gt5WlIZUQrrH6EZrNClwT/H0FateUsZkGIOPRrLbP+PR9A== +ci-info@^3.2.0: + version "3.9.0" + resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-3.9.0.tgz#4279a62028a7b1f262f3473fc9605f5e218c59b4" + integrity sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ== cjs-module-lexer@^1.0.0: - version "1.2.2" - resolved "https://registry.yarnpkg.com/cjs-module-lexer/-/cjs-module-lexer-1.2.2.tgz#9f84ba3244a512f3a54e5277e8eef4c489864e40" - integrity sha512-cOU9usZw8/dXIXKtwa8pM0OTJQuJkxMN6w30csNRUerHfeQ5R6U3kkU/FtJeIf3M202OHfY2U8ccInBG7/xogA== + version "1.2.3" + resolved "https://registry.yarnpkg.com/cjs-module-lexer/-/cjs-module-lexer-1.2.3.tgz#6c370ab19f8a3394e318fe682686ec0ac684d107" + integrity sha512-0TNiGstbQmCFwt4akjjBg5pLRTSyj/PkWQ1ZoO2zntmg9yLqSRxwEa4iCfQLGjqhiqBfOJa7W/E8wfGrTDmlZQ== -cliui@^7.0.2: - version "7.0.4" - resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f" - integrity sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ== +cliui@^8.0.1: + version "8.0.1" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-8.0.1.tgz#0c04b075db02cbfe60dc8e6cf2f5486b1a3608aa" + integrity sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ== dependencies: string-width "^4.2.0" - strip-ansi "^6.0.0" + strip-ansi "^6.0.1" wrap-ansi "^7.0.0" co@^4.6.0: version "4.6.0" resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" - integrity sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ= + integrity sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ== collect-v8-coverage@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/collect-v8-coverage/-/collect-v8-coverage-1.0.1.tgz#cc2c8e94fc18bbdffe64d6534570c8a673b27f59" - integrity sha512-iBPtljfCNcTKNAto0KEtDfZ3qzjJvqE3aTGZsbhjSBlorqpXJlaWWtPO35D+ZImoC3KWejX64o+yPGxhWSTzfg== + version "1.0.2" + resolved "https://registry.yarnpkg.com/collect-v8-coverage/-/collect-v8-coverage-1.0.2.tgz#c0b29bcd33bcd0779a1344c2136051e6afd3d9e9" + integrity sha512-lHl4d5/ONEbLlJvaJNtsF/Lz+WvB07u2ycqTYbdrq7UypDXailES4valYb2eWiJFxZlVmpGekfqoxQhzyFdT4Q== color-convert@^1.9.0: version "1.9.3" @@ -1138,43 +1009,37 @@ color-convert@^2.0.1: color-name@1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" - integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= + integrity sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw== color-name@~1.1.4: version "1.1.4" resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== -colorette@^1.3.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/colorette/-/colorette-1.4.0.tgz#5190fbb87276259a86ad700bff2c6d6faa3fca40" - integrity sha512-Y2oEozpomLn7Q3HFP7dpww7AtMJplbM9lGZP6RDfHqmbeRjiwRg4n6VM6j4KLmRke85uWEI7JqF17f3pqdRA0g== - -combined-stream@^1.0.8: - version "1.0.8" - resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f" - integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg== - dependencies: - delayed-stream "~1.0.0" - concat-map@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" - integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= + integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== -convert-source-map@^1.4.0, convert-source-map@^1.6.0, convert-source-map@^1.7.0: - version "1.8.0" - resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.8.0.tgz#f3373c32d21b4d780dd8004514684fb791ca4369" - integrity sha512-+OQdjP49zViI/6i7nIJpA8rAl4sV/JdPfU9nZs3VqOwGIgizICvuN2ru6fMd+4llL0tar18UYJXfZ/TWtmhUjA== - dependencies: - safe-buffer "~5.1.1" +convert-source-map@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-2.0.0.tgz#4b560f649fc4e918dd0ab75cf4961e8bc882d82a" + integrity sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg== -create-require@^1.1.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/create-require/-/create-require-1.1.1.tgz#c1d7e8f1e5f6cfc9ff65f9cd352d37348756c333" - integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ== +create-jest@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/create-jest/-/create-jest-29.7.0.tgz#a355c5b3cb1e1af02ba177fe7afd7feee49a5320" + integrity sha512-Adz2bdH0Vq3F53KEMJOoftQFutWCukm6J24wbPWRO4k1kMY7gS7ds/uoJkNuV8wDCtWWnuwGcJwpWcih+zEW1Q== + dependencies: + "@jest/types" "^29.6.3" + chalk "^4.0.0" + exit "^0.1.2" + graceful-fs "^4.2.9" + jest-config "^29.7.0" + jest-util "^29.7.0" + prompts "^2.0.1" -cross-spawn@^7.0.0, cross-spawn@^7.0.2, cross-spawn@^7.0.3: +cross-spawn@^7.0.3: version "7.0.3" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== @@ -1183,128 +1048,68 @@ cross-spawn@^7.0.0, cross-spawn@^7.0.2, cross-spawn@^7.0.3: shebang-command "^2.0.0" which "^2.0.1" -cssom@^0.4.4: - version "0.4.4" - resolved "https://registry.yarnpkg.com/cssom/-/cssom-0.4.4.tgz#5a66cf93d2d0b661d80bf6a44fb65f5c2e4e0a10" - integrity sha512-p3pvU7r1MyyqbTk+WbNJIgJjG2VmTIaB10rI93LzVPrmDJKkzKYMtxxyAvQXR/NS6otuzveI7+7BBq3SjBS2mw== - -cssom@~0.3.6: - version "0.3.8" - resolved "https://registry.yarnpkg.com/cssom/-/cssom-0.3.8.tgz#9f1276f5b2b463f2114d3f2c75250af8c1a36f4a" - integrity sha512-b0tGHbfegbhPJpxpiBPU2sCkigAqtM9O121le6bbOlgyV+NyGyCmVfJ6QW9eRjz8CpNfWEOYBIMIGRYkLwsIYg== - -cssstyle@^2.3.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/cssstyle/-/cssstyle-2.3.0.tgz#ff665a0ddbdc31864b09647f34163443d90b0852" - integrity sha512-AZL67abkUzIuvcHqk7c09cezpGNcxUxU4Ioi/05xHk4DQeTkWmGYftIE6ctU6AEt+Gn4n1lDStOtj7FKycP71A== - dependencies: - cssom "~0.3.6" - -data-urls@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/data-urls/-/data-urls-2.0.0.tgz#156485a72963a970f5d5821aaf642bef2bf2db9b" - integrity sha512-X5eWTSXO/BJmpdIKCRuKUgSCgAN0OwliVK3yPKbwIWU1Tdw5BRajxlzMidvh+gwko9AfQ9zIj52pzF91Q3YAvQ== +cross-spawn@^7.0.6: + version "7.0.6" + resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.6.tgz#8a58fe78f00dcd70c370451759dfbfaf03e8ee9f" + integrity sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA== dependencies: - abab "^2.0.3" - whatwg-mimetype "^2.3.0" - whatwg-url "^8.0.0" + path-key "^3.1.0" + shebang-command "^2.0.0" + which "^2.0.1" -debug@4, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1: - version "4.3.2" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.2.tgz#f0a49c18ac8779e31d4a0c6029dfb76873c7428b" - integrity sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw== +debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2: + version "4.3.4" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" + integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== dependencies: ms "2.1.2" -decimal.js@^10.2.1: - version "10.3.1" - resolved "https://registry.yarnpkg.com/decimal.js/-/decimal.js-10.3.1.tgz#d8c3a444a9c6774ba60ca6ad7261c3a94fd5e783" - integrity sha512-V0pfhfr8suzyPGOx3nmq4aHqabehUZn6Ch9kyFpV79TGDTWFmHqUqXdabR7QHqxzrYolF4+tVmJhUG4OURg5dQ== +dedent@^1.0.0: + version "1.5.1" + resolved "https://registry.yarnpkg.com/dedent/-/dedent-1.5.1.tgz#4f3fc94c8b711e9bb2800d185cd6ad20f2a90aff" + integrity sha512-+LxW+KLWxu3HW3M2w2ympwtqPrqYRzU8fqi6Fhd18fBALe15blJPI/I4+UHveMVG6lJqB4JNd4UG0S5cnVHwIg== -dedent@^0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/dedent/-/dedent-0.7.0.tgz#2495ddbaf6eb874abb0e1be9df22d2e5a544326c" - integrity sha1-JJXduvbrh0q7Dhvp3yLS5aVEMmw= - -deep-is@^0.1.3, deep-is@~0.1.3: +deep-is@^0.1.3: version "0.1.4" resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.4.tgz#a6f2dce612fadd2ef1f519b73551f17e85199831" integrity sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ== deepmerge@^4.2.2: - version "4.2.2" - resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-4.2.2.tgz#44d2ea3679b8f4d4ffba33f03d865fc1e7bf4955" - integrity sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg== - -delayed-stream@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" - integrity sha1-3zrhmayt+31ECqrgsp4icrJOxhk= + version "4.3.1" + resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-4.3.1.tgz#44b5f2147cd3b00d4b56137685966f26fd25dd4a" + integrity sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A== detect-newline@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/detect-newline/-/detect-newline-3.1.0.tgz#576f5dfc63ae1a192ff192d8ad3af6308991b651" integrity sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA== -diff-sequences@^27.0.6: - version "27.0.6" - resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-27.0.6.tgz#3305cb2e55a033924054695cc66019fd7f8e5723" - integrity sha512-ag6wfpBFyNXZ0p8pcuIDS//D8H062ZQJ3fzYxjpmeKjnz8W4pekL3AI8VohmyZmsWW2PWaHgjsmqR6L13101VQ== - -diff@^4.0.1: - version "4.0.2" - resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d" - integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A== - -dir-glob@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/dir-glob/-/dir-glob-3.0.1.tgz#56dbf73d992a4a93ba1584f4534063fd2e41717f" - integrity sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA== - dependencies: - path-type "^4.0.0" - -doctrine@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-3.0.0.tgz#addebead72a6574db783639dc87a121773973961" - integrity sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w== - dependencies: - esutils "^2.0.2" +diff-sequences@^29.6.3: + version "29.6.3" + resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-29.6.3.tgz#4deaf894d11407c51efc8418012f9e70b84ea921" + integrity sha512-EjePK1srD3P08o2j4f0ExnylqRs5B9tJjcp9t1krH2qRi8CCdsYfwe9JgSLurFBWwq4uOlipzfk5fHNvwFKr8Q== -domexception@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/domexception/-/domexception-2.0.1.tgz#fb44aefba793e1574b0af6aed2801d057529f304" - integrity sha512-yxJ2mFy/sibVQlu5qHjOkf9J3K6zgmCxgJ94u2EdvDOV09H+32LtRswEcUsmUWN72pVLOEnTSRaIVVzVQgS0dg== - dependencies: - webidl-conversions "^5.0.0" - -electron-to-chromium@^1.3.830: - version "1.3.845" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.845.tgz#326d3be3ee5d2c065f689119d441c997f9fd41d8" - integrity sha512-y0RorqmExFDI4RjLEC6j365bIT5UAXf9WIRcknvSFHVhbC/dRnCgJnPA3DUUW6SCC85QGKEafgqcHJ6uPdEP1Q== +electron-to-chromium@^1.4.535: + version "1.4.588" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.588.tgz#d553f3c008e73488fb181fdf2601fdb0b1ffbb78" + integrity sha512-soytjxwbgcCu7nh5Pf4S2/4wa6UIu+A3p03U2yVr53qGxi1/VTR3ENI+p50v+UxqqZAfl48j3z55ud7VHIOr9w== -emittery@^0.8.1: - version "0.8.1" - resolved "https://registry.yarnpkg.com/emittery/-/emittery-0.8.1.tgz#bb23cc86d03b30aa75a7f734819dee2e1ba70860" - integrity sha512-uDfvUjVrfGJJhymx/kz6prltenw1u7WrCg1oa94zYY8xxVpLLUu045LAT0dhDZdXG58/EpPL/5kA180fQ/qudg== +emittery@^0.13.1: + version "0.13.1" + resolved "https://registry.yarnpkg.com/emittery/-/emittery-0.13.1.tgz#c04b8c3457490e0847ae51fced3af52d338e3dad" + integrity sha512-DeWwawk6r5yR9jFgnDKYt4sLS0LmHJJi3ZOnb5/JdbYwj3nW+FxQnHIjhBKz8YLC7oRNPVM9NQ47I3CVx34eqQ== emoji-regex@^8.0.0: version "8.0.0" resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== -end-of-stream@^1.1.0: - version "1.4.4" - resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.4.tgz#5ae64a5f45057baf3626ec14da0ca5e4b2431eb0" - integrity sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q== - dependencies: - once "^1.4.0" - -enquirer@^2.3.5: - version "2.3.6" - resolved "https://registry.yarnpkg.com/enquirer/-/enquirer-2.3.6.tgz#2a7fe5dd634a1e4125a975ec994ff5456dc3734d" - integrity sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg== +error-ex@^1.3.1: + version "1.3.2" + resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf" + integrity sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g== dependencies: - ansi-colors "^4.1.1" + is-arrayish "^0.2.1" escalade@^3.1.1: version "3.1.1" @@ -1314,7 +1119,7 @@ escalade@^3.1.1: escape-string-regexp@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" - integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= + integrity sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg== escape-string-regexp@^2.0.0: version "2.0.0" @@ -1326,119 +1131,101 @@ escape-string-regexp@^4.0.0: resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== -escodegen@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-2.0.0.tgz#5e32b12833e8aa8fa35e1bf0befa89380484c7dd" - integrity sha512-mmHKys/C8BFUGI+MAWNcSYoORYLMdPzjrknd2Vc+bUsjN5bXcr8EhrNB+UTqfL1y3I9c4fw2ihgtMPQLBRiQxw== - dependencies: - esprima "^4.0.1" - estraverse "^5.2.0" - esutils "^2.0.2" - optionator "^0.8.1" - optionalDependencies: - source-map "~0.6.1" - -eslint-config-prettier@^8.0.0: - version "8.3.0" - resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-8.3.0.tgz#f7471b20b6fe8a9a9254cc684454202886a2dd7a" - integrity sha512-BgZuLUSeKzvlL/VUjx/Yb787VQ26RU3gGjA3iiFvdsp/2bMfVIWUVP7tjxtjS0e+HP409cPlPvNkQloz8C91ew== +eslint-config-prettier@^10.0.2: + version "10.0.2" + resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-10.0.2.tgz#47444de8aa104ce82c2f91ad2a5e96b62c01e20d" + integrity sha512-1105/17ZIMjmCOJOPNfVdbXafLCLj3hPmkmB7dLgt7XsQ/zkxSuDerE/xgO3RxoHysR1N1whmquY0lSn2O0VLg== -eslint-scope@^5.1.1: - version "5.1.1" - resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c" - integrity sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw== +eslint-scope@^8.2.0: + version "8.2.0" + resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-8.2.0.tgz#377aa6f1cb5dc7592cfd0b7f892fd0cf352ce442" + integrity sha512-PHlWUfG6lvPc3yvP5A4PNyBL1W8fkDUccmI21JUu/+GKZBoH/W5u6usENXUrWFRsyoW5ACUjFGgAFQp5gUlb/A== dependencies: esrecurse "^4.3.0" - estraverse "^4.1.1" + estraverse "^5.2.0" -eslint-utils@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-2.1.0.tgz#d2de5e03424e707dc10c74068ddedae708741b27" - integrity sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg== - dependencies: - eslint-visitor-keys "^1.1.0" +eslint-visitor-keys@^3.3.0: + version "3.4.3" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz#0cd72fe8550e3c2eae156a96a4dddcd1c8ac5800" + integrity sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag== -eslint-utils@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-3.0.0.tgz#8aebaface7345bb33559db0a1f13a1d2d48c3672" - integrity sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA== - dependencies: - eslint-visitor-keys "^2.0.0" - -eslint-visitor-keys@^1.1.0, eslint-visitor-keys@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz#30ebd1ef7c2fdff01c3a4f151044af25fab0523e" - integrity sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ== +eslint-visitor-keys@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-4.0.0.tgz#e3adc021aa038a2a8e0b2f8b0ce8f66b9483b1fb" + integrity sha512-OtIRv/2GyiF6o/d8K7MYKKbXrOUBIK6SfkIRM4Z0dY3w+LiQ0vy3F57m0Z71bjbyeiWFiHJ8brqnmE6H6/jEuw== -eslint-visitor-keys@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz#f65328259305927392c938ed44eb0a5c9b2bd303" - integrity sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw== - -eslint@^7.22.0: - version "7.32.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.32.0.tgz#c6d328a14be3fb08c8d1d21e12c02fdb7a2a812d" - integrity sha512-VHZ8gX+EDfz+97jGcgyGCyRia/dPOd6Xh9yPv8Bl1+SoaIwD+a/vlrOmGRUyOYu7MwUhc7CxqeaDZU13S4+EpA== - dependencies: - "@babel/code-frame" "7.12.11" - "@eslint/eslintrc" "^0.4.3" - "@humanwhocodes/config-array" "^0.5.0" - ajv "^6.10.0" +eslint-visitor-keys@^4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz#687bacb2af884fcdda8a6e7d65c606f46a14cd45" + integrity sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw== + +eslint@^9.21.0: + version "9.21.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-9.21.0.tgz#b1c9c16f5153ff219791f627b94ab8f11f811591" + integrity sha512-KjeihdFqTPhOMXTt7StsDxriV4n66ueuF/jfPNC3j/lduHwr/ijDwJMsF+wyMJethgiKi5wniIE243vi07d3pg== + dependencies: + "@eslint-community/eslint-utils" "^4.2.0" + "@eslint-community/regexpp" "^4.12.1" + "@eslint/config-array" "^0.19.2" + "@eslint/core" "^0.12.0" + "@eslint/eslintrc" "^3.3.0" + "@eslint/js" "9.21.0" + "@eslint/plugin-kit" "^0.2.7" + "@humanfs/node" "^0.16.6" + "@humanwhocodes/module-importer" "^1.0.1" + "@humanwhocodes/retry" "^0.4.2" + "@types/estree" "^1.0.6" + "@types/json-schema" "^7.0.15" + ajv "^6.12.4" chalk "^4.0.0" - cross-spawn "^7.0.2" - debug "^4.0.1" - doctrine "^3.0.0" - enquirer "^2.3.5" + cross-spawn "^7.0.6" + debug "^4.3.2" escape-string-regexp "^4.0.0" - eslint-scope "^5.1.1" - eslint-utils "^2.1.0" - eslint-visitor-keys "^2.0.0" - espree "^7.3.1" - esquery "^1.4.0" + eslint-scope "^8.2.0" + eslint-visitor-keys "^4.2.0" + espree "^10.3.0" + esquery "^1.5.0" esutils "^2.0.2" fast-deep-equal "^3.1.3" - file-entry-cache "^6.0.1" - functional-red-black-tree "^1.0.1" - glob-parent "^5.1.2" - globals "^13.6.0" - ignore "^4.0.6" - import-fresh "^3.0.0" + file-entry-cache "^8.0.0" + find-up "^5.0.0" + glob-parent "^6.0.2" + ignore "^5.2.0" imurmurhash "^0.1.4" is-glob "^4.0.0" - js-yaml "^3.13.1" json-stable-stringify-without-jsonify "^1.0.1" - levn "^0.4.1" lodash.merge "^4.6.2" - minimatch "^3.0.4" + minimatch "^3.1.2" natural-compare "^1.4.0" - optionator "^0.9.1" - progress "^2.0.0" - regexpp "^3.1.0" - semver "^7.2.1" - strip-ansi "^6.0.0" - strip-json-comments "^3.1.0" - table "^6.0.9" - text-table "^0.2.0" - v8-compile-cache "^2.0.3" + optionator "^0.9.3" + +espree@^10.0.1: + version "10.0.1" + resolved "https://registry.yarnpkg.com/espree/-/espree-10.0.1.tgz#600e60404157412751ba4a6f3a2ee1a42433139f" + integrity sha512-MWkrWZbJsL2UwnjxTX3gG8FneachS/Mwg7tdGXce011sJd5b0JG54vat5KHnfSBODZ3Wvzd2WnjxyzsRoVv+ww== + dependencies: + acorn "^8.11.3" + acorn-jsx "^5.3.2" + eslint-visitor-keys "^4.0.0" -espree@^7.3.0, espree@^7.3.1: - version "7.3.1" - resolved "https://registry.yarnpkg.com/espree/-/espree-7.3.1.tgz#f2df330b752c6f55019f8bd89b7660039c1bbbb6" - integrity sha512-v3JCNCE64umkFpmkFGqzVKsOT0tN1Zr+ueqLZfpV1Ob8e+CEgPWa+OxCoGH3tnhimMKIaBm4m/vaRpJ/krRz2g== +espree@^10.3.0: + version "10.3.0" + resolved "https://registry.yarnpkg.com/espree/-/espree-10.3.0.tgz#29267cf5b0cb98735b65e64ba07e0ed49d1eed8a" + integrity sha512-0QYC8b24HWY8zjRnDTL6RiHfDbAWn63qb4LMj1Z4b076A4une81+z03Kg7l7mn/48PUTqoLptSXez8oknU8Clg== dependencies: - acorn "^7.4.0" - acorn-jsx "^5.3.1" - eslint-visitor-keys "^1.3.0" + acorn "^8.14.0" + acorn-jsx "^5.3.2" + eslint-visitor-keys "^4.2.0" -esprima@^4.0.0, esprima@^4.0.1: +esprima@^4.0.0: version "4.0.1" resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== -esquery@^1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.4.0.tgz#2148ffc38b82e8c7057dfed48425b3e61f0f24a5" - integrity sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w== +esquery@^1.5.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.6.0.tgz#91419234f804d852a82dceec3e16cdc22cf9dae7" + integrity sha512-ca9pw9fomFcKPvFLXhBKUK90ZvGibiGOvRJNbjljY7s7uq/5YO4BOzcYtJqExdx99rF6aAcnRxHmcUHcz6sQsg== dependencies: estraverse "^5.1.0" @@ -1449,36 +1236,16 @@ esrecurse@^4.3.0: dependencies: estraverse "^5.2.0" -estraverse@^4.1.1: - version "4.3.0" - resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.3.0.tgz#398ad3f3c5a24948be7725e83d11a7de28cdbd1d" - integrity sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw== - estraverse@^5.1.0, estraverse@^5.2.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.2.0.tgz#307df42547e6cc7324d3cf03c155d5cdb8c53880" - integrity sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ== + version "5.3.0" + resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.3.0.tgz#2eea5290702f26ab8fe5370370ff86c965d21123" + integrity sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA== esutils@^2.0.2: version "2.0.3" resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== -execa@^4.0.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/execa/-/execa-4.1.0.tgz#4e5491ad1572f2f17a77d388c6c857135b22847a" - integrity sha512-j5W0//W7f8UxAn8hXVnwG8tLwdiUy4FJLcSupCg6maBYZDpyBvTApK7KyuI4bKj8KOh1r2YH+6ucuYtJv1bTZA== - dependencies: - cross-spawn "^7.0.0" - get-stream "^5.0.0" - human-signals "^1.1.1" - is-stream "^2.0.0" - merge-stream "^2.0.0" - npm-run-path "^4.0.0" - onetime "^5.1.0" - signal-exit "^3.0.2" - strip-final-newline "^2.0.0" - execa@^5.0.0: version "5.1.1" resolved "https://registry.yarnpkg.com/execa/-/execa-5.1.1.tgz#f80ad9cbf4298f7bd1d4c9555c21e93741c411dd" @@ -1497,66 +1264,47 @@ execa@^5.0.0: exit@^0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/exit/-/exit-0.1.2.tgz#0632638f8d877cc82107d30a0fff1a17cba1cd0c" - integrity sha1-BjJjj42HfMghB9MKD/8aF8uhzQw= + integrity sha512-Zk/eNKV2zbjpKzrsQ+n1G6poVbErQxJ0LBOJXaKZ1EViLzH+hrLu9cdXI4zw9dBQJslwBEpbQ2P1oS7nDxs6jQ== -expect@^27.3.1: - version "27.3.1" - resolved "https://registry.yarnpkg.com/expect/-/expect-27.3.1.tgz#d0f170b1f5c8a2009bab0beffd4bb94f043e38e7" - integrity sha512-MrNXV2sL9iDRebWPGOGFdPQRl2eDQNu/uhxIMShjjx74T6kC6jFIkmQ6OqXDtevjGUkyB2IT56RzDBqXf/QPCg== +expect@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/expect/-/expect-29.7.0.tgz#578874590dcb3214514084c08115d8aee61e11bc" + integrity sha512-2Zks0hf1VLFYI1kbh0I5jP3KHHyCHpkfyHBzsSXRFgl/Bg9mWYfMW8oD+PdMPlEwy5HNsR9JutYy6pMeOh61nw== dependencies: - "@jest/types" "^27.2.5" - ansi-styles "^5.0.0" - jest-get-type "^27.3.1" - jest-matcher-utils "^27.3.1" - jest-message-util "^27.3.1" - jest-regex-util "^27.0.6" + "@jest/expect-utils" "^29.7.0" + jest-get-type "^29.6.3" + jest-matcher-utils "^29.7.0" + jest-message-util "^29.7.0" + jest-util "^29.7.0" fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: version "3.1.3" resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== -fast-glob@^3.1.1: - version "3.2.7" - resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.7.tgz#fd6cb7a2d7e9aa7a7846111e85a196d6b2f766a1" - integrity sha512-rYGMRwip6lUMvYD3BTScMwT1HtAs2d71SMv66Vrxs0IekGZEjhM0pcMfjQPnknBt2zeCwQMEupiN02ZP4DiT1Q== - dependencies: - "@nodelib/fs.stat" "^2.0.2" - "@nodelib/fs.walk" "^1.2.3" - glob-parent "^5.1.2" - merge2 "^1.3.0" - micromatch "^4.0.4" - -fast-json-stable-stringify@2.x, fast-json-stable-stringify@^2.0.0: +fast-json-stable-stringify@^2.0.0, fast-json-stable-stringify@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw== -fast-levenshtein@^2.0.6, fast-levenshtein@~2.0.6: +fast-levenshtein@^2.0.6: version "2.0.6" resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" - integrity sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc= - -fastq@^1.6.0: - version "1.13.0" - resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.13.0.tgz#616760f88a7526bdfc596b7cab8c18938c36b98c" - integrity sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw== - dependencies: - reusify "^1.0.4" + integrity sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw== fb-watchman@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/fb-watchman/-/fb-watchman-2.0.1.tgz#fc84fb39d2709cf3ff6d743706157bb5708a8a85" - integrity sha512-DkPJKQeY6kKwmuMretBhr7G6Vodr7bFwDYTXIkfG1gjvNpaxBTQV3PbXg6bR1c1UP4jPOX0jHUbbHANL9vRjVg== + version "2.0.2" + resolved "https://registry.yarnpkg.com/fb-watchman/-/fb-watchman-2.0.2.tgz#e9524ee6b5c77e9e5001af0f85f3adbb8623255c" + integrity sha512-p5161BqbuCaSnB8jIbzQHOlpgsPmK5rJVDfDKO91Axs5NC1uu3HRQm6wt9cd9/+GtQQIO53JdGXXoyDpTAsgYA== dependencies: bser "2.1.1" -file-entry-cache@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-6.0.1.tgz#211b2dd9659cb0394b073e7323ac3c933d522027" - integrity sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg== +file-entry-cache@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-8.0.0.tgz#7787bddcf1131bffb92636c69457bbc0edd6d81f" + integrity sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ== dependencies: - flat-cache "^3.0.4" + flat-cache "^4.0.0" fill-range@^7.0.1: version "7.0.1" @@ -1573,47 +1321,41 @@ find-up@^4.0.0, find-up@^4.1.0: locate-path "^5.0.0" path-exists "^4.0.0" -flat-cache@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-3.0.4.tgz#61b0338302b2fe9f957dcc32fc2a87f1c3048b11" - integrity sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg== +find-up@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-5.0.0.tgz#4c92819ecb7083561e4f4a240a86be5198f536fc" + integrity sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng== dependencies: - flatted "^3.1.0" - rimraf "^3.0.2" - -flatted@^3.1.0: - version "3.2.2" - resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.2.tgz#64bfed5cb68fe3ca78b3eb214ad97b63bedce561" - integrity sha512-JaTY/wtrcSyvXJl4IMFHPKyFur1sE9AUqc0QnhOaJ0CxHtAoIV8pYDzeEfAaNEtGkOfq4gr3LBFmdXW5mOQFnA== + locate-path "^6.0.0" + path-exists "^4.0.0" -form-data@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/form-data/-/form-data-3.0.1.tgz#ebd53791b78356a99af9a300d4282c4d5eb9755f" - integrity sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg== +flat-cache@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-4.0.1.tgz#0ece39fcb14ee012f4b0410bd33dd9c1f011127c" + integrity sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw== dependencies: - asynckit "^0.4.0" - combined-stream "^1.0.8" - mime-types "^2.1.12" + flatted "^3.2.9" + keyv "^4.5.4" + +flatted@^3.2.9: + version "3.2.9" + resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.9.tgz#7eb4c67ca1ba34232ca9d2d93e9886e611ad7daf" + integrity sha512-36yxDn5H7OFZQla0/jFJmbIKTdZAQHngCedGxiMmpNfEZM0sdEeT+WczLQrjK6D7o2aiyLYDnkw0R3JK0Qv1RQ== fs.realpath@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" - integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= + integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== fsevents@^2.3.2: - version "2.3.2" - resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" - integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== - -function-bind@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" - integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== + version "2.3.3" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6" + integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw== -functional-red-black-tree@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327" - integrity sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc= +function-bind@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.2.tgz#2c02d864d97f3ea6c8830c464cbd11ab6eab7a1c" + integrity sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA== gensync@^1.0.0-beta.2: version "1.0.0-beta.2" @@ -1630,34 +1372,27 @@ get-package-type@^0.1.0: resolved "https://registry.yarnpkg.com/get-package-type/-/get-package-type-0.1.0.tgz#8de2d803cff44df3bc6c456e6668b36c3926e11a" integrity sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q== -get-stream@^5.0.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-5.2.0.tgz#4966a1795ee5ace65e706c4b7beb71257d6e22d3" - integrity sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA== - dependencies: - pump "^3.0.0" - get-stream@^6.0.0: version "6.0.1" resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-6.0.1.tgz#a262d8eef67aced57c2852ad6167526a43cbf7b7" integrity sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg== -glob-parent@^5.1.2: - version "5.1.2" - resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" - integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== +glob-parent@^6.0.2: + version "6.0.2" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-6.0.2.tgz#6d237d99083950c79290f24c7642a3de9a28f9e3" + integrity sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A== dependencies: - is-glob "^4.0.1" + is-glob "^4.0.3" -glob@^7.1.1, glob@^7.1.2, glob@^7.1.3, glob@^7.1.4: - version "7.1.7" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.7.tgz#3b193e9233f01d42d0b3f78294bbeeb418f94a90" - integrity sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ== +glob@^7.1.3, glob@^7.1.4: + version "7.2.3" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b" + integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q== dependencies: fs.realpath "^1.0.0" inflight "^1.0.4" inherits "2" - minimatch "^3.0.4" + minimatch "^3.1.1" once "^1.3.0" path-is-absolute "^1.0.0" @@ -1666,109 +1401,64 @@ globals@^11.1.0: resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e" integrity sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA== -globals@^13.6.0, globals@^13.9.0: - version "13.11.0" - resolved "https://registry.yarnpkg.com/globals/-/globals-13.11.0.tgz#40ef678da117fe7bd2e28f1fab24951bd0255be7" - integrity sha512-08/xrJ7wQjK9kkkRoI3OFUBbLx4f+6x3SGwcPvQ0QH6goFDrOU2oyAWrmh3dJezu65buo+HBMzAMQy6rovVC3g== - dependencies: - type-fest "^0.20.2" +globals@^14.0.0: + version "14.0.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-14.0.0.tgz#898d7413c29babcf6bafe56fcadded858ada724e" + integrity sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ== -globby@^11.0.3: - version "11.0.4" - resolved "https://registry.yarnpkg.com/globby/-/globby-11.0.4.tgz#2cbaff77c2f2a62e71e9b2813a67b97a3a3001a5" - integrity sha512-9O4MVG9ioZJ08ffbcyVYyLOJLk5JQ688pJ4eMGLpdWLHq/Wr1D9BlriLQyL0E+jbkuePVZXYFj47QM/v093wHg== - dependencies: - array-union "^2.1.0" - dir-glob "^3.0.1" - fast-glob "^3.1.1" - ignore "^5.1.4" - merge2 "^1.3.0" - slash "^3.0.0" +globals@^16.0.0: + version "16.0.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-16.0.0.tgz#3d7684652c5c4fbd086ec82f9448214da49382d8" + integrity sha512-iInW14XItCXET01CQFqudPOWP2jYMl7T+QRQT+UNcR/iQncN/F0UNpgd76iFkBPgNQb4+X3LV9tLJYzwh+Gl3A== -graceful-fs@^4.2.4: - version "4.2.8" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.8.tgz#e412b8d33f5e006593cbd3cee6df9f2cebbe802a" - integrity sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg== +graceful-fs@^4.2.9: + version "4.2.11" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.11.tgz#4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3" + integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ== has-flag@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" - integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0= + integrity sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw== has-flag@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== -has@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" - integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== - dependencies: - function-bind "^1.1.1" - -html-encoding-sniffer@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/html-encoding-sniffer/-/html-encoding-sniffer-2.0.1.tgz#42a6dc4fd33f00281176e8b23759ca4e4fa185f3" - integrity sha512-D5JbOMBIR/TVZkubHT+OyT2705QvogUW4IBn6nHd756OwieSF9aDYFj4dv6HHEVGYbHaLETa3WggZYWWMyy3ZQ== +hasown@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/hasown/-/hasown-2.0.0.tgz#f4c513d454a57b7c7e1650778de226b11700546c" + integrity sha512-vUptKVTpIJhcczKBbgnS+RtcuYMB8+oNzPK2/Hp3hanz8JmpATdmmgLgSaadVREkDm+e2giHwY3ZRkyjSIDDFA== dependencies: - whatwg-encoding "^1.0.5" + function-bind "^1.1.2" html-escaper@^2.0.0: version "2.0.2" resolved "https://registry.yarnpkg.com/html-escaper/-/html-escaper-2.0.2.tgz#dfd60027da36a36dfcbe236262c00a5822681453" integrity sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg== -http-proxy-agent@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/http-proxy-agent/-/http-proxy-agent-4.0.1.tgz#8a8c8ef7f5932ccf953c296ca8291b95aa74aa3a" - integrity sha512-k0zdNgqWTGA6aeIRVpvfVob4fL52dTfaehylg0Y4UvSySvOq/Y+BOyPrgpUrA7HylqvU8vIZGsRuXmspskV0Tg== - dependencies: - "@tootallnate/once" "1" - agent-base "6" - debug "4" - -https-proxy-agent@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz#e2a90542abb68a762e0a0850f6c9edadfd8506b2" - integrity sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA== - dependencies: - agent-base "6" - debug "4" - -human-signals@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-1.1.1.tgz#c5b1cd14f50aeae09ab6c59fe63ba3395fe4dfa3" - integrity sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw== - human-signals@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-2.1.0.tgz#dc91fcba42e4d06e4abaed33b3e7a3c02f514ea0" integrity sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw== -husky@^7.0.0: - version "7.0.4" - resolved "https://registry.yarnpkg.com/husky/-/husky-7.0.4.tgz#242048245dc49c8fb1bf0cc7cfb98dd722531535" - integrity sha512-vbaCKN2QLtP/vD4yvs6iz6hBEo6wkSzs8HpRah1Z6aGmF2KW5PdYuAd7uX5a+OyBZHBhd+TFLqgjUgytQr4RvQ== - -iconv-lite@0.4.24: - version "0.4.24" - resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" - integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== - dependencies: - safer-buffer ">= 2.1.2 < 3" +husky@^9.1.7: + version "9.1.7" + resolved "https://registry.yarnpkg.com/husky/-/husky-9.1.7.tgz#d46a38035d101b46a70456a850ff4201344c0b2d" + integrity sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA== -ignore@^4.0.6: - version "4.0.6" - resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc" - integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg== +ignore@^5.2.0: + version "5.3.0" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.3.0.tgz#67418ae40d34d6999c95ff56016759c718c82f78" + integrity sha512-g7dmpshy+gD7mh88OC9NwSGTKoc3kyLAZQRU1mt53Aw/vnvfXnbC+F/7F7QoYVKbV+KNvJx8wArewKy1vXMtlg== -ignore@^5.1.4, ignore@^5.1.8: - version "5.1.8" - resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.1.8.tgz#f150a8b50a34289b33e22f5889abd4d8016f0e57" - integrity sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw== +ignore@^7.0.3: + version "7.0.3" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-7.0.3.tgz#397ef9315dfe0595671eefe8b633fec6943ab733" + integrity sha512-bAH5jbK/F3T3Jls4I0SO1hmPR0dKU0a7+SY6n1yzRtG54FLO8d6w/nxLFX2Nb7dBu6cCWXPaAME6cYqFUMmuCA== -import-fresh@^3.0.0, import-fresh@^3.2.1: +import-fresh@^3.2.1: version "3.3.0" resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.3.0.tgz#37162c25fcb9ebaa2e6e53d5b4d88ce17d9e0c2b" integrity sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw== @@ -1777,9 +1467,9 @@ import-fresh@^3.0.0, import-fresh@^3.2.1: resolve-from "^4.0.0" import-local@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/import-local/-/import-local-3.0.2.tgz#a8cfd0431d1de4a2199703d003e3e62364fa6db6" - integrity sha512-vjL3+w0oulAVZ0hBHnxa/Nm5TAurf9YLQJDhqRZyqb+VKGOB6LU8t9H1Nr5CIo16vh9XfJTOoHwU0B71S557gA== + version "3.1.0" + resolved "https://registry.yarnpkg.com/import-local/-/import-local-3.1.0.tgz#b4479df8a5fd44f6cdce24070675676063c95cb4" + integrity sha512-ASB07uLtnDs1o6EHjKpX34BKYDSqnFerfTOJL2HvMqF70LnxpjkzDB8J44oT9pu4AMPkQwf8jl6szgvNd2tRIg== dependencies: pkg-dir "^4.2.0" resolve-cwd "^3.0.0" @@ -1787,12 +1477,12 @@ import-local@^3.0.2: imurmurhash@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" - integrity sha1-khi5srkoojixPcT7a21XbyMUU+o= + integrity sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA== inflight@^1.0.4: version "1.0.6" resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" - integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk= + integrity sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA== dependencies: once "^1.3.0" wrappy "1" @@ -1802,24 +1492,22 @@ inherits@2: resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== -is-ci@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-3.0.0.tgz#c7e7be3c9d8eef7d0fa144390bd1e4b88dc4c994" - integrity sha512-kDXyttuLeslKAHYL/K28F2YkM3x5jvFPEw3yXbRptXydjD9rpLEz+C5K5iutY9ZiUu6AP41JdvRQwF4Iqs4ZCQ== - dependencies: - ci-info "^3.1.1" +is-arrayish@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" + integrity sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg== -is-core-module@^2.2.0: - version "2.6.0" - resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.6.0.tgz#d7553b2526fe59b92ba3e40c8df757ec8a709e19" - integrity sha512-wShG8vs60jKfPWpF2KZRaAtvt3a20OAn7+IJ6hLPECpSABLcKtFKTTI4ZtH5QcBruBHlq+WsdHWyz0BCZW7svQ== +is-core-module@^2.13.0: + version "2.13.1" + resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.13.1.tgz#ad0d7532c6fea9da1ebdc82742d74525c6273384" + integrity sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw== dependencies: - has "^1.0.3" + hasown "^2.0.0" is-extglob@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" - integrity sha1-qIwCU1eR8C7TfHahueqXc8gz+MI= + integrity sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ== is-fullwidth-code-point@^3.0.0: version "3.0.0" @@ -1831,10 +1519,10 @@ is-generator-fn@^2.0.0: resolved "https://registry.yarnpkg.com/is-generator-fn/-/is-generator-fn-2.1.0.tgz#7d140adc389aaf3011a8f2a2a4cfa6faadffb118" integrity sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ== -is-glob@^4.0.0, is-glob@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.1.tgz#7567dbe9f2f5e2467bc77ab83c4a29482407a5dc" - integrity sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg== +is-glob@^4.0.0, is-glob@^4.0.3: + version "4.0.3" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084" + integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== dependencies: is-extglob "^2.1.1" @@ -1843,503 +1531,426 @@ is-number@^7.0.0: resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== -is-potential-custom-element-name@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz#171ed6f19e3ac554394edf78caa05784a45bebb5" - integrity sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ== - is-stream@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-2.0.1.tgz#fac1e3d53b97ad5a9d0ae9cef2389f5810a5c077" integrity sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg== -is-typedarray@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" - integrity sha1-5HnICFjfDBsR3dppQPlgEfzaSpo= - isexe@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" - integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= + integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw== -istanbul-lib-coverage@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-3.0.0.tgz#f5944a37c70b550b02a78a5c3b2055b280cec8ec" - integrity sha512-UiUIqxMgRDET6eR+o5HbfRYP1l0hqkWOs7vNxC/mggutCMUIhWMm8gAHb8tHlyfD3/l6rlgNA5cKdDzEAf6hEg== +istanbul-lib-coverage@^3.0.0, istanbul-lib-coverage@^3.2.0: + version "3.2.2" + resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz#2d166c4b0644d43a39f04bf6c2edd1e585f31756" + integrity sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg== -istanbul-lib-instrument@^4.0.0, istanbul-lib-instrument@^4.0.3: - version "4.0.3" - resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-4.0.3.tgz#873c6fff897450118222774696a3f28902d77c1d" - integrity sha512-BXgQl9kf4WTCPCCpmFGoJkz/+uhvm7h7PFKUYxh7qarQd3ER33vHG//qaE8eN25l07YqZPpHXU9I09l/RD5aGQ== +istanbul-lib-instrument@^5.0.4: + version "5.2.1" + resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-5.2.1.tgz#d10c8885c2125574e1c231cacadf955675e1ce3d" + integrity sha512-pzqtp31nLv/XFOzXGuvhCb8qhjmTVo5vjVk19XE4CRlSWz0KoeJ3bw9XsA7nOp9YBf4qHjwBxkDzKcME/J29Yg== dependencies: - "@babel/core" "^7.7.5" + "@babel/core" "^7.12.3" + "@babel/parser" "^7.14.7" "@istanbuljs/schema" "^0.1.2" - istanbul-lib-coverage "^3.0.0" + istanbul-lib-coverage "^3.2.0" semver "^6.3.0" +istanbul-lib-instrument@^6.0.0: + version "6.0.1" + resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-6.0.1.tgz#71e87707e8041428732518c6fb5211761753fbdf" + integrity sha512-EAMEJBsYuyyztxMxW3g7ugGPkrZsV57v0Hmv3mm1uQsmB+QnZuepg731CRaIgeUVSdmsTngOkSnauNF8p7FIhA== + dependencies: + "@babel/core" "^7.12.3" + "@babel/parser" "^7.14.7" + "@istanbuljs/schema" "^0.1.2" + istanbul-lib-coverage "^3.2.0" + semver "^7.5.4" + istanbul-lib-report@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz#7518fe52ea44de372f460a76b5ecda9ffb73d8a6" - integrity sha512-wcdi+uAKzfiGT2abPpKZ0hSU1rGQjUQnLvtY5MpQ7QCTahD3VODhcu4wcfY1YtkGaDD5yuydOLINXsfbus9ROw== + version "3.0.1" + resolved "https://registry.yarnpkg.com/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz#908305bac9a5bd175ac6a74489eafd0fc2445a7d" + integrity sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw== dependencies: istanbul-lib-coverage "^3.0.0" - make-dir "^3.0.0" + make-dir "^4.0.0" supports-color "^7.1.0" istanbul-lib-source-maps@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/istanbul-lib-source-maps/-/istanbul-lib-source-maps-4.0.0.tgz#75743ce6d96bb86dc7ee4352cf6366a23f0b1ad9" - integrity sha512-c16LpFRkR8vQXyHZ5nLpY35JZtzj1PQY1iZmesUbf1FZHbIupcWfjgOXBY9YHkLEQ6puz1u4Dgj6qmU/DisrZg== + version "4.0.1" + resolved "https://registry.yarnpkg.com/istanbul-lib-source-maps/-/istanbul-lib-source-maps-4.0.1.tgz#895f3a709fcfba34c6de5a42939022f3e4358551" + integrity sha512-n3s8EwkdFIJCG3BPKBYvskgXGoy88ARzvegkitk60NxRdwltLOTaH7CUiMRXvwYorl0Q712iEjcWB+fK/MrWVw== dependencies: debug "^4.1.1" istanbul-lib-coverage "^3.0.0" source-map "^0.6.1" -istanbul-reports@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/istanbul-reports/-/istanbul-reports-3.0.2.tgz#d593210e5000683750cb09fc0644e4b6e27fd53b" - integrity sha512-9tZvz7AiR3PEDNGiV9vIouQ/EAcqMXFmkcA1CDFTwOB98OZVDL0PH9glHotf5Ugp6GCOTypfzGWI/OqjWNCRUw== +istanbul-reports@^3.1.3: + version "3.1.6" + resolved "https://registry.yarnpkg.com/istanbul-reports/-/istanbul-reports-3.1.6.tgz#2544bcab4768154281a2f0870471902704ccaa1a" + integrity sha512-TLgnMkKg3iTDsQ9PbPTdpfAK2DzjF9mqUG7RMgcQl8oFjad8ob4laGxv5XV5U9MAfx8D6tSJiUyuAwzLicaxlg== dependencies: html-escaper "^2.0.0" istanbul-lib-report "^3.0.0" -jest-changed-files@^27.3.0: - version "27.3.0" - resolved "https://registry.yarnpkg.com/jest-changed-files/-/jest-changed-files-27.3.0.tgz#22a02cc2b34583fc66e443171dc271c0529d263c" - integrity sha512-9DJs9garMHv4RhylUMZgbdCJ3+jHSkpL9aaVKp13xtXAD80qLTLrqcDZL1PHA9dYA0bCI86Nv2BhkLpLhrBcPg== +jest-changed-files@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-changed-files/-/jest-changed-files-29.7.0.tgz#1c06d07e77c78e1585d020424dedc10d6e17ac3a" + integrity sha512-fEArFiwf1BpQ+4bXSprcDc3/x4HSzL4al2tozwVpDFpsxALjLYdyiIK4e5Vz66GQJIbXJ82+35PtysofptNX2w== dependencies: - "@jest/types" "^27.2.5" execa "^5.0.0" - throat "^6.0.1" - -jest-circus@^27.3.1: - version "27.3.1" - resolved "https://registry.yarnpkg.com/jest-circus/-/jest-circus-27.3.1.tgz#1679e74387cbbf0c6a8b42de963250a6469e0797" - integrity sha512-v1dsM9II6gvXokgqq6Yh2jHCpfg7ZqV4jWY66u7npz24JnhP3NHxI0sKT7+ZMQ7IrOWHYAaeEllOySbDbWsiXw== - dependencies: - "@jest/environment" "^27.3.1" - "@jest/test-result" "^27.3.1" - "@jest/types" "^27.2.5" + jest-util "^29.7.0" + p-limit "^3.1.0" + +jest-circus@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-circus/-/jest-circus-29.7.0.tgz#b6817a45fcc835d8b16d5962d0c026473ee3668a" + integrity sha512-3E1nCMgipcTkCocFwM90XXQab9bS+GMsjdpmPrlelaxwD93Ad8iVEjX/vvHPdLPnFf+L40u+5+iutRdA1N9myw== + dependencies: + "@jest/environment" "^29.7.0" + "@jest/expect" "^29.7.0" + "@jest/test-result" "^29.7.0" + "@jest/types" "^29.6.3" "@types/node" "*" chalk "^4.0.0" co "^4.6.0" - dedent "^0.7.0" - expect "^27.3.1" + dedent "^1.0.0" is-generator-fn "^2.0.0" - jest-each "^27.3.1" - jest-matcher-utils "^27.3.1" - jest-message-util "^27.3.1" - jest-runtime "^27.3.1" - jest-snapshot "^27.3.1" - jest-util "^27.3.1" - pretty-format "^27.3.1" + jest-each "^29.7.0" + jest-matcher-utils "^29.7.0" + jest-message-util "^29.7.0" + jest-runtime "^29.7.0" + jest-snapshot "^29.7.0" + jest-util "^29.7.0" + p-limit "^3.1.0" + pretty-format "^29.7.0" + pure-rand "^6.0.0" slash "^3.0.0" stack-utils "^2.0.3" - throat "^6.0.1" -jest-cli@^27.3.1: - version "27.3.1" - resolved "https://registry.yarnpkg.com/jest-cli/-/jest-cli-27.3.1.tgz#b576f9d146ba6643ce0a162d782b40152b6b1d16" - integrity sha512-WHnCqpfK+6EvT62me6WVs8NhtbjAS4/6vZJnk7/2+oOr50cwAzG4Wxt6RXX0hu6m1169ZGMlhYYUNeKBXCph/Q== +jest-cli@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-cli/-/jest-cli-29.7.0.tgz#5592c940798e0cae677eec169264f2d839a37995" + integrity sha512-OVVobw2IubN/GSYsxETi+gOe7Ka59EFMR/twOU3Jb2GnKKeMGJB5SGUUrEz3SFVmJASUdZUzy83sLNNQ2gZslg== dependencies: - "@jest/core" "^27.3.1" - "@jest/test-result" "^27.3.1" - "@jest/types" "^27.2.5" + "@jest/core" "^29.7.0" + "@jest/test-result" "^29.7.0" + "@jest/types" "^29.6.3" chalk "^4.0.0" + create-jest "^29.7.0" exit "^0.1.2" - graceful-fs "^4.2.4" import-local "^3.0.2" - jest-config "^27.3.1" - jest-util "^27.3.1" - jest-validate "^27.3.1" - prompts "^2.0.1" - yargs "^16.2.0" - -jest-config@^27.3.1: - version "27.3.1" - resolved "https://registry.yarnpkg.com/jest-config/-/jest-config-27.3.1.tgz#cb3b7f6aaa8c0a7daad4f2b9573899ca7e09bbad" - integrity sha512-KY8xOIbIACZ/vdYCKSopL44I0xboxC751IX+DXL2+Wx6DKNycyEfV3rryC3BPm5Uq/BBqDoMrKuqLEUNJmMKKg== - dependencies: - "@babel/core" "^7.1.0" - "@jest/test-sequencer" "^27.3.1" - "@jest/types" "^27.2.5" - babel-jest "^27.3.1" + jest-config "^29.7.0" + jest-util "^29.7.0" + jest-validate "^29.7.0" + yargs "^17.3.1" + +jest-config@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-config/-/jest-config-29.7.0.tgz#bcbda8806dbcc01b1e316a46bb74085a84b0245f" + integrity sha512-uXbpfeQ7R6TZBqI3/TxCU4q4ttk3u0PJeC+E0zbfSoSjq6bJ7buBPxzQPL0ifrkY4DNu4JUdk0ImlBUYi840eQ== + dependencies: + "@babel/core" "^7.11.6" + "@jest/test-sequencer" "^29.7.0" + "@jest/types" "^29.6.3" + babel-jest "^29.7.0" chalk "^4.0.0" ci-info "^3.2.0" deepmerge "^4.2.2" - glob "^7.1.1" - graceful-fs "^4.2.4" - jest-circus "^27.3.1" - jest-environment-jsdom "^27.3.1" - jest-environment-node "^27.3.1" - jest-get-type "^27.3.1" - jest-jasmine2 "^27.3.1" - jest-regex-util "^27.0.6" - jest-resolve "^27.3.1" - jest-runner "^27.3.1" - jest-util "^27.3.1" - jest-validate "^27.3.1" + glob "^7.1.3" + graceful-fs "^4.2.9" + jest-circus "^29.7.0" + jest-environment-node "^29.7.0" + jest-get-type "^29.6.3" + jest-regex-util "^29.6.3" + jest-resolve "^29.7.0" + jest-runner "^29.7.0" + jest-util "^29.7.0" + jest-validate "^29.7.0" micromatch "^4.0.4" - pretty-format "^27.3.1" - -jest-diff@^27.0.0: - version "27.2.0" - resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-27.2.0.tgz#bda761c360f751bab1e7a2fe2fc2b0a35ce8518c" - integrity sha512-QSO9WC6btFYWtRJ3Hac0sRrkspf7B01mGrrQEiCW6TobtViJ9RWL0EmOs/WnBsZDsI/Y2IoSHZA2x6offu0sYw== - dependencies: - chalk "^4.0.0" - diff-sequences "^27.0.6" - jest-get-type "^27.0.6" - pretty-format "^27.2.0" + parse-json "^5.2.0" + pretty-format "^29.7.0" + slash "^3.0.0" + strip-json-comments "^3.1.1" -jest-diff@^27.3.1: - version "27.3.1" - resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-27.3.1.tgz#d2775fea15411f5f5aeda2a5e02c2f36440f6d55" - integrity sha512-PCeuAH4AWUo2O5+ksW4pL9v5xJAcIKPUPfIhZBcG1RKv/0+dvaWTQK1Nrau8d67dp65fOqbeMdoil+6PedyEPQ== +jest-diff@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-29.7.0.tgz#017934a66ebb7ecf6f205e84699be10afd70458a" + integrity sha512-LMIgiIrhigmPrs03JHpxUh2yISK3vLFPkAodPeo0+BuF7wA2FoQbkEg1u8gBYBThncu7e1oEDUfIXVuTqLRUjw== dependencies: chalk "^4.0.0" - diff-sequences "^27.0.6" - jest-get-type "^27.3.1" - pretty-format "^27.3.1" + diff-sequences "^29.6.3" + jest-get-type "^29.6.3" + pretty-format "^29.7.0" -jest-docblock@^27.0.6: - version "27.0.6" - resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-27.0.6.tgz#cc78266acf7fe693ca462cbbda0ea4e639e4e5f3" - integrity sha512-Fid6dPcjwepTFraz0YxIMCi7dejjJ/KL9FBjPYhBp4Sv1Y9PdhImlKZqYU555BlN4TQKaTc+F2Av1z+anVyGkA== +jest-docblock@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-29.7.0.tgz#8fddb6adc3cdc955c93e2a87f61cfd350d5d119a" + integrity sha512-q617Auw3A612guyaFgsbFeYpNP5t2aoUNLwBUbc/0kD1R4t9ixDbyFTHd1nok4epoVFpr7PmeWHrhvuV3XaJ4g== dependencies: detect-newline "^3.0.0" -jest-each@^27.3.1: - version "27.3.1" - resolved "https://registry.yarnpkg.com/jest-each/-/jest-each-27.3.1.tgz#14c56bb4f18dd18dc6bdd853919b5f16a17761ff" - integrity sha512-E4SwfzKJWYcvOYCjOxhZcxwL+AY0uFMvdCOwvzgutJiaiodFjkxQQDxHm8FQBeTqDnSmKsQWn7ldMRzTn2zJaQ== +jest-each@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-each/-/jest-each-29.7.0.tgz#162a9b3f2328bdd991beaabffbb74745e56577d1" + integrity sha512-gns+Er14+ZrEoC5fhOfYCY1LOHHr0TI+rQUHZS8Ttw2l7gl+80eHc/gFf2Ktkw0+SIACDTeWvpFcv3B04VembQ== dependencies: - "@jest/types" "^27.2.5" + "@jest/types" "^29.6.3" chalk "^4.0.0" - jest-get-type "^27.3.1" - jest-util "^27.3.1" - pretty-format "^27.3.1" - -jest-environment-jsdom@^27.3.1: - version "27.3.1" - resolved "https://registry.yarnpkg.com/jest-environment-jsdom/-/jest-environment-jsdom-27.3.1.tgz#63ac36d68f7a9303494df783494856222b57f73e" - integrity sha512-3MOy8qMzIkQlfb3W1TfrD7uZHj+xx8Olix5vMENkj5djPmRqndMaXtpnaZkxmxM+Qc3lo+yVzJjzuXbCcZjAlg== - dependencies: - "@jest/environment" "^27.3.1" - "@jest/fake-timers" "^27.3.1" - "@jest/types" "^27.2.5" - "@types/node" "*" - jest-mock "^27.3.0" - jest-util "^27.3.1" - jsdom "^16.6.0" - -jest-environment-node@^27.3.1: - version "27.3.1" - resolved "https://registry.yarnpkg.com/jest-environment-node/-/jest-environment-node-27.3.1.tgz#af7d0eed04edafb740311b303f3fe7c8c27014bb" - integrity sha512-T89F/FgkE8waqrTSA7/ydMkcc52uYPgZZ6q8OaZgyiZkJb5QNNCF6oPZjH9IfPFfcc9uBWh1574N0kY0pSvTXw== - dependencies: - "@jest/environment" "^27.3.1" - "@jest/fake-timers" "^27.3.1" - "@jest/types" "^27.2.5" + jest-get-type "^29.6.3" + jest-util "^29.7.0" + pretty-format "^29.7.0" + +jest-environment-node@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-environment-node/-/jest-environment-node-29.7.0.tgz#0b93e111dda8ec120bc8300e6d1fb9576e164376" + integrity sha512-DOSwCRqXirTOyheM+4d5YZOrWcdu0LNZ87ewUoywbcb2XR4wKgqiG8vNeYwhjFMbEkfju7wx2GYH0P2gevGvFw== + dependencies: + "@jest/environment" "^29.7.0" + "@jest/fake-timers" "^29.7.0" + "@jest/types" "^29.6.3" "@types/node" "*" - jest-mock "^27.3.0" - jest-util "^27.3.1" - -jest-get-type@^27.0.6: - version "27.0.6" - resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-27.0.6.tgz#0eb5c7f755854279ce9b68a9f1a4122f69047cfe" - integrity sha512-XTkK5exIeUbbveehcSR8w0bhH+c0yloW/Wpl+9vZrjzztCPWrxhHwkIFpZzCt71oRBsgxmuUfxEqOYoZI2macg== - -jest-get-type@^27.3.1: - version "27.3.1" - resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-27.3.1.tgz#a8a2b0a12b50169773099eee60a0e6dd11423eff" - integrity sha512-+Ilqi8hgHSAdhlQ3s12CAVNd8H96ZkQBfYoXmArzZnOfAtVAJEiPDBirjByEblvG/4LPJmkL+nBqPO3A1YJAEg== - -jest-haste-map@^27.3.1: - version "27.3.1" - resolved "https://registry.yarnpkg.com/jest-haste-map/-/jest-haste-map-27.3.1.tgz#7656fbd64bf48bda904e759fc9d93e2c807353ee" - integrity sha512-lYfNZIzwPccDJZIyk9Iz5iQMM/MH56NIIcGj7AFU1YyA4ewWFBl8z+YPJuSCRML/ee2cCt2y3W4K3VXPT6Nhzg== - dependencies: - "@jest/types" "^27.2.5" - "@types/graceful-fs" "^4.1.2" + jest-mock "^29.7.0" + jest-util "^29.7.0" + +jest-get-type@^29.6.3: + version "29.6.3" + resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-29.6.3.tgz#36f499fdcea197c1045a127319c0481723908fd1" + integrity sha512-zrteXnqYxfQh7l5FHyL38jL39di8H8rHoecLH3JNxH3BwOrBsNeabdap5e0I23lD4HHI8W5VFBZqG4Eaq5LNcw== + +jest-haste-map@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-haste-map/-/jest-haste-map-29.7.0.tgz#3c2396524482f5a0506376e6c858c3bbcc17b104" + integrity sha512-fP8u2pyfqx0K1rGn1R9pyE0/KTn+G7PxktWidOBTqFPLYX0b9ksaMFkhK5vrS3DVun09pckLdlx90QthlW7AmA== + dependencies: + "@jest/types" "^29.6.3" + "@types/graceful-fs" "^4.1.3" "@types/node" "*" anymatch "^3.0.3" fb-watchman "^2.0.0" - graceful-fs "^4.2.4" - jest-regex-util "^27.0.6" - jest-serializer "^27.0.6" - jest-util "^27.3.1" - jest-worker "^27.3.1" + graceful-fs "^4.2.9" + jest-regex-util "^29.6.3" + jest-util "^29.7.0" + jest-worker "^29.7.0" micromatch "^4.0.4" - walker "^1.0.7" + walker "^1.0.8" optionalDependencies: fsevents "^2.3.2" -jest-jasmine2@^27.3.1: - version "27.3.1" - resolved "https://registry.yarnpkg.com/jest-jasmine2/-/jest-jasmine2-27.3.1.tgz#df6d3d07c7dafc344feb43a0072a6f09458d32b0" - integrity sha512-WK11ZUetDQaC09w4/j7o4FZDUIp+4iYWH/Lik34Pv7ukL+DuXFGdnmmi7dT58J2ZYKFB5r13GyE0z3NPeyJmsg== +jest-leak-detector@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-leak-detector/-/jest-leak-detector-29.7.0.tgz#5b7ec0dadfdfec0ca383dc9aa016d36b5ea4c728" + integrity sha512-kYA8IJcSYtST2BY9I+SMC32nDpBT3J2NvWJx8+JCuCdl/CR1I4EKUJROiP8XtCcxqgTTBGJNdbB1A8XRKbTetw== dependencies: - "@babel/traverse" "^7.1.0" - "@jest/environment" "^27.3.1" - "@jest/source-map" "^27.0.6" - "@jest/test-result" "^27.3.1" - "@jest/types" "^27.2.5" - "@types/node" "*" - chalk "^4.0.0" - co "^4.6.0" - expect "^27.3.1" - is-generator-fn "^2.0.0" - jest-each "^27.3.1" - jest-matcher-utils "^27.3.1" - jest-message-util "^27.3.1" - jest-runtime "^27.3.1" - jest-snapshot "^27.3.1" - jest-util "^27.3.1" - pretty-format "^27.3.1" - throat "^6.0.1" - -jest-leak-detector@^27.3.1: - version "27.3.1" - resolved "https://registry.yarnpkg.com/jest-leak-detector/-/jest-leak-detector-27.3.1.tgz#7fb632c2992ef707a1e73286e1e704f9cc1772b2" - integrity sha512-78QstU9tXbaHzwlRlKmTpjP9k4Pvre5l0r8Spo4SbFFVy/4Abg9I6ZjHwjg2QyKEAMg020XcjP+UgLZIY50yEg== - dependencies: - jest-get-type "^27.3.1" - pretty-format "^27.3.1" - -jest-matcher-utils@^27.3.1: - version "27.3.1" - resolved "https://registry.yarnpkg.com/jest-matcher-utils/-/jest-matcher-utils-27.3.1.tgz#257ad61e54a6d4044e080d85dbdc4a08811e9c1c" - integrity sha512-hX8N7zXS4k+8bC1Aj0OWpGb7D3gIXxYvPNK1inP5xvE4ztbz3rc4AkI6jGVaerepBnfWB17FL5lWFJT3s7qo8w== + jest-get-type "^29.6.3" + pretty-format "^29.7.0" + +jest-matcher-utils@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-matcher-utils/-/jest-matcher-utils-29.7.0.tgz#ae8fec79ff249fd592ce80e3ee474e83a6c44f12" + integrity sha512-sBkD+Xi9DtcChsI3L3u0+N0opgPYnCRPtGcQYrgXmR+hmt/fYfWAL0xRXYU8eWOdfuLgBe0YCW3AFtnRLagq/g== dependencies: chalk "^4.0.0" - jest-diff "^27.3.1" - jest-get-type "^27.3.1" - pretty-format "^27.3.1" + jest-diff "^29.7.0" + jest-get-type "^29.6.3" + pretty-format "^29.7.0" -jest-message-util@^27.3.1: - version "27.3.1" - resolved "https://registry.yarnpkg.com/jest-message-util/-/jest-message-util-27.3.1.tgz#f7c25688ad3410ab10bcb862bcfe3152345c6436" - integrity sha512-bh3JEmxsTZ/9rTm0jQrPElbY2+y48Rw2t47uMfByNyUVR+OfPh4anuyKsGqsNkXk/TI4JbLRZx+7p7Hdt6q1yg== +jest-message-util@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-message-util/-/jest-message-util-29.7.0.tgz#8bc392e204e95dfe7564abbe72a404e28e51f7f3" + integrity sha512-GBEV4GRADeP+qtB2+6u61stea8mGcOT4mCtrYISZwfu9/ISHFJ/5zOMXYbpBE9RsS5+Gb63DW4FgmnKJ79Kf6w== dependencies: "@babel/code-frame" "^7.12.13" - "@jest/types" "^27.2.5" + "@jest/types" "^29.6.3" "@types/stack-utils" "^2.0.0" chalk "^4.0.0" - graceful-fs "^4.2.4" + graceful-fs "^4.2.9" micromatch "^4.0.4" - pretty-format "^27.3.1" + pretty-format "^29.7.0" slash "^3.0.0" stack-utils "^2.0.3" -jest-mock@^27.3.0: - version "27.3.0" - resolved "https://registry.yarnpkg.com/jest-mock/-/jest-mock-27.3.0.tgz#ddf0ec3cc3e68c8ccd489bef4d1f525571a1b867" - integrity sha512-ziZiLk0elZOQjD08bLkegBzv5hCABu/c8Ytx45nJKkysQwGaonvmTxwjLqEA4qGdasq9o2I8/HtdGMNnVsMTGw== +jest-mock@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-mock/-/jest-mock-29.7.0.tgz#4e836cf60e99c6fcfabe9f99d017f3fdd50a6347" + integrity sha512-ITOMZn+UkYS4ZFh83xYAOzWStloNzJFO2s8DWrE4lhtGD+AorgnbkiKERe4wQVBydIGPx059g6riW5Btp6Llnw== dependencies: - "@jest/types" "^27.2.5" + "@jest/types" "^29.6.3" "@types/node" "*" + jest-util "^29.7.0" jest-pnp-resolver@^1.2.2: - version "1.2.2" - resolved "https://registry.yarnpkg.com/jest-pnp-resolver/-/jest-pnp-resolver-1.2.2.tgz#b704ac0ae028a89108a4d040b3f919dfddc8e33c" - integrity sha512-olV41bKSMm8BdnuMsewT4jqlZ8+3TCARAXjZGT9jcoSnrfUnRCqnMoF9XEeoWjbzObpqF9dRhHQj0Xb9QdF6/w== - -jest-regex-util@^27.0.6: - version "27.0.6" - resolved "https://registry.yarnpkg.com/jest-regex-util/-/jest-regex-util-27.0.6.tgz#02e112082935ae949ce5d13b2675db3d8c87d9c5" - integrity sha512-SUhPzBsGa1IKm8hx2F4NfTGGp+r7BXJ4CulsZ1k2kI+mGLG+lxGrs76veN2LF/aUdGosJBzKgXmNCw+BzFqBDQ== - -jest-resolve-dependencies@^27.3.1: - version "27.3.1" - resolved "https://registry.yarnpkg.com/jest-resolve-dependencies/-/jest-resolve-dependencies-27.3.1.tgz#85b99bdbdfa46e2c81c6228fc4c91076f624f6e2" - integrity sha512-X7iLzY8pCiYOnvYo2YrK3P9oSE8/3N2f4pUZMJ8IUcZnT81vlSonya1KTO9ZfKGuC+svE6FHK/XOb8SsoRUV1A== - dependencies: - "@jest/types" "^27.2.5" - jest-regex-util "^27.0.6" - jest-snapshot "^27.3.1" - -jest-resolve@^27.3.1: - version "27.3.1" - resolved "https://registry.yarnpkg.com/jest-resolve/-/jest-resolve-27.3.1.tgz#0e5542172a1aa0270be6f66a65888647bdd74a3e" - integrity sha512-Dfzt25CFSPo3Y3GCbxynRBZzxq9AdyNN+x/v2IqYx6KVT5Z6me2Z/PsSGFSv3cOSUZqJ9pHxilao/I/m9FouLw== - dependencies: - "@jest/types" "^27.2.5" + version "1.2.3" + resolved "https://registry.yarnpkg.com/jest-pnp-resolver/-/jest-pnp-resolver-1.2.3.tgz#930b1546164d4ad5937d5540e711d4d38d4cad2e" + integrity sha512-+3NpwQEnRoIBtx4fyhblQDPgJI0H1IEIkX7ShLUjPGA7TtUTvI1oiKi3SR4oBR0hQhQR80l4WAe5RrXBwWMA8w== + +jest-regex-util@^29.6.3: + version "29.6.3" + resolved "https://registry.yarnpkg.com/jest-regex-util/-/jest-regex-util-29.6.3.tgz#4a556d9c776af68e1c5f48194f4d0327d24e8a52" + integrity sha512-KJJBsRCyyLNWCNBOvZyRDnAIfUiRJ8v+hOBQYGn8gDyF3UegwiP4gwRR3/SDa42g1YbVycTidUF3rKjyLFDWbg== + +jest-resolve-dependencies@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-resolve-dependencies/-/jest-resolve-dependencies-29.7.0.tgz#1b04f2c095f37fc776ff40803dc92921b1e88428" + integrity sha512-un0zD/6qxJ+S0et7WxeI3H5XSe9lTBBR7bOHCHXkKR6luG5mwDDlIzVQ0V5cZCuoTgEdcdwzTghYkTWfubi+nA== + dependencies: + jest-regex-util "^29.6.3" + jest-snapshot "^29.7.0" + +jest-resolve@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-resolve/-/jest-resolve-29.7.0.tgz#64d6a8992dd26f635ab0c01e5eef4399c6bcbc30" + integrity sha512-IOVhZSrg+UvVAshDSDtHyFCCBUl/Q3AAJv8iZ6ZjnZ74xzvwuzLXid9IIIPgTnY62SJjfuupMKZsZQRsCvxEgA== + dependencies: chalk "^4.0.0" - graceful-fs "^4.2.4" - jest-haste-map "^27.3.1" + graceful-fs "^4.2.9" + jest-haste-map "^29.7.0" jest-pnp-resolver "^1.2.2" - jest-util "^27.3.1" - jest-validate "^27.3.1" + jest-util "^29.7.0" + jest-validate "^29.7.0" resolve "^1.20.0" - resolve.exports "^1.1.0" + resolve.exports "^2.0.0" slash "^3.0.0" -jest-runner@^27.3.1: - version "27.3.1" - resolved "https://registry.yarnpkg.com/jest-runner/-/jest-runner-27.3.1.tgz#1d594dcbf3bd8600a7e839e790384559eaf96e3e" - integrity sha512-r4W6kBn6sPr3TBwQNmqE94mPlYVn7fLBseeJfo4E2uCTmAyDFm2O5DYAQAFP7Q3YfiA/bMwg8TVsciP7k0xOww== +jest-runner@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-runner/-/jest-runner-29.7.0.tgz#809af072d408a53dcfd2e849a4c976d3132f718e" + integrity sha512-fsc4N6cPCAahybGBfTRcq5wFR6fpLznMg47sY5aDpsoejOcVYFb07AHuSnR0liMcPTgBsA3ZJL6kFOjPdoNipQ== dependencies: - "@jest/console" "^27.3.1" - "@jest/environment" "^27.3.1" - "@jest/test-result" "^27.3.1" - "@jest/transform" "^27.3.1" - "@jest/types" "^27.2.5" + "@jest/console" "^29.7.0" + "@jest/environment" "^29.7.0" + "@jest/test-result" "^29.7.0" + "@jest/transform" "^29.7.0" + "@jest/types" "^29.6.3" "@types/node" "*" chalk "^4.0.0" - emittery "^0.8.1" - exit "^0.1.2" - graceful-fs "^4.2.4" - jest-docblock "^27.0.6" - jest-environment-jsdom "^27.3.1" - jest-environment-node "^27.3.1" - jest-haste-map "^27.3.1" - jest-leak-detector "^27.3.1" - jest-message-util "^27.3.1" - jest-resolve "^27.3.1" - jest-runtime "^27.3.1" - jest-util "^27.3.1" - jest-worker "^27.3.1" - source-map-support "^0.5.6" - throat "^6.0.1" - -jest-runtime@^27.3.1: - version "27.3.1" - resolved "https://registry.yarnpkg.com/jest-runtime/-/jest-runtime-27.3.1.tgz#80fa32eb85fe5af575865ddf379874777ee993d7" - integrity sha512-qtO6VxPbS8umqhEDpjA4pqTkKQ1Hy4ZSi9mDVeE9Za7LKBo2LdW2jmT+Iod3XFaJqINikZQsn2wEi0j9wPRbLg== - dependencies: - "@jest/console" "^27.3.1" - "@jest/environment" "^27.3.1" - "@jest/globals" "^27.3.1" - "@jest/source-map" "^27.0.6" - "@jest/test-result" "^27.3.1" - "@jest/transform" "^27.3.1" - "@jest/types" "^27.2.5" - "@types/yargs" "^16.0.0" + emittery "^0.13.1" + graceful-fs "^4.2.9" + jest-docblock "^29.7.0" + jest-environment-node "^29.7.0" + jest-haste-map "^29.7.0" + jest-leak-detector "^29.7.0" + jest-message-util "^29.7.0" + jest-resolve "^29.7.0" + jest-runtime "^29.7.0" + jest-util "^29.7.0" + jest-watcher "^29.7.0" + jest-worker "^29.7.0" + p-limit "^3.1.0" + source-map-support "0.5.13" + +jest-runtime@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-runtime/-/jest-runtime-29.7.0.tgz#efecb3141cf7d3767a3a0cc8f7c9990587d3d817" + integrity sha512-gUnLjgwdGqW7B4LvOIkbKs9WGbn+QLqRQQ9juC6HndeDiezIwhDP+mhMwHWCEcfQ5RUXa6OPnFF8BJh5xegwwQ== + dependencies: + "@jest/environment" "^29.7.0" + "@jest/fake-timers" "^29.7.0" + "@jest/globals" "^29.7.0" + "@jest/source-map" "^29.6.3" + "@jest/test-result" "^29.7.0" + "@jest/transform" "^29.7.0" + "@jest/types" "^29.6.3" + "@types/node" "*" chalk "^4.0.0" cjs-module-lexer "^1.0.0" collect-v8-coverage "^1.0.0" - execa "^5.0.0" - exit "^0.1.2" glob "^7.1.3" - graceful-fs "^4.2.4" - jest-haste-map "^27.3.1" - jest-message-util "^27.3.1" - jest-mock "^27.3.0" - jest-regex-util "^27.0.6" - jest-resolve "^27.3.1" - jest-snapshot "^27.3.1" - jest-util "^27.3.1" - jest-validate "^27.3.1" + graceful-fs "^4.2.9" + jest-haste-map "^29.7.0" + jest-message-util "^29.7.0" + jest-mock "^29.7.0" + jest-regex-util "^29.6.3" + jest-resolve "^29.7.0" + jest-snapshot "^29.7.0" + jest-util "^29.7.0" slash "^3.0.0" strip-bom "^4.0.0" - yargs "^16.2.0" -jest-serializer@^27.0.6: - version "27.0.6" - resolved "https://registry.yarnpkg.com/jest-serializer/-/jest-serializer-27.0.6.tgz#93a6c74e0132b81a2d54623251c46c498bb5bec1" - integrity sha512-PtGdVK9EGC7dsaziskfqaAPib6wTViY3G8E5wz9tLVPhHyiDNTZn/xjZ4khAw+09QkoOVpn7vF5nPSN6dtBexA== +jest-snapshot@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-snapshot/-/jest-snapshot-29.7.0.tgz#c2c574c3f51865da1bb329036778a69bf88a6be5" + integrity sha512-Rm0BMWtxBcioHr1/OX5YCP8Uov4riHvKPknOGs804Zg9JGZgmIBkbtlxJC/7Z4msKYVbIJtfU+tKb8xlYNfdkw== dependencies: - "@types/node" "*" - graceful-fs "^4.2.4" - -jest-snapshot@^27.3.1: - version "27.3.1" - resolved "https://registry.yarnpkg.com/jest-snapshot/-/jest-snapshot-27.3.1.tgz#1da5c0712a252d70917d46c037054f5918c49ee4" - integrity sha512-APZyBvSgQgOT0XumwfFu7X3G5elj6TGhCBLbBdn3R1IzYustPGPE38F51dBWMQ8hRXa9je0vAdeVDtqHLvB6lg== - dependencies: - "@babel/core" "^7.7.2" + "@babel/core" "^7.11.6" "@babel/generator" "^7.7.2" - "@babel/parser" "^7.7.2" + "@babel/plugin-syntax-jsx" "^7.7.2" "@babel/plugin-syntax-typescript" "^7.7.2" - "@babel/traverse" "^7.7.2" - "@babel/types" "^7.0.0" - "@jest/transform" "^27.3.1" - "@jest/types" "^27.2.5" - "@types/babel__traverse" "^7.0.4" - "@types/prettier" "^2.1.5" + "@babel/types" "^7.3.3" + "@jest/expect-utils" "^29.7.0" + "@jest/transform" "^29.7.0" + "@jest/types" "^29.6.3" babel-preset-current-node-syntax "^1.0.0" chalk "^4.0.0" - expect "^27.3.1" - graceful-fs "^4.2.4" - jest-diff "^27.3.1" - jest-get-type "^27.3.1" - jest-haste-map "^27.3.1" - jest-matcher-utils "^27.3.1" - jest-message-util "^27.3.1" - jest-resolve "^27.3.1" - jest-util "^27.3.1" + expect "^29.7.0" + graceful-fs "^4.2.9" + jest-diff "^29.7.0" + jest-get-type "^29.6.3" + jest-matcher-utils "^29.7.0" + jest-message-util "^29.7.0" + jest-util "^29.7.0" natural-compare "^1.4.0" - pretty-format "^27.3.1" - semver "^7.3.2" - -jest-util@^27.0.0: - version "27.2.5" - resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-27.2.5.tgz#88740c4024d223634a82ce7c2263e8bc6df3b3ba" - integrity sha512-QRhDC6XxISntMzFRd/OQ6TGsjbzA5ONO0tlAj2ElHs155x1aEr0rkYJBEysG6H/gZVH3oGFzCdAB/GA8leh8NQ== - dependencies: - "@jest/types" "^27.2.5" - "@types/node" "*" - chalk "^4.0.0" - graceful-fs "^4.2.4" - is-ci "^3.0.0" - picomatch "^2.2.3" + pretty-format "^29.7.0" + semver "^7.5.3" -jest-util@^27.3.1: - version "27.3.1" - resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-27.3.1.tgz#a58cdc7b6c8a560caac9ed6bdfc4e4ff23f80429" - integrity sha512-8fg+ifEH3GDryLQf/eKZck1DEs2YuVPBCMOaHQxVVLmQwl/CDhWzrvChTX4efLZxGrw+AA0mSXv78cyytBt/uw== +jest-util@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-29.7.0.tgz#23c2b62bfb22be82b44de98055802ff3710fc0bc" + integrity sha512-z6EbKajIpqGKU56y5KBUgy1dt1ihhQJgWzUlZHArA/+X2ad7Cb5iF+AK1EWVL/Bo7Rz9uurpqw6SiBCefUbCGA== dependencies: - "@jest/types" "^27.2.5" + "@jest/types" "^29.6.3" "@types/node" "*" chalk "^4.0.0" ci-info "^3.2.0" - graceful-fs "^4.2.4" + graceful-fs "^4.2.9" picomatch "^2.2.3" -jest-validate@^27.3.1: - version "27.3.1" - resolved "https://registry.yarnpkg.com/jest-validate/-/jest-validate-27.3.1.tgz#3a395d61a19cd13ae9054af8cdaf299116ef8a24" - integrity sha512-3H0XCHDFLA9uDII67Bwi1Vy7AqwA5HqEEjyy934lgVhtJ3eisw6ShOF1MDmRPspyikef5MyExvIm0/TuLzZ86Q== +jest-validate@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-validate/-/jest-validate-29.7.0.tgz#7bf705511c64da591d46b15fce41400d52147d9c" + integrity sha512-ZB7wHqaRGVw/9hST/OuFUReG7M8vKeq0/J2egIGLdvjHCmYqGARhzXmtgi+gVeZ5uXFF219aOc3Ls2yLg27tkw== dependencies: - "@jest/types" "^27.2.5" + "@jest/types" "^29.6.3" camelcase "^6.2.0" chalk "^4.0.0" - jest-get-type "^27.3.1" + jest-get-type "^29.6.3" leven "^3.1.0" - pretty-format "^27.3.1" + pretty-format "^29.7.0" -jest-watcher@^27.3.1: - version "27.3.1" - resolved "https://registry.yarnpkg.com/jest-watcher/-/jest-watcher-27.3.1.tgz#ba5e0bc6aa843612b54ddb7f009d1cbff7e05f3e" - integrity sha512-9/xbV6chABsGHWh9yPaAGYVVKurWoP3ZMCv6h+O1v9/+pkOroigs6WzZ0e9gLP/njokUwM7yQhr01LKJVMkaZA== +jest-watcher@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-watcher/-/jest-watcher-29.7.0.tgz#7810d30d619c3a62093223ce6bb359ca1b28a2f2" + integrity sha512-49Fg7WXkU3Vl2h6LbLtMQ/HyB6rXSIX7SqvBLQmssRBGN9I0PNvPmAmCWSOY6SOvrjhI/F7/bGAv9RtnsPA03g== dependencies: - "@jest/test-result" "^27.3.1" - "@jest/types" "^27.2.5" + "@jest/test-result" "^29.7.0" + "@jest/types" "^29.6.3" "@types/node" "*" ansi-escapes "^4.2.1" chalk "^4.0.0" - jest-util "^27.3.1" + emittery "^0.13.1" + jest-util "^29.7.0" string-length "^4.0.1" -jest-worker@^27.3.1: - version "27.3.1" - resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-27.3.1.tgz#0def7feae5b8042be38479799aeb7b5facac24b2" - integrity sha512-ks3WCzsiZaOPJl/oMsDjaf0TRiSv7ctNgs0FqRr2nARsovz6AWWy4oLElwcquGSz692DzgZQrCLScPNs5YlC4g== +jest-worker@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-29.7.0.tgz#acad073acbbaeb7262bd5389e1bcf43e10058d4a" + integrity sha512-eIz2msL/EzL9UFTFFx7jBTkeZfku0yUAyZZZmJ93H2TYEiroIx2PQjEXcwYtYl8zXCxb+PAmA2hLIt/6ZEkPHw== dependencies: "@types/node" "*" + jest-util "^29.7.0" merge-stream "^2.0.0" supports-color "^8.0.0" -jest@^27.0.1: - version "27.3.1" - resolved "https://registry.yarnpkg.com/jest/-/jest-27.3.1.tgz#b5bab64e8f56b6f7e275ba1836898b0d9f1e5c8a" - integrity sha512-U2AX0AgQGd5EzMsiZpYt8HyZ+nSVIh5ujQ9CPp9EQZJMjXIiSZpJNweZl0swatKRoqHWgGKM3zaSwm4Zaz87ng== +jest@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest/-/jest-29.7.0.tgz#994676fc24177f088f1c5e3737f5697204ff2613" + integrity sha512-NIy3oAFp9shda19hy4HK0HRTWKtPJmGdnvywu01nOqNC2vZg+Z+fvJDxpMQA88eb2I9EcafcdjYgsDthnYTvGw== dependencies: - "@jest/core" "^27.3.1" + "@jest/core" "^29.7.0" + "@jest/types" "^29.6.3" import-local "^3.0.2" - jest-cli "^27.3.1" + jest-cli "^29.7.0" js-tokens@^4.0.0: version "4.0.0" @@ -2354,65 +1965,49 @@ js-yaml@^3.13.1: argparse "^1.0.7" esprima "^4.0.0" -jsdom@^16.6.0: - version "16.7.0" - resolved "https://registry.yarnpkg.com/jsdom/-/jsdom-16.7.0.tgz#918ae71965424b197c819f8183a754e18977b710" - integrity sha512-u9Smc2G1USStM+s/x1ru5Sxrl6mPYCbByG1U/hUmqaVsm4tbNyS7CicOSRyuGQYZhTu0h84qkZZQ/I+dzizSVw== - dependencies: - abab "^2.0.5" - acorn "^8.2.4" - acorn-globals "^6.0.0" - cssom "^0.4.4" - cssstyle "^2.3.0" - data-urls "^2.0.0" - decimal.js "^10.2.1" - domexception "^2.0.1" - escodegen "^2.0.0" - form-data "^3.0.0" - html-encoding-sniffer "^2.0.1" - http-proxy-agent "^4.0.1" - https-proxy-agent "^5.0.0" - is-potential-custom-element-name "^1.0.1" - nwsapi "^2.2.0" - parse5 "6.0.1" - saxes "^5.0.1" - symbol-tree "^3.2.4" - tough-cookie "^4.0.0" - w3c-hr-time "^1.0.2" - w3c-xmlserializer "^2.0.0" - webidl-conversions "^6.1.0" - whatwg-encoding "^1.0.5" - whatwg-mimetype "^2.3.0" - whatwg-url "^8.5.0" - ws "^7.4.6" - xml-name-validator "^3.0.0" +js-yaml@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602" + integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA== + dependencies: + argparse "^2.0.1" jsesc@^2.5.1: version "2.5.2" resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-2.5.2.tgz#80564d2e483dacf6e8ef209650a67df3f0c283a4" integrity sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA== +json-buffer@3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/json-buffer/-/json-buffer-3.0.1.tgz#9338802a30d3b6605fbe0613e094008ca8c05a13" + integrity sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ== + +json-parse-even-better-errors@^2.3.0: + version "2.3.1" + resolved "https://registry.yarnpkg.com/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz#7c47805a94319928e05777405dc12e1f7a4ee02d" + integrity sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w== + json-schema-traverse@^0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== -json-schema-traverse@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz#ae7bcb3656ab77a73ba5c49bf654f38e6b6860e2" - integrity sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug== - json-stable-stringify-without-jsonify@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651" - integrity sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE= + integrity sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw== -json5@2.x, json5@^2.1.2: - version "2.2.0" - resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.0.tgz#2dfefe720c6ba525d9ebd909950f0515316c89a3" - integrity sha512-f+8cldu7X/y7RAJurMEJmdoKXGB/X550w2Nr3tTbezL6RwEE/iMcm+tZnXeoZtKuOq6ft8+CqzEkrIgx1fPoQA== +json5@^2.2.3: + version "2.2.3" + resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283" + integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg== + +keyv@^4.5.4: + version "4.5.4" + resolved "https://registry.yarnpkg.com/keyv/-/keyv-4.5.4.tgz#a879a99e29452f942439f2a405e3af8b31d4de93" + integrity sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw== dependencies: - minimist "^1.2.5" + json-buffer "3.0.1" kleur@^3.0.3: version "3.0.3" @@ -2432,13 +2027,10 @@ levn@^0.4.1: prelude-ls "^1.2.1" type-check "~0.4.0" -levn@~0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee" - integrity sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4= - dependencies: - prelude-ls "~1.1.2" - type-check "~0.3.2" +lines-and-columns@^1.1.6: + version "1.2.4" + resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.2.4.tgz#eca284f75d2965079309dc0ad9255abb2ebc1632" + integrity sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg== locate-path@^5.0.0: version "5.0.0" @@ -2447,30 +2039,24 @@ locate-path@^5.0.0: dependencies: p-locate "^4.1.0" -lodash.clonedeep@^4.5.0: - version "4.5.0" - resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef" - integrity sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8= - -lodash.memoize@4.x: - version "4.1.2" - resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe" - integrity sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4= +locate-path@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-6.0.0.tgz#55321eb309febbc59c4801d931a72452a681d286" + integrity sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw== + dependencies: + p-locate "^5.0.0" lodash.merge@^4.6.2: version "4.6.2" resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a" integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ== -lodash.truncate@^4.4.2: - version "4.4.2" - resolved "https://registry.yarnpkg.com/lodash.truncate/-/lodash.truncate-4.4.2.tgz#5a350da0b1113b837ecfffd5812cbe58d6eae193" - integrity sha1-WjUNoLERO4N+z//VgSy+WNbq4ZM= - -lodash@^4.7.0: - version "4.17.21" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" - integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== +lru-cache@^5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-5.1.1.tgz#1da27e6710271947695daf6848e847f01d84b920" + integrity sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w== + dependencies: + yallist "^3.0.2" lru-cache@^6.0.0: version "6.0.0" @@ -2479,73 +2065,46 @@ lru-cache@^6.0.0: dependencies: yallist "^4.0.0" -make-dir@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-3.1.0.tgz#415e967046b3a7f1d185277d84aa58203726a13f" - integrity sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw== +make-dir@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-4.0.0.tgz#c3c2307a771277cd9638305f915c29ae741b614e" + integrity sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw== dependencies: - semver "^6.0.0" - -make-error@1.x, make-error@^1.1.1: - version "1.3.6" - resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" - integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== + semver "^7.5.3" -makeerror@1.0.x: - version "1.0.11" - resolved "https://registry.yarnpkg.com/makeerror/-/makeerror-1.0.11.tgz#e01a5c9109f2af79660e4e8b9587790184f5a96c" - integrity sha1-4BpckQnyr3lmDk6LlYd5AYT1qWw= +makeerror@1.0.12: + version "1.0.12" + resolved "https://registry.yarnpkg.com/makeerror/-/makeerror-1.0.12.tgz#3e5dd2079a82e812e983cc6610c4a2cb0eaa801a" + integrity sha512-JmqCvUhmt43madlpFzG4BQzG2Z3m6tvQDNKdClZnO3VbIudJYmxsT0FNJMeiB2+JTSlTQTSbU8QdesVmwJcmLg== dependencies: - tmpl "1.0.x" + tmpl "1.0.5" merge-stream@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60" integrity sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w== -merge2@^1.3.0: - version "1.4.1" - resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae" - integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg== - micromatch@^4.0.4: - version "4.0.4" - resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.4.tgz#896d519dfe9db25fce94ceb7a500919bf881ebf9" - integrity sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg== - dependencies: - braces "^3.0.1" - picomatch "^2.2.3" - -mime-db@1.49.0: - version "1.49.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.49.0.tgz#f3dfde60c99e9cf3bc9701d687778f537001cbed" - integrity sha512-CIc8j9URtOVApSFCQIF+VBkX1RwXp/oMMOrqdyXSBXq5RWNEsRfyj1kiRnQgmNXmHxPoFIxOroKA3zcU9P+nAA== - -mime-types@^2.1.12: - version "2.1.32" - resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.32.tgz#1d00e89e7de7fe02008db61001d9e02852670fd5" - integrity sha512-hJGaVS4G4c9TSMYh2n6SQAGrC4RnfU+daP8G7cSCmaqNjiOoUY0VHCMS42pxnQmVF1GWwFhbHWn3RIxCqTmZ9A== + version "4.0.5" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.5.tgz#bc8999a7cbbf77cdc89f132f6e467051b49090c6" + integrity sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA== dependencies: - mime-db "1.49.0" + braces "^3.0.2" + picomatch "^2.3.1" mimic-fn@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b" integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg== -minimatch@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" - integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA== +minimatch@^3.0.4, minimatch@^3.1.1, minimatch@^3.1.2: + version "3.1.2" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" + integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== dependencies: brace-expansion "^1.1.7" -minimist@^1.2.5: - version "1.2.5" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" - integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw== - -mri@^1.1.5: +mri@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/mri/-/mri-1.2.0.tgz#6721480fec2a11a4889861115a48b6cbe7cc8f0b" integrity sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA== @@ -2555,91 +2114,58 @@ ms@2.1.2: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== -multimatch@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/multimatch/-/multimatch-4.0.0.tgz#8c3c0f6e3e8449ada0af3dd29efb491a375191b3" - integrity sha512-lDmx79y1z6i7RNx0ZGCPq1bzJ6ZoDDKbvh7jxr9SJcWLkShMzXrHbYVpTdnhNM5MXpDUxCQ4DgqVttVXlBgiBQ== - dependencies: - "@types/minimatch" "^3.0.3" - array-differ "^3.0.0" - array-union "^2.1.0" - arrify "^2.0.1" - minimatch "^3.0.4" - natural-compare@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" - integrity sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc= + integrity sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw== node-int64@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b" - integrity sha1-h6kGXNs1XTGC2PlM4RGIuCXGijs= - -node-modules-regexp@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/node-modules-regexp/-/node-modules-regexp-1.0.0.tgz#8d9dbe28964a4ac5712e9131642107c71e90ec40" - integrity sha1-jZ2+KJZKSsVxLpExZCEHxx6Q7EA= + integrity sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw== -node-releases@^1.1.75: - version "1.1.76" - resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.76.tgz#df245b062b0cafbd5282ab6792f7dccc2d97f36e" - integrity sha512-9/IECtNr8dXNmPWmFXepT0/7o5eolGesHUa3mtr0KlgnCvnZxwh2qensKL42JJY2vQKC3nIBXetFAqR+PW1CmA== +node-releases@^2.0.13: + version "2.0.13" + resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.13.tgz#d5ed1627c23e3461e819b02e57b75e4899b1c81d" + integrity sha512-uYr7J37ae/ORWdZeQ1xxMJe3NtdmqMC/JZK+geofDrkLUApKRHPd18/TxtBOJ4A0/+uUIliorNrfYV6s1b02eQ== normalize-path@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== -npm-run-path@^4.0.0, npm-run-path@^4.0.1: +npm-run-path@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-4.0.1.tgz#b7ecd1e5ed53da8e37a55e1c2269e0b97ed748ea" integrity sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw== dependencies: path-key "^3.0.0" -nwsapi@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/nwsapi/-/nwsapi-2.2.0.tgz#204879a9e3d068ff2a55139c2c772780681a38b7" - integrity sha512-h2AatdwYH+JHiZpv7pt/gSX1XoRGb7L/qSIeuqA6GwYoF9w1vP1cw42TO0aI2pNyshRK5893hNSl+1//vHK7hQ== - -once@^1.3.0, once@^1.3.1, once@^1.4.0: +once@^1.3.0: version "1.4.0" resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" - integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= + integrity sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w== dependencies: wrappy "1" -onetime@^5.1.0, onetime@^5.1.2: +onetime@^5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/onetime/-/onetime-5.1.2.tgz#d0e96ebb56b07476df1dd9c4806e5237985ca45e" integrity sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg== dependencies: mimic-fn "^2.1.0" -optionator@^0.8.1: - version "0.8.3" - resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.3.tgz#84fa1d036fe9d3c7e21d99884b601167ec8fb495" - integrity sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA== - dependencies: - deep-is "~0.1.3" - fast-levenshtein "~2.0.6" - levn "~0.3.0" - prelude-ls "~1.1.2" - type-check "~0.3.2" - word-wrap "~1.2.3" - -optionator@^0.9.1: - version "0.9.1" - resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.9.1.tgz#4f236a6373dae0566a6d43e1326674f50c291499" - integrity sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw== +optionator@^0.9.3: + version "0.9.3" + resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.9.3.tgz#007397d44ed1872fdc6ed31360190f81814e2c64" + integrity sha512-JjCoypp+jKn1ttEFExxhetCKeJt9zhAgAve5FXHixTvFDW/5aEktX9bufBKLRRMdU7bNtpLfcGu94B3cdEJgjg== dependencies: + "@aashutoshrathi/word-wrap" "^1.2.3" deep-is "^0.1.3" fast-levenshtein "^2.0.6" levn "^0.4.1" prelude-ls "^1.2.1" type-check "^0.4.0" - word-wrap "^1.2.3" p-limit@^2.2.0: version "2.3.0" @@ -2648,6 +2174,13 @@ p-limit@^2.2.0: dependencies: p-try "^2.0.0" +p-limit@^3.0.2, p-limit@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-3.1.0.tgz#e1daccbe78d0d1388ca18c64fea38e3e57e3706b" + integrity sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ== + dependencies: + yocto-queue "^0.1.0" + p-locate@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-4.1.0.tgz#a3428bb7088b3a60292f66919278b7c297ad4f07" @@ -2655,6 +2188,13 @@ p-locate@^4.1.0: dependencies: p-limit "^2.2.0" +p-locate@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-5.0.0.tgz#83c8315c6785005e3bd021839411c9e110e6d834" + integrity sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw== + dependencies: + p-limit "^3.0.2" + p-try@^2.0.0: version "2.2.0" resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" @@ -2667,10 +2207,15 @@ parent-module@^1.0.0: dependencies: callsites "^3.0.0" -parse5@6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/parse5/-/parse5-6.0.1.tgz#e1a1c085c569b3dc08321184f19a39cc27f7c30b" - integrity sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw== +parse-json@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-5.2.0.tgz#c76fc66dee54231c962b22bcc8a72cf2f99753cd" + integrity sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg== + dependencies: + "@babel/code-frame" "^7.0.0" + error-ex "^1.3.1" + json-parse-even-better-errors "^2.3.0" + lines-and-columns "^1.1.6" path-exists@^4.0.0: version "4.0.0" @@ -2680,34 +2225,42 @@ path-exists@^4.0.0: path-is-absolute@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" - integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= + integrity sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg== path-key@^3.0.0, path-key@^3.1.0: version "3.1.1" resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375" integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== -path-parse@^1.0.6: +path-parse@^1.0.7: version "1.0.7" resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== -path-type@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b" - integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw== +picocolors@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.0.0.tgz#cb5bdc74ff3f51892236eaf79d68bc44564ab81c" + integrity sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ== -picomatch@^2.0.4, picomatch@^2.2.3: - version "2.3.0" - resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.0.tgz#f1f061de8f6a4bf022892e2d128234fb98302972" - integrity sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw== +picocolors@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.1.1.tgz#3d321af3eab939b083c8f929a1d12cda81c26b6b" + integrity sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA== -pirates@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/pirates/-/pirates-4.0.1.tgz#643a92caf894566f91b2b986d2c66950a8e2fb87" - integrity sha512-WuNqLTbMI3tmfef2TKxlQmAiLHKtFhlsCZnPIpuv2Ow0RDVO8lfy1Opf4NUzlMXLjPl+Men7AuVdX6TA+s+uGA== - dependencies: - node-modules-regexp "^1.0.0" +picomatch@^2.0.4, picomatch@^2.2.3, picomatch@^2.3.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" + integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== + +picomatch@^4.0.2: + version "4.0.2" + resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-4.0.2.tgz#77c742931e8f3b8820946c76cd0c1f13730d1dab" + integrity sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg== + +pirates@^4.0.4: + version "4.0.6" + resolved "https://registry.yarnpkg.com/pirates/-/pirates-4.0.6.tgz#3018ae32ecfcff6c29ba2267cbf21166ac1f36b9" + integrity sha512-saLsH7WeYYPiD25LDuLRRY/i+6HaPYr6G1OUlN39otzkSTxKnubR9RTxS3/Kk50s1g2JTgFwWQDQyplC5/SHZg== pkg-dir@^4.2.0: version "4.2.0" @@ -2721,103 +2274,60 @@ prelude-ls@^1.2.1: resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g== -prelude-ls@~1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" - integrity sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ= - -prettier@>=2.3.0: - version "2.4.1" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.4.1.tgz#671e11c89c14a4cfc876ce564106c4a6726c9f5c" - integrity sha512-9fbDAXSBcc6Bs1mZrDYb3XKzDLm4EXXL9sC1LqKP5rZkT6KRr/rf9amVUcODVXgguK/isJz0d0hP72WeaKWsvA== - -pretty-format@^27.0.0, pretty-format@^27.2.0: - version "27.2.0" - resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-27.2.0.tgz#ee37a94ce2a79765791a8649ae374d468c18ef19" - integrity sha512-KyJdmgBkMscLqo8A7K77omgLx5PWPiXJswtTtFV7XgVZv2+qPk6UivpXXO+5k6ZEbWIbLoKdx1pZ6ldINzbwTA== - dependencies: - "@jest/types" "^27.1.1" - ansi-regex "^5.0.0" - ansi-styles "^5.0.0" - react-is "^17.0.1" +prettier@^3.5.3: + version "3.5.3" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.5.3.tgz#4fc2ce0d657e7a02e602549f053b239cb7dfe1b5" + integrity sha512-QQtaxnoDJeAkDvDKWCLiwIXkTgRhwYDEQCghU9Z6q03iyek/rxRh/2lC3HB7P8sWT2xC/y5JDctPLBIGzHKbhw== -pretty-format@^27.3.1: - version "27.3.1" - resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-27.3.1.tgz#7e9486365ccdd4a502061fa761d3ab9ca1b78df5" - integrity sha512-DR/c+pvFc52nLimLROYjnXPtolawm+uWDxr4FjuLDLUn+ktWnSN851KoHwHzzqq6rfCOjkzN8FLgDrSub6UDuA== +pretty-format@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-29.7.0.tgz#ca42c758310f365bfa71a0bda0a807160b776812" + integrity sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ== dependencies: - "@jest/types" "^27.2.5" - ansi-regex "^5.0.1" + "@jest/schemas" "^29.6.3" ansi-styles "^5.0.0" - react-is "^17.0.1" + react-is "^18.0.0" -pretty-quick@^3.1.0: - version "3.1.1" - resolved "https://registry.yarnpkg.com/pretty-quick/-/pretty-quick-3.1.1.tgz#93ca4e2dd38cc4e970e3f54a0ead317a25454688" - integrity sha512-ZYLGiMoV2jcaas3vTJrLvKAYsxDoXQBUn8OSTxkl67Fyov9lyXivJTl0+2WVh+y6EovGcw7Lm5ThYpH+Sh3XxQ== +pretty-quick@^4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/pretty-quick/-/pretty-quick-4.1.1.tgz#8a0c883e4beeb0eddbe7eda50d7b1251d4f72968" + integrity sha512-9Ud0l/CspNTmyIdYac9X7Inb3o8fuUsw+1zJFvCGn+at0t1UwUcUdo2RSZ41gcmfLv1fxgWQxWEfItR7CBwugg== dependencies: - chalk "^3.0.0" - execa "^4.0.0" - find-up "^4.1.0" - ignore "^5.1.4" - mri "^1.1.5" - multimatch "^4.0.0" - -progress@^2.0.0: - version "2.0.3" - resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8" - integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA== + find-up "^5.0.0" + ignore "^7.0.3" + mri "^1.2.0" + picocolors "^1.1.1" + picomatch "^4.0.2" + tinyexec "^0.3.2" + tslib "^2.8.1" prompts@^2.0.1: - version "2.4.1" - resolved "https://registry.yarnpkg.com/prompts/-/prompts-2.4.1.tgz#befd3b1195ba052f9fd2fde8a486c4e82ee77f61" - integrity sha512-EQyfIuO2hPDsX1L/blblV+H7I0knhgAd82cVneCwcdND9B8AuCDuRcBH6yIcG4dFzlOUqbazQqwGjx5xmsNLuQ== + version "2.4.2" + resolved "https://registry.yarnpkg.com/prompts/-/prompts-2.4.2.tgz#7b57e73b3a48029ad10ebd44f74b01722a4cb069" + integrity sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q== dependencies: kleur "^3.0.3" sisteransi "^1.0.5" -psl@^1.1.33: - version "1.8.0" - resolved "https://registry.yarnpkg.com/psl/-/psl-1.8.0.tgz#9326f8bcfb013adcc005fdff056acce020e51c24" - integrity sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ== - -pump@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/pump/-/pump-3.0.0.tgz#b4a2116815bde2f4e1ea602354e8c75565107a64" - integrity sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww== - dependencies: - end-of-stream "^1.1.0" - once "^1.3.1" - -punycode@^2.1.0, punycode@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" - integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== - -queue-microtask@^1.2.2: - version "1.2.3" - resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243" - integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A== +punycode@^2.1.0: + version "2.3.1" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.1.tgz#027422e2faec0b25e1549c3e1bd8309b9133b6e5" + integrity sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg== -react-is@^17.0.1: - version "17.0.2" - resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0" - integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w== +pure-rand@^6.0.0: + version "6.0.4" + resolved "https://registry.yarnpkg.com/pure-rand/-/pure-rand-6.0.4.tgz#50b737f6a925468679bff00ad20eade53f37d5c7" + integrity sha512-LA0Y9kxMYv47GIPJy6MI84fqTd2HmYZI83W/kM/SkKfDlajnZYfmXFTxkbY+xSBPkLJxltMa9hIkmdc29eguMA== -regexpp@^3.1.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.2.0.tgz#0425a2768d8f23bad70ca4b90461fa2f1213e1b2" - integrity sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg== +react-is@^18.0.0: + version "18.2.0" + resolved "https://registry.yarnpkg.com/react-is/-/react-is-18.2.0.tgz#199431eeaaa2e09f86427efbb4f1473edb47609b" + integrity sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w== require-directory@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" - integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I= - -require-from-string@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/require-from-string/-/require-from-string-2.0.2.tgz#89a7fdd938261267318eafe14f9c32e598c36909" - integrity sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw== + integrity sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q== resolve-cwd@^3.0.0: version "3.0.0" @@ -2836,67 +2346,32 @@ resolve-from@^5.0.0: resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-5.0.0.tgz#c35225843df8f776df21c57557bc087e9dfdfc69" integrity sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw== -resolve.exports@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/resolve.exports/-/resolve.exports-1.1.0.tgz#5ce842b94b05146c0e03076985d1d0e7e48c90c9" - integrity sha512-J1l+Zxxp4XK3LUDZ9m60LRJF/mAe4z6a4xyabPHk7pvK5t35dACV32iIjJDFeWZFfZlO29w6SZ67knR0tHzJtQ== +resolve.exports@^2.0.0: + version "2.0.2" + resolved "https://registry.yarnpkg.com/resolve.exports/-/resolve.exports-2.0.2.tgz#f8c934b8e6a13f539e38b7098e2e36134f01e800" + integrity sha512-X2UW6Nw3n/aMgDVy+0rSqgHlv39WZAlZrXCdnbyEiKm17DSqHX4MmQMaST3FbeWR5FTuRcUwYAziZajji0Y7mg== resolve@^1.20.0: - version "1.20.0" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.20.0.tgz#629a013fb3f70755d6f0b7935cc1c2c5378b1975" - integrity sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A== - dependencies: - is-core-module "^2.2.0" - path-parse "^1.0.6" - -reusify@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76" - integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw== - -rimraf@^3.0.0, rimraf@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a" - integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA== - dependencies: - glob "^7.1.3" - -run-parallel@^1.1.9: - version "1.2.0" - resolved "https://registry.yarnpkg.com/run-parallel/-/run-parallel-1.2.0.tgz#66d1368da7bdf921eb9d95bd1a9229e7f21a43ee" - integrity sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA== + version "1.22.8" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.8.tgz#b6c87a9f2aa06dfab52e3d70ac8cde321fa5a48d" + integrity sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw== dependencies: - queue-microtask "^1.2.2" - -safe-buffer@~5.1.1: - version "5.1.2" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" - integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== + is-core-module "^2.13.0" + path-parse "^1.0.7" + supports-preserve-symlinks-flag "^1.0.0" -"safer-buffer@>= 2.1.2 < 3": - version "2.1.2" - resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" - integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== - -saxes@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/saxes/-/saxes-5.0.1.tgz#eebab953fa3b7608dbe94e5dadb15c888fa6696d" - integrity sha512-5LBh1Tls8c9xgGjw3QrMwETmTMVk0oFgvrFSvWx62llR2hcEInrKNZ2GZCCuuy2lvWrdl5jhbpeqc5hRYKFOcw== - dependencies: - xmlchars "^2.2.0" +semver@^6.3.0, semver@^6.3.1: + version "6.3.1" + resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4" + integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA== -semver@7.x, semver@^7.2.1, semver@^7.3.2, semver@^7.3.5: - version "7.3.5" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.5.tgz#0b621c879348d8998e4b0e4be94b3f12e6018ef7" - integrity sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ== +semver@^7.5.3, semver@^7.5.4: + version "7.5.4" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e" + integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA== dependencies: lru-cache "^6.0.0" -semver@^6.0.0, semver@^6.3.0: - version "6.3.0" - resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" - integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== - shebang-command@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea" @@ -2909,10 +2384,10 @@ shebang-regex@^3.0.0: resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172" integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== -signal-exit@^3.0.2, signal-exit@^3.0.3: - version "3.0.4" - resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.4.tgz#366a4684d175b9cab2081e3681fda3747b6c51d7" - integrity sha512-rqYhcAnZ6d/vTPGghdrw7iumdcbXpsk1b8IG/rz+VWV51DM0p7XCtMoJ3qhPLIbp3tvyt3pKRbaaEMZYpHto8Q== +signal-exit@^3.0.3, signal-exit@^3.0.7: + version "3.0.7" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9" + integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== sisteransi@^1.0.5: version "1.0.5" @@ -2924,47 +2399,28 @@ slash@^3.0.0: resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634" integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q== -slice-ansi@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-4.0.0.tgz#500e8dd0fd55b05815086255b3195adf2a45fe6b" - integrity sha512-qMCMfhY040cVHT43K9BFygqYbUPFZKHOg7K73mtTWJRb8pyP3fzf4Ixd5SzdEJQ6MRUg/WBnOLxghZtKKurENQ== - dependencies: - ansi-styles "^4.0.0" - astral-regex "^2.0.0" - is-fullwidth-code-point "^3.0.0" - -source-map-support@^0.5.6: - version "0.5.20" - resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.20.tgz#12166089f8f5e5e8c56926b377633392dd2cb6c9" - integrity sha512-n1lZZ8Ve4ksRqizaBQgxXDgKwttHDhyfQjA6YZZn8+AroHbsIz+JjwxQDxbp+7y5OYCI8t1Yk7etjD9CRd2hIw== +source-map-support@0.5.13: + version "0.5.13" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.13.tgz#31b24a9c2e73c2de85066c0feb7d44767ed52932" + integrity sha512-SHSKFHadjVA5oR4PPqhtAVdcBWwRYVd6g6cAXnIbRiIwc2EhPrTuKUBdSLvlEKyIP3GCf89fltvcZiP9MMFA1w== dependencies: buffer-from "^1.0.0" source-map "^0.6.0" -source-map@^0.5.0: - version "0.5.7" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" - integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= - -source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.1: +source-map@^0.6.0, source-map@^0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== -source-map@^0.7.3: - version "0.7.3" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383" - integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ== - sprintf-js@~1.0.2: version "1.0.3" resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" - integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= + integrity sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g== stack-utils@^2.0.3: - version "2.0.5" - resolved "https://registry.yarnpkg.com/stack-utils/-/stack-utils-2.0.5.tgz#d25265fca995154659dbbfba3b49254778d2fdd5" - integrity sha512-xrQcmYhOsn/1kX+Vraq+7j4oE2j/6BFscZ0etmYg81xuM8Gq0022Pxb8+IqgOFUIaxHs0KaSb7T1+OegiNrNFA== + version "2.0.6" + resolved "https://registry.yarnpkg.com/stack-utils/-/stack-utils-2.0.6.tgz#aaf0748169c02fc33c8232abccf933f54a1cc34f" + integrity sha512-XlkWvfIm6RmsWtNJx+uqtKLS8eqFbxUg0ZzLXqY0caEy9l7hruX8IpiDnjsLavoBgqCCR71TqWO8MaXYheJ3RQ== dependencies: escape-string-regexp "^2.0.0" @@ -2976,21 +2432,21 @@ string-length@^4.0.1: char-regex "^1.0.2" strip-ansi "^6.0.0" -string-width@^4.1.0, string-width@^4.2.0: - version "4.2.2" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.2.tgz#dafd4f9559a7585cfba529c6a0a4f73488ebd4c5" - integrity sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA== +string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== dependencies: emoji-regex "^8.0.0" is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.0" + strip-ansi "^6.0.1" -strip-ansi@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.0.tgz#0b1571dd7669ccd4f3e06e14ef1eed26225ae532" - integrity sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w== +strip-ansi@^6.0.0, strip-ansi@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== dependencies: - ansi-regex "^5.0.0" + ansi-regex "^5.0.1" strip-bom@^4.0.0: version "4.0.0" @@ -3002,7 +2458,7 @@ strip-final-newline@^2.0.0: resolved "https://registry.yarnpkg.com/strip-final-newline/-/strip-final-newline-2.0.0.tgz#89b852fb2fcbe936f6f4b3187afb0a12c1ab58ad" integrity sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA== -strip-json-comments@^3.1.0, strip-json-comments@^3.1.1: +strip-json-comments@^3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== @@ -3014,7 +2470,7 @@ supports-color@^5.3.0: dependencies: has-flag "^3.0.0" -supports-color@^7.0.0, supports-color@^7.1.0: +supports-color@^7.1.0: version "7.2.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== @@ -3028,38 +2484,10 @@ supports-color@^8.0.0: dependencies: has-flag "^4.0.0" -supports-hyperlinks@^2.0.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/supports-hyperlinks/-/supports-hyperlinks-2.2.0.tgz#4f77b42488765891774b70c79babd87f9bd594bb" - integrity sha512-6sXEzV5+I5j8Bmq9/vUphGRM/RJNT9SCURJLjwfOg51heRtguGWDzcaBlgAzKhQa0EVNpPEKzQuBwZ8S8WaCeQ== - dependencies: - has-flag "^4.0.0" - supports-color "^7.0.0" - -symbol-tree@^3.2.4: - version "3.2.4" - resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.4.tgz#430637d248ba77e078883951fb9aa0eed7c63fa2" - integrity sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw== - -table@^6.0.9: - version "6.7.1" - resolved "https://registry.yarnpkg.com/table/-/table-6.7.1.tgz#ee05592b7143831a8c94f3cee6aae4c1ccef33e2" - integrity sha512-ZGum47Yi6KOOFDE8m223td53ath2enHcYLgOCjGr5ngu8bdIARQk6mN/wRMv4yMRcHnCSnHbCEha4sobQx5yWg== - dependencies: - ajv "^8.0.1" - lodash.clonedeep "^4.5.0" - lodash.truncate "^4.4.2" - slice-ansi "^4.0.0" - string-width "^4.2.0" - strip-ansi "^6.0.0" - -terminal-link@^2.0.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/terminal-link/-/terminal-link-2.1.1.tgz#14a64a27ab3c0df933ea546fba55f2d078edc994" - integrity sha512-un0FmiRUQNr5PJqy9kP7c40F5BOfpGlYTrxonDChEZB7pzZxRNp/bt+ymiy9/npwXya9KH99nJ/GXFIiUkYGFQ== - dependencies: - ansi-escapes "^4.2.1" - supports-hyperlinks "^2.0.0" +supports-preserve-symlinks-flag@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09" + integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== test-exclude@^6.0.0: version "6.0.0" @@ -3070,17 +2498,12 @@ test-exclude@^6.0.0: glob "^7.1.4" minimatch "^3.0.4" -text-table@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" - integrity sha1-f17oI66AUgfACvLfSoTsP8+lcLQ= - -throat@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/throat/-/throat-6.0.1.tgz#d514fedad95740c12c2d7fc70ea863eb51ade375" - integrity sha512-8hmiGIJMDlwjg7dlJ4yKGLK8EsYqKgPWbG3b4wjJddKNwc7N7Dpn08Df4szr/sZdMVeOstrdYSsqzX6BYbcB+w== +tinyexec@^0.3.2: + version "0.3.2" + resolved "https://registry.yarnpkg.com/tinyexec/-/tinyexec-0.3.2.tgz#941794e657a85e496577995c6eef66f53f42b3d2" + integrity sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA== -tmpl@1.0.x: +tmpl@1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/tmpl/-/tmpl-1.0.5.tgz#8683e0b902bb9c20c4f726e3c0b69f36518c07cc" integrity sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw== @@ -3088,7 +2511,7 @@ tmpl@1.0.x: to-fast-properties@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e" - integrity sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4= + integrity sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog== to-regex-range@^5.0.1: version "5.0.1" @@ -3097,65 +2520,10 @@ to-regex-range@^5.0.1: dependencies: is-number "^7.0.0" -tough-cookie@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-4.0.0.tgz#d822234eeca882f991f0f908824ad2622ddbece4" - integrity sha512-tHdtEpQCMrc1YLrMaqXXcj6AxhYi/xgit6mZu1+EDWUn+qhUf8wMQoFIy9NXuq23zAwtcB0t/MjACGR18pcRbg== - dependencies: - psl "^1.1.33" - punycode "^2.1.1" - universalify "^0.1.2" - -tr46@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/tr46/-/tr46-2.1.0.tgz#fa87aa81ca5d5941da8cbf1f9b749dc969a4e240" - integrity sha512-15Ih7phfcdP5YxqiB+iDtLoaTz4Nd35+IiAv0kQ5FNKHzXgdWqPoTIqEDDJmXceQt4JZk6lVPT8lnDlPpGDppw== - dependencies: - punycode "^2.1.1" - -ts-jest@^27.0.5: - version "27.0.7" - resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-27.0.7.tgz#fb7c8c8cb5526ab371bc1b23d06e745652cca2d0" - integrity sha512-O41shibMqzdafpuP+CkrOL7ykbmLh+FqQrXEmV9CydQ5JBk0Sj0uAEF5TNNe94fZWKm3yYvWa/IbyV4Yg1zK2Q== - dependencies: - bs-logger "0.x" - fast-json-stable-stringify "2.x" - jest-util "^27.0.0" - json5 "2.x" - lodash.memoize "4.x" - make-error "1.x" - semver "7.x" - yargs-parser "20.x" - -ts-node@^10.2.1: - version "10.4.0" - resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.4.0.tgz#680f88945885f4e6cf450e7f0d6223dd404895f7" - integrity sha512-g0FlPvvCXSIO1JDF6S232P5jPYqBkRL9qly81ZgAOSU7rwI0stphCgd2kLiCrU9DjQCrJMWEqcNSjQL02s6d8A== - dependencies: - "@cspotcode/source-map-support" "0.7.0" - "@tsconfig/node10" "^1.0.7" - "@tsconfig/node12" "^1.0.7" - "@tsconfig/node14" "^1.0.0" - "@tsconfig/node16" "^1.0.2" - acorn "^8.4.1" - acorn-walk "^8.1.1" - arg "^4.1.0" - create-require "^1.1.0" - diff "^4.0.1" - make-error "^1.1.1" - yn "3.1.1" - -tslib@^1.8.1: - version "1.14.1" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" - integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== - -tsutils@^3.21.0: - version "3.21.0" - resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623" - integrity sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA== - dependencies: - tslib "^1.8.1" +tslib@^2.8.1: + version "2.8.1" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.1.tgz#612efe4ed235d567e8aba5f2a5fab70280ade83f" + integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w== type-check@^0.4.0, type-check@~0.4.0: version "0.4.0" @@ -3164,44 +2532,28 @@ type-check@^0.4.0, type-check@~0.4.0: dependencies: prelude-ls "^1.2.1" -type-check@~0.3.2: - version "0.3.2" - resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72" - integrity sha1-WITKtRLPHTVeP7eE8wgEsrUg23I= - dependencies: - prelude-ls "~1.1.2" - type-detect@4.0.8: version "4.0.8" resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c" integrity sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g== -type-fest@^0.20.2: - version "0.20.2" - resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.20.2.tgz#1bf207f4b28f91583666cb5fbd327887301cd5f4" - integrity sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ== - type-fest@^0.21.3: version "0.21.3" resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.21.3.tgz#d260a24b0198436e133fa26a524a6d65fa3b2e37" integrity sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w== -typedarray-to-buffer@^3.1.5: - version "3.1.5" - resolved "https://registry.yarnpkg.com/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz#a97ee7a9ff42691b9f783ff1bc5112fe3fca9080" - integrity sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q== - dependencies: - is-typedarray "^1.0.0" - -typescript@^4.4.3: - version "4.4.4" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.4.4.tgz#2cd01a1a1f160704d3101fd5a58ff0f9fcb8030c" - integrity sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA== +undici-types@~5.26.4: + version "5.26.5" + resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617" + integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA== -universalify@^0.1.2: - version "0.1.2" - resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66" - integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg== +update-browserslist-db@^1.0.13: + version "1.0.13" + resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.0.13.tgz#3c5e4f5c083661bd38ef64b6328c26ed6c8248c4" + integrity sha512-xebP81SNcPuNpPP3uzeW1NYXxI3rxyJzF3pD6sH4jE7o/IX+WtSpwnVU+qIsDPyk0d3hmFQ7mjqc6AtV604hbg== + dependencies: + escalade "^3.1.1" + picocolors "^1.0.0" uri-js@^4.2.2: version "4.4.1" @@ -3210,71 +2562,21 @@ uri-js@^4.2.2: dependencies: punycode "^2.1.0" -v8-compile-cache@^2.0.3: - version "2.3.0" - resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz#2de19618c66dc247dcfb6f99338035d8245a2cee" - integrity sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA== - -v8-to-istanbul@^8.1.0: - version "8.1.0" - resolved "https://registry.yarnpkg.com/v8-to-istanbul/-/v8-to-istanbul-8.1.0.tgz#0aeb763894f1a0a1676adf8a8b7612a38902446c" - integrity sha512-/PRhfd8aTNp9Ggr62HPzXg2XasNFGy5PBt0Rp04du7/8GNNSgxFL6WBTkgMKSL9bFjH+8kKEG3f37FmxiTqUUA== +v8-to-istanbul@^9.0.1: + version "9.1.3" + resolved "https://registry.yarnpkg.com/v8-to-istanbul/-/v8-to-istanbul-9.1.3.tgz#ea456604101cd18005ac2cae3cdd1aa058a6306b" + integrity sha512-9lDD+EVI2fjFsMWXc6dy5JJzBsVTcQ2fVkfBvncZ6xJWG9wtBhOldG+mHkSL0+V1K/xgZz0JDO5UT5hFwHUghg== dependencies: + "@jridgewell/trace-mapping" "^0.3.12" "@types/istanbul-lib-coverage" "^2.0.1" - convert-source-map "^1.6.0" - source-map "^0.7.3" + convert-source-map "^2.0.0" -w3c-hr-time@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/w3c-hr-time/-/w3c-hr-time-1.0.2.tgz#0a89cdf5cc15822df9c360543676963e0cc308cd" - integrity sha512-z8P5DvDNjKDoFIHK7q8r8lackT6l+jo/Ye3HOle7l9nICP9lf1Ci25fy9vHd0JOWewkIFzXIEig3TdKT7JQ5fQ== - dependencies: - browser-process-hrtime "^1.0.0" - -w3c-xmlserializer@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/w3c-xmlserializer/-/w3c-xmlserializer-2.0.0.tgz#3e7104a05b75146cc60f564380b7f683acf1020a" - integrity sha512-4tzD0mF8iSiMiNs30BiLO3EpfGLZUT2MSX/G+o7ZywDzliWQ3OPtTZ0PTC3B3ca1UAf4cJMHB+2Bf56EriJuRA== - dependencies: - xml-name-validator "^3.0.0" - -walker@^1.0.7: - version "1.0.7" - resolved "https://registry.yarnpkg.com/walker/-/walker-1.0.7.tgz#2f7f9b8fd10d677262b18a884e28d19618e028fb" - integrity sha1-L3+bj9ENZ3JisYqITijRlhjgKPs= - dependencies: - makeerror "1.0.x" - -webidl-conversions@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-5.0.0.tgz#ae59c8a00b121543a2acc65c0434f57b0fc11aff" - integrity sha512-VlZwKPCkYKxQgeSbH5EyngOmRp7Ww7I9rQLERETtf5ofd9pGeswWiOtogpEO850jziPRarreGxn5QIiTqpb2wA== - -webidl-conversions@^6.1.0: - version "6.1.0" - resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-6.1.0.tgz#9111b4d7ea80acd40f5270d666621afa78b69514" - integrity sha512-qBIvFLGiBpLjfwmYAaHPXsn+ho5xZnGvyGvsarywGNc8VyQJUMHJ8OBKGGrPER0okBeMDaan4mNBlgBROxuI8w== - -whatwg-encoding@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/whatwg-encoding/-/whatwg-encoding-1.0.5.tgz#5abacf777c32166a51d085d6b4f3e7d27113ddb0" - integrity sha512-b5lim54JOPN9HtzvK9HFXvBma/rnfFeqsic0hSpjtDbVxR3dJKLc+KB4V6GgiGOvl7CY/KNh8rxSo9DKQrnUEw== - dependencies: - iconv-lite "0.4.24" - -whatwg-mimetype@^2.3.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/whatwg-mimetype/-/whatwg-mimetype-2.3.0.tgz#3d4b1e0312d2079879f826aff18dbeeca5960fbf" - integrity sha512-M4yMwr6mAnQz76TbJm914+gPpB/nCwvZbJU28cUD6dR004SAxDLOOSUaB1JDRqLtaOV/vi0IC5lEAGFgrjGv/g== - -whatwg-url@^8.0.0, whatwg-url@^8.5.0: - version "8.7.0" - resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-8.7.0.tgz#656a78e510ff8f3937bc0bcbe9f5c0ac35941b77" - integrity sha512-gAojqb/m9Q8a5IV96E3fHJM70AzCkgt4uXYX2O7EmuyOnLrViCQlsEBmF9UQIu3/aeAIp2U17rtbpZWNntQqdg== +walker@^1.0.8: + version "1.0.8" + resolved "https://registry.yarnpkg.com/walker/-/walker-1.0.8.tgz#bd498db477afe573dc04185f011d3ab8a8d7653f" + integrity sha512-ts/8E8l5b7kY0vlWLewOkDXMmPdLcVV4GmOQLyxuSswIJsweeFZtAsMF7k1Nszz+TYBQrlYRmzOnr398y1JemQ== dependencies: - lodash "^4.7.0" - tr46 "^2.1.0" - webidl-conversions "^6.1.0" + makeerror "1.0.12" which@^2.0.1: version "2.0.2" @@ -3283,11 +2585,6 @@ which@^2.0.1: dependencies: isexe "^2.0.0" -word-wrap@^1.2.3, word-wrap@~1.2.3: - version "1.2.3" - resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c" - integrity sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ== - wrap-ansi@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" @@ -3300,62 +2597,50 @@ wrap-ansi@^7.0.0: wrappy@1: version "1.0.2" resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" - integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= + integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ== -write-file-atomic@^3.0.0: - version "3.0.3" - resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-3.0.3.tgz#56bd5c5a5c70481cd19c571bd39ab965a5de56e8" - integrity sha512-AvHcyZ5JnSfq3ioSyjrBkH9yW4m7Ayk8/9My/DD9onKeu/94fwrMocemO2QAJFAlnnDN+ZDS+ZjAR5ua1/PV/Q== +write-file-atomic@^4.0.2: + version "4.0.2" + resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-4.0.2.tgz#a9df01ae5b77858a027fd2e80768ee433555fcfd" + integrity sha512-7KxauUdBmSdWnmpaGFg+ppNjKF8uNLry8LyzjauQDOVONfFLNKrKvQOxZ/VuTIcS/gge/YNahf5RIIQWTSarlg== dependencies: imurmurhash "^0.1.4" - is-typedarray "^1.0.0" - signal-exit "^3.0.2" - typedarray-to-buffer "^3.1.5" - -ws@^7.4.6: - version "7.5.5" - resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.5.tgz#8b4bc4af518cfabd0473ae4f99144287b33eb881" - integrity sha512-BAkMFcAzl8as1G/hArkxOxq3G7pjUqQ3gzYbLL0/5zNkph70e+lCoxBGnm6AW1+/aiNeV4fnKqZ8m4GZewmH2w== - -xml-name-validator@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a" - integrity sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw== - -xmlchars@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/xmlchars/-/xmlchars-2.2.0.tgz#060fe1bcb7f9c76fe2a17db86a9bc3ab894210cb" - integrity sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw== + signal-exit "^3.0.7" y18n@^5.0.5: version "5.0.8" resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== +yallist@^3.0.2: + version "3.1.1" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd" + integrity sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g== + yallist@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== -yargs-parser@20.x, yargs-parser@^20.2.2: - version "20.2.9" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee" - integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w== +yargs-parser@^21.1.1: + version "21.1.1" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.1.1.tgz#9096bceebf990d21bb31fa9516e0ede294a77d35" + integrity sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw== -yargs@^16.2.0: - version "16.2.0" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-16.2.0.tgz#1c82bf0f6b6a66eafce7ef30e376f49a12477f66" - integrity sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw== +yargs@^17.3.1: + version "17.7.2" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.7.2.tgz#991df39aca675a192b816e1e0363f9d75d2aa269" + integrity sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w== dependencies: - cliui "^7.0.2" + cliui "^8.0.1" escalade "^3.1.1" get-caller-file "^2.0.5" require-directory "^2.1.1" - string-width "^4.2.0" + string-width "^4.2.3" y18n "^5.0.5" - yargs-parser "^20.2.2" + yargs-parser "^21.1.1" -yn@3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50" - integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q== +yocto-queue@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" + integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==