Ruby rubocop-ast: Difference between revisions

From wikinotes
No edit summary
Line 13: Line 13:
|}
|}
</blockquote><!-- documentation -->
</blockquote><!-- documentation -->
= Usage =
<blockquote>
there's a lisp-like DSL for matching nodes
<source lang="javascript">
_  // any one thing
... // any number of items
</source>
<source lang="lisp">
(const _ _)                # any const
(casgn <(const _ _) ...>)  # any const being assigned via 'casgn'
</source>
</blockquote><!-- usage -->

Revision as of 00:20, 1 February 2024

A DSL for ruby parser that simplifies matching AST nodes.

Documentation

All AST nodes https://github.com/rubocop/rubocop-ast/blob/master/docs/modules/ROOT/pages/node_types.adoc
official docs https://docs.rubocop.org/rubocop-ast/
test patterns https://nodepattern.herokuapp.com/

Usage

there's a lisp-like DSL for matching nodes

_   // any one thing
... // any number of items
(const _ _)                # any const
(casgn <(const _ _) ...>)  # any const being assigned via 'casgn'