fkling / astexplorer

A web tool to explore the ASTs generated by various parsers.
https://astexplorer.net/
MIT License
6.19k stars 737 forks source link

Comments checkbox #483

Open brettz9 opened 4 years ago

brettz9 commented 4 years ago

Hi,

Such an invaluable tool, thank you!

Was hoping to see an option to enable showing comments in the results for parsers supporting including this (optionally) in the results (e.g., espree's comment option).

fkling commented 4 years ago

Hi @brettz9 !

Since it's not possible for me to keep up with the development of all the parsers or which options they accept, I have to rely on others to propose necessary changes. I'd appreciate a pull request that adds the options to those parsers.

brettz9 commented 4 years ago

Sorry, a bit busy, and not familiar with React or Webpack.

Btw, one other idea also related to expanding the current functionality which I feel would be great--the ability to filter down the tree with esquery selectors.

karlhorky commented 1 year ago

the ability to filter down the tree with esquery selectors

Would also love to have this! @brettz9 do you think that it deserves a new issue? (since this issue's title "Comments checkbox" seems unrelated)

karlhorky commented 1 year ago

Workaround (for using esquery selectors in AST explorer)

From https://github.com/estools/esquery/issues/107, a tip from @pierpo was to use the "Transform" function with "ESLint v8" and the esquery selector specified as below:

export default function (context) {
  return {
    "JSXElement[openingElement.name.name='p'] > JSXElement[openingElement.name.name=/^span$/]": (
      node
    ) => {
      context.report({
        node,
        message: "Found"
      });
    }
  };
}

On AST explorer: https://astexplorer.net/#/gist/4699a2ceadc890386cbd0727734c3ca5/c9250ace00e2686b4d95879dff67341ce35d9018

Screenshot 2023-04-18 at 12 42 44