Skip to content

Add an emberSourceVersion parser option - #267

Merged
NullVoxPopuli merged 1 commit into
ember-tooling:mainfrom
davidtaylorhq:ember-source-version-option
Oct 22, 2026
Merged

NullVoxPopuli merged 1 commit into
ember-tooling:mainfrom
davidtaylorhq:ember-source-version-option

Conversation

@davidtaylorhq

Copy link
Copy Markdown
Contributor

The parser treats the Ember 7.1 built-in template keywords (eq, and, on and the rest) as defined only when it can resolve ember-source 7.1 or newer from its own install location. Projects that lint without ember-source installed get a no-undef error for every bare keyword, and they have no way to tell the parser which Ember they run on. Discourse plugins and themes are an example: they run inside Discourse, but their repos don't install ember-source.

  • parserOptions.emberSourceVersion sets the version to use. When it's set, the parser uses it instead of looking for ember-source.
  • New tests cover the option when ember-source can't be found, and the option winning over a newer installed version.
  • The README has a short section on the built-in keywords and the new option.

The parser treats the Ember 7.1 built-in template keywords (`eq`, `and`, `on` and the rest) as defined only when it can resolve `ember-source` 7.1 or newer from its own install location. Projects that lint without `ember-source` installed get a `no-undef` error for every bare keyword, and they have no way to tell the parser which Ember they run on. Discourse plugins and themes are an example: they run inside Discourse, but their repos don't install `ember-source`.

- `parserOptions.emberSourceVersion` sets the version to use. When it's set, the parser uses it instead of looking for `ember-source`.
- New tests cover the option when `ember-source` can't be found, and the option winning over a newer installed version.
- The README has a short section on the built-in keywords and the new option.
davidtaylorhq added a commit to discourse/lint-configs that referenced this pull request Oct 22, 2026
Ember 7.1 made `and`, `or`, `not`, `eq`, `neq`, `gt`, `gte`, `lt` and `lte` built-in template keywords, so `.gjs` and `.gts` templates no longer need to import them from `discourse/truth-helpers`. This rule reports those imports, and its autofix deletes them.

- `notEq` becomes the `neq` keyword, and an aliased import such as `or as either` goes back to its keyword name. The autofix renames the template uses to match.
- Truth helpers that have no keyword, such as `has` and `includes`, stay imported.
- The old `truth-helpers` import path is handled too.
- `fixImport` now removes the whole declaration when no imports are left in it, instead of writing `import  from "…"`.
- `ember-source` is a temporary dev dependency. `ember-eslint-parser` only treats the keywords as defined when it can find `ember-source` 7.1 or newer, so without it `no-undef` flags the bare `or` that the autofix leaves in the test fixture. Plugin and theme repos that don't install `ember-source` will see the same errors. Both go away once ember-tooling/ember-eslint-parser#267 is released and this config sets its `emberSourceVersion` option.

Bumps the package to 3.9.0.
@github-actions

Copy link
Copy Markdown
Contributor

🏎️ Benchmark Comparison

Parse

Benchmark Control (p50) Experiment (p50) Δ
🟢 gts small 973.80 ms 917.49 ms -5.8%
⚪ gts medium 1626.97 ms 1598.96 ms -1.7%
⚪ gts large 772.61 ms 778.95 ms +0.8%
⚪ gjs small 782.99 ms 789.80 ms +0.9%
⚪ gjs medium 1408.26 ms 1424.82 ms +1.2%
🟢 gjs large 653.29 ms 623.32 ms -4.6%
🔴 hbs small 128.46 ms 137.75 ms +7.2%
🟢 hbs medium 733.91 ms 714.54 ms -2.6%
🟢 hbs large 821.47 ms 798.28 ms -2.8%

🟢 faster · 🔴 slower · 🟠 slightly slower · ⚪ within 2%

Full mitata output
clk: ~3.10 GHz
cpu: AMD EPYC 7763 64-Core Processor
runtime: node 24.21.0 (x64-linux)

benchmark                   avg (min … max) p75 / p99    (min … top 1%)
------------------------------------------- -------------------------------
gts small (control)          998.57 ms/iter    1.05 s                     █
                       (828.74 ms … 1.35 s)    1.12 s ▅▅  ▅▅▅   ▅▅ ▅ ▅    █
                    ( 15.26 mb …  92.33 mb)  35.22 mb ██▁▁███▁▁▁██▁█▁█▁▁▁▁█

gts small (experiment)       955.75 ms/iter    1.00 s      █    █          
                       (800.46 ms … 1.26 s)    1.09 s ▅ ▅▅ █  ▅ █   ▅    ▅▅
                    ( 15.13 mb …  87.00 mb)  39.26 mb █▁██▁█▁▁█▁█▁▁▁█▁▁▁▁██

                             ┌                                            ┐
                                 ╷        ┌──────────────┬───────┐        ╷
         gts small (control)     ├────────┤              │       ├────────┤
                                 ╵        └──────────────┴───────┘        ╵
                             ╷      ┌──────────────┬──────┐            ╷
      gts small (experiment) ├──────┤              │      ├────────────┤
                             ╵      └──────────────┴──────┘            ╵
                             └                                            ┘
                             800.46 ms           957.81 ms           1.12 s

summary
  gts small (experiment)
   1.04x faster than gts small (control)

------------------------------------------- -------------------------------
gts medium (control)            1.66 s/iter    1.67 s █                    
                          (1.55 s … 2.12 s)    1.72 s █▅ ▅ ▅   ▅ ▅▅ ▅  ▅  ▅
                    ( 33.56 mb … 105.29 mb)  85.75 mb ██▁█▁█▁▁▁█▁██▁█▁▁█▁▁█

gts medium (experiment)         1.65 s/iter    1.67 s █  █ ███ █ ██  ██   █
                          (1.49 s … 2.18 s)    1.73 s █  █ ███ █ ██  ██   █
                    ( 34.02 mb … 105.61 mb)  86.06 mb █▁▁█▁███▁█▁██▁▁██▁▁▁█

                             ┌                                            ┐
                                        ╷┌───────────────────┬┐         ╷
        gts medium (control)            ├┤                   │├─────────┤
                                        ╵└───────────────────┴┘         ╵
                             ╷           ┌─────────────────┬───┐          ╷
     gts medium (experiment) ├───────────┤                 │   ├──────────┤
                             ╵           └─────────────────┴───┘          ╵
                             └                                            ┘
                             1.49 s              1.61 s              1.73 s

summary
  gts medium (experiment)
   1.01x faster than gts medium (control)

------------------------------------------- -------------------------------
gts large (control)          820.13 ms/iter 826.22 ms   █   █              
                       (731.44 ms … 1.24 s) 858.20 ms ▅ █▅  █▅▅      ▅ ▅  ▅
                    ( 18.06 mb …  89.56 mb)  41.50 mb █▁██▁▁███▁▁▁▁▁▁█▁█▁▁█

gts large (experiment)       832.35 ms/iter 862.70 ms     █                
                       (734.88 ms … 1.19 s) 931.83 ms   █ █                
                    ( 18.65 mb …  90.16 mb)  42.20 mb █▁████▁▁▁▁▁▁▁█▁█▁▁▁▁█

                             ┌                                            ┐
                             ╷  ┌────────────────┬┐      ╷
         gts large (control) ├──┤                │├──────┤
                             ╵  └────────────────┴┘      ╵
                              ╷    ┌────────────────┬─────┐               ╷
      gts large (experiment)  ├────┤                │     ├───────────────┤
                              ╵    └────────────────┴─────┘               ╵
                             └                                            ┘
                             731.44 ms         831.63 ms          931.83 ms

summary
  gts large (control)
   1.01x faster than gts large (experiment)

------------------------------------------- -------------------------------
gjs small (control)          816.42 ms/iter 822.25 ms  █                   
                       (748.04 ms … 1.10 s) 887.89 ms  █   █               
                    ( 32.25 mb …  47.97 mb)  34.76 mb ███▁▁█▁▁▁█▁██▁▁▁▁▁▁▁█

gjs small (experiment)       820.97 ms/iter 830.27 ms  █ █                 
                       (743.67 ms … 1.08 s) 887.46 ms ▅█ █  ▅▅   ▅▅    ▅  ▅
                    ( 32.17 mb …  47.62 mb)  34.57 mb ██▁█▁▁██▁▁▁██▁▁▁▁█▁▁█

                             ┌                                            ┐
                              ╷ ┌───────────────────┬─┐                   ╷
         gjs small (control)  ├─┤                   │ ├───────────────────┤
                              ╵ └───────────────────┴─┘                   ╵
                             ╷ ┌─────────────────────┬──┐                 ╷
      gjs small (experiment) ├─┤                     │  ├─────────────────┤
                             ╵ └─────────────────────┴──┘                 ╵
                             └                                            ┘
                             743.67 ms         815.78 ms          887.89 ms

summary
  gjs small (control)
   1.01x faster than gjs small (experiment)

------------------------------------------- -------------------------------
gjs medium (control)            1.44 s/iter    1.44 s █                    
                          (1.34 s … 1.88 s)    1.49 s █▅▅  ▅   ▅▅  ▅▅    ▅▅
                    ( 27.05 mb …  99.53 mb)  69.42 mb ███▁▁█▁▁▁██▁▁██▁▁▁▁██

gjs medium (experiment)         1.45 s/iter    1.46 s             █        
                          (1.29 s … 1.85 s)    1.51 s             █        
                    ( 27.03 mb …  99.74 mb)  74.51 mb █▁▁█▁█▁▁▁▁▁███▁██▁▁▁█

                             ┌                                            ┐
                                       ╷ ┌──────────────────┬        ╷
        gjs medium (control)           ├─┤                  │────────┤
                                       ╵ └──────────────────┴        ╵
                             ╷           ┌───────────────────┬┐           ╷
     gjs medium (experiment) ├───────────┤                   │├───────────┤
                             ╵           └───────────────────┴┘           ╵
                             └                                            ┘
                             1.29 s              1.40 s              1.51 s

summary
  gjs medium (control)
   1x faster than gjs medium (experiment)

------------------------------------------- -------------------------------
gjs large (control)          687.10 ms/iter 661.12 ms    █ ██              
                    (621.10 ms … 972.13 ms) 756.71 ms ▅ ▅█▅██     ▅       ▅
                    (  2.14 mb …  74.20 mb)  33.11 mb █▁█████▁▁▁▁▁█▁▁▁▁▁▁▁█

gjs large (experiment)       675.80 ms/iter 645.78 ms  █                   
                       (599.33 ms … 1.02 s) 781.53 ms ██ █ █               
                    (  2.52 mb …  73.93 mb)  33.01 mb ██▁█▁█▁▁▁▁▁▁▁▁▁▁█▁▁▁█

                             ┌                                            ┐
                                  ╷    ┌───────────┬                ╷
         gjs large (control)      ├────┤           │────────────────┤
                                  ╵    └───────────┴                ╵
                             ╷ ┌────────────────┬                         ╷
      gjs large (experiment) ├─┤                │─────────────────────────┤
                             ╵ └────────────────┴                         ╵
                             └                                            ┘
                             599.33 ms         690.43 ms          781.53 ms

summary
  gjs large (experiment)
   1.02x faster than gjs large (control)

------------------------------------------- -------------------------------
hbs small (control)          144.90 ms/iter 152.08 ms     █              █ 
                    (115.67 ms … 261.29 ms) 154.64 ms ▅▅  █ ▅▅  ▅    ▅   █▅
                    ( 51.34 mb …  54.04 mb)  52.83 mb ██▁▁█▁██▁▁█▁▁▁▁█▁▁▁██

hbs small (experiment)       150.45 ms/iter 150.57 ms         █            
                    (110.63 ms … 285.16 ms) 177.08 ms ▅ ▅ ▅▅▅ █  ▅▅ ▅     ▅
                    ( 51.22 mb …  54.91 mb)  53.44 mb █▁█▁███▁█▁▁██▁█▁▁▁▁▁█

                             ┌                                            ┐
                                ╷    ┌──────────────┬────┐ ╷
         hbs small (control)    ├────┤              │    ├─┤
                                ╵    └──────────────┴────┘ ╵
                             ╷        ┌─────────────────┬                 ╷
      hbs small (experiment) ├────────┤                 │─────────────────┤
                             ╵        └─────────────────┴                 ╵
                             └                                            ┘
                             110.63 ms         143.86 ms          177.08 ms

summary
  hbs small (control)
   1.04x faster than hbs small (experiment)

------------------------------------------- -------------------------------
hbs medium (control)         771.76 ms/iter 756.18 ms  █                   
                       (721.83 ms … 1.04 s) 814.57 ms  █ █                 
                    (  9.17 mb …  82.99 mb)  33.14 mb █████▁▁█▁▁▁▁▁▁▁▁▁▁▁██

hbs medium (experiment)      748.80 ms/iter 731.02 ms  █ █                 
                    (702.68 ms … 984.97 ms) 790.31 ms  █ █                █
                    (  9.15 mb …  82.81 mb)  33.15 mb ██▁█▁██▁▁▁▁▁▁▁▁▁▁▁▁▁█

                             ┌                                            ┐
                                     ╷┌──────────────────┬                ╷
        hbs medium (control)         ├┤                  │────────────────┤
                                     ╵└──────────────────┴                ╵
                             ╷┌─────────────────┬               ╷
     hbs medium (experiment) ├┤                 │───────────────┤
                             ╵└─────────────────┴               ╵
                             └                                            ┘
                             702.68 ms         758.63 ms          814.57 ms

summary
  hbs medium (experiment)
   1.03x faster than hbs medium (control)

------------------------------------------- -------------------------------
hbs large (control)          850.59 ms/iter 836.37 ms █  █                 
                       (809.61 ms … 1.08 s) 885.29 ms █  █                 
                    ( 53.50 mb …  64.88 mb)  55.53 mb █▁▁██▁██▁▁▁▁█▁▁▁▁▁▁▁█

hbs large (experiment)       834.06 ms/iter 804.84 ms ██                   
                       (791.66 ms … 1.12 s) 886.58 ms ███                  
                    ( 53.49 mb …  64.85 mb)  55.50 mb ████▁▁▁█▁▁▁▁▁▁▁▁▁▁▁▁█

                             ┌                                            ┐
                                      ┌──────────────────┬               ╷
         hbs large (control)          │                  │───────────────┤
                                      └──────────────────┴               ╵
                             ╷┌──────────────────┬                        ╷
      hbs large (experiment) ├┤                  │────────────────────────┤
                             ╵└──────────────────┴                        ╵
                             └                                            ┘
                             791.66 ms         839.12 ms          886.58 ms

summary
  hbs large (experiment)
   1.02x faster than hbs large (control)
### Project mode (type-aware)
Benchmark Control (p50) Experiment (p50) Δ
⚪ project warm parse x150 591.93 ms 585.94 ms -1.0%
⚪ project parse+typed x150 642.58 ms 653.93 ms +1.8%
🟢 projectService warm parse x150 680.47 ms 615.55 ms -9.5%
🟢 projectService parse+typed x150 670.44 ms 654.23 ms -2.4%

🟢 faster · 🔴 slower · 🟠 slightly slower · ⚪ within 2%

Full mitata output
clk: ~3.04 GHz
cpu: AMD EPYC 7763 64-Core Processor
runtime: node 24.21.0 (x64-linux)

benchmark                                   avg (min … max) p75 / p99    (min … top 1%)
----------------------------------------------------------- -------------------------------
project warm parse x150 (control)            594.24 ms/iter 599.18 ms     █         █      
                                    (580.34 ms … 616.13 ms) 607.14 ms ██▁▁█▁█▁▁█▁█▁▁█▁█▁▁▁█
                                  gc(279.23 ms … 289.87 ms) 114.36 mb (112.78 mb…115.21 mb)

project warm parse x150 (experiment)         596.99 ms/iter 603.47 ms  ▃   █               
                                    (569.81 ms … 647.37 ms) 634.61 ms ▆█▁▁▁█▆▁▁▆▆▁▁▁▁▆▁▁▁▁▆
                                  gc(276.38 ms … 291.95 ms) 112.21 mb (111.41 mb…112.79 mb)

                                             ┌                                            ┐
                                                    ╷   ┌─────┬──┐     ╷
           project warm parse x150 (control)        ├───┤     │  ├─────┤
                                                    ╵   └─────┴──┘     ╵
                                             ╷  ┌───────────────┬───┐                     ╷
        project warm parse x150 (experiment) ├──┤               │   ├─────────────────────┤
                                             ╵  └───────────────┴───┘                     ╵
                                             └                                            ┘
                                             569.81 ms         602.21 ms          634.61 ms

summary
  project warm parse x150 (control)
   1x faster than project warm parse x150 (experiment)

