astexplorer icon indicating copy to clipboard operation
astexplorer copied to clipboard

Comments checkbox

Open brettz9 opened this issue 5 years ago • 4 comments

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).

brettz9 avatar Feb 20 '20 11:02 brettz9

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.

fkling avatar Mar 12 '20 23:03 fkling

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.

brettz9 avatar Mar 17 '20 14:03 brettz9

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 avatar Apr 18 '23 10:04 karlhorky

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

karlhorky avatar Apr 18 '23 10:04 karlhorky