Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

feat(rome_js_analyzer): read globals from analyzer options #4261

Merged
merged 1 commit into from
Mar 6, 2023

Conversation

ematipico
Copy link
Contributor

Summary

The analyzer infrastructure has had for a while the globals field available in the configuration, although it wasn't documented because it wasn't used.

This PR implements the logic to read these globals and update the noUnusedVariables rule to consume it.

Test Plan

I created a new test case to make sure the feature works.

Documentation

  • The PR requires documentation
  • I will create a new PR to update the documentation

@netlify
Copy link

netlify bot commented Mar 5, 2023

Deploy Preview for docs-rometools canceled.

Name Link
🔨 Latest commit 45c4c68
🔍 Latest deploy log https://app.netlify.com/sites/docs-rometools/deploys/640484ed6c3ed4000754fcce

@ematipico ematipico added the A-Linter Area: linter label Mar 5, 2023
Comment on lines +123 to +128
let globals: Vec<_> = options
.configuration
.globals
.iter()
.map(|global| global.as_str())
.collect();
Copy link
Contributor Author

@ematipico ematipico Mar 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately there isn't a way to transform a Vec<String> to &[&str] without allocation. Although, this allocation is done once per analyzer pass, which is cheaper than doing the allocation for each rule.

@ematipico
Copy link
Contributor Author

!bench_analyzer

@github-actions
Copy link

github-actions bot commented Mar 5, 2023

Analyzer Benchmark Results

group                     main                                   pr
-----                     ----                                   --
analyzer/css.js           1.01      3.2±0.00ms     3.7 MB/sec    1.00      3.1±0.01ms     3.7 MB/sec
analyzer/index.js         1.01      7.6±0.03ms     4.2 MB/sec    1.00      7.5±0.01ms     4.3 MB/sec
analyzer/lint.ts          1.01      3.4±0.01ms    12.1 MB/sec    1.00      3.4±0.01ms    12.3 MB/sec
analyzer/parser.ts        1.01     10.3±0.02ms     4.7 MB/sec    1.00     10.2±0.03ms     4.8 MB/sec
analyzer/router.ts        1.02      3.4±0.01ms     9.1 MB/sec    1.00      3.4±0.00ms     9.2 MB/sec
analyzer/statement.ts     1.02      9.8±0.02ms     3.6 MB/sec    1.00      9.6±0.04ms     3.7 MB/sec
analyzer/typescript.ts    1.02     14.8±0.05ms     3.7 MB/sec    1.00     14.5±0.03ms     3.8 MB/sec

@ematipico ematipico merged commit 7a2d97e into main Mar 6, 2023
@ematipico ematipico deleted the feat/extend-undeclared branch March 6, 2023 19:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Linter Area: linter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant