AGLint
AGLint copied to clipboard
Optimizing AST traversal
Currently, the core traverses the AST, but this approach is not always the most efficient. As we introduce more CSS-specific linter rules, each of them will individually traverse the CSS-related ASTs. For example, if we have 4 linter rules searching for various issues in element hiding rules' CSS, this would result in 4xN AST traversals, where N is the number of element hiding rules.
It might be worth considering a solution similar to the one used by ESLint, where linter rules define AST selectors along with the logic that should execute for those nodes. This way, the linter core can efficiently combine the AGTree parser with any other parser, like CSSTree or Acorn and only needs to traverse the whole AST once. Additionally, CSS parsing errors will be reported by the core itself only once (currently, each CSS rule individually reports parsing errors due to the design).