----------------------------------------------------------- -------------------------------
project parse+typed x150 (control)           649.11 ms/iter 667.32 ms          █          █
                                    (605.57 ms … 703.21 ms) 689.08 ms █▁██▁██▁▁█▁▁▁▁██▁▁▁▁█
                                  gc(278.40 ms … 299.78 ms) 119.50 mb (118.03 mb…123.36 mb)

project parse+typed x150 (experiment)        651.90 ms/iter 673.28 ms █            █     █ 
                                    (621.94 ms … 687.57 ms) 676.63 ms █▁██▁█▁▁▁▁▁▁██▁▁▁▁▁██
                                  gc(286.35 ms … 306.94 ms) 112.35 mb (111.47 mb…116.61 mb)

                                             ┌                                            ┐
                                             ╷     ┌────────────────┬─────────┐           ╷
          project parse+typed x150 (control) ├─────┤                │         ├───────────┤
                                             ╵     └────────────────┴─────────┘           ╵
                                                      ╷  ┌────────────┬──────────┐ ╷
       project parse+typed x150 (experiment)          ├──┤            │          ├─┤
                                                      ╵  └────────────┴──────────┘ ╵
                                             └                                            ┘
                                             605.57 ms         647.32 ms          689.08 ms

summary
  project parse+typed x150 (control)
   1x faster than project parse+typed x150 (experiment)

----------------------------------------------------------- -------------------------------
projectService warm parse x150 (control)     678.72 ms/iter 688.72 ms                   █  
                                    (655.08 ms … 693.95 ms) 692.07 ms ██▁▁▁▁▁▁█▁▁██▁███▁█▁█
                                  gc(295.21 ms … 318.57 ms) 115.45 mb (113.35 mb…116.20 mb)

projectService warm parse x150 (experiment)  626.90 ms/iter 626.65 ms        █  ▃          
                                    (594.61 ms … 714.47 ms) 651.40 ms ▆▁▆▁▆▁▁█▁▁█▆▁▁▁▆▁▁▁▁▆
                                  gc(288.57 ms … 340.47 ms) 111.97 mb (111.57 mb…112.25 mb)

                                             ┌                                            ┐
                                                                         ╷      ┌───┬───┐ ╷
    projectService warm parse x150 (control)                             ├──────┤   │   ├─┤
                                                                         ╵      └───┴───┘ ╵
                                             ╷    ┌─────────┬          ╷
 projectService warm parse x150 (experiment) ├────┤         │──────────┤
                                             ╵    └─────────┴          ╵
                                             └                                            ┘
                                             594.61 ms         643.34 ms          692.07 ms

summary
  projectService warm parse x150 (experiment)
   1.08x faster than projectService warm parse x150 (control)

----------------------------------------------------------- -------------------------------
projectService parse+typed x150 (control)    674.34 ms/iter 678.80 ms            █         
                                    (644.85 ms … 717.49 ms) 692.43 ms █▁▁▁█▁█▁▁▁█████▁▁▁█▁█
                                  gc(295.37 ms … 312.68 ms) 119.90 mb (118.98 mb…123.54 mb)

projectService parse+typed x150 (experiment) 660.99 ms/iter 663.80 ms █  █ █               
                                    (640.52 ms … 701.88 ms) 698.06 ms █▁▁████▁██▁▁▁▁▁▁▁▁▁▁█
                                  gc(299.76 ms … 317.16 ms) 115.97 mb (111.68 mb…119.76 mb)

                                             ┌                                            ┐
                                                ╷           ┌──────────┬───┐          ╷
   projectService parse+typed x150 (control)    ├───────────┤          │   ├──────────┤
                                                ╵           └──────────┴───┘          ╵
                                             ╷      ┌────────┬─┐                          ╷
projectService parse+typed x150 (experiment) ├──────┤        │ ├──────────────────────────┤
                                             ╵      └────────┴─┘                          ╵
                                             └                                            ┘
                                             640.52 ms         669.29 ms          698.06 ms

summary
  projectService parse+typed x150 (experiment)
   1.02x faster than projectService parse+typed x150 (control)

@NullVoxPopuli NullVoxPopuli added the enhancement New feature or request label Oct 22, 2026
@NullVoxPopuli
NullVoxPopuli merged commit 09bedb3 into ember-tooling:main Oct 22, 2026
38 of 39 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants