[TASK] boilerplate eslint config: lint browser <script> blocks from HTML with core JS rules

Open Beginner friendly
#2,793 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
eslint, javascript
Domain
tooling

Research direction

Start with boilerplate/files/eslint.config.js and trace how modernFiles, browserFiles, and serverBlocks are used. Check the boilerplate dependency for eslint-plugin-sfmc and inspect test/tooling.smoke.test.js for the existing lint fixture. Done means the browser script virtual files receive the specified core JS rules, classic script handling is preserved, and the smoke test passes.

Written by the indexing model from the issue text.

Description

c/INIT chore

What

Since eslint-plugin-sfmc 5.7.0, the combined HTML processor also extracts browser JavaScript from <script> tags without runat="server". Those blocks come out as virtual files named *.html/browser-script-N.mjs (classic scripts) and *.html/browser-module-N.mjs (type="module").

The boilerplate boilerplate/files/eslint.config.js does not cover them yet:

  • unicorn recommended already applies, because its **/*.{js,mjs,cjs,ssjs} pattern matches .mjs.
  • js.configs.recommended, no-var and prefer-const do not apply, because modernFiles only lists retrieve/**/*.js, deploy/**/*.js and the Node files.

So inline browser JavaScript in retrieved HTML (CloudPages, emails, code snippets) misses the core JS checks.

Fix

Add a separate file list for the browser blocks and include it in the js.configs.recommended and no-var / prefer-const blocks only:

// Browser JavaScript the sfmc processor extracts from HTML <script> tags (eslint-plugin-sfmc >= 5.7.0).
const htmlBrowserBlocks = ['**/*.html/browser-*.mjs'];
// ...
{ ...js.configs.recommended, files: [...modernFiles, ...htmlBrowserBlocks], ignores: serverBlocks },
{ files: [...modernFiles, ...htmlBrowserBlocks], ignores: serverBlocks, rules: { 'no-var': 'error', 'prefer-const': 'error' } },

Do not add them to browserFiles: that block sets sourceType: 'module', which would override the plugin's script-vs-module split for classic <script> tags. The plugin already sets browser globals and ecmaVersion: 2025 for these blocks. Leave jsdoc off them (too noisy on inline snippets).

Done when

  • boilerplate/files/eslint.config.js updated as above
  • the boilerplate's eslint-plugin-sfmc dependency is at least 5.7.0
  • the comment on serverBlocks still makes sense (only *.js children are SSJS; browser children are .mjs)
  • tooling smoke test (test/tooling.smoke.test.js) still passes, ideally with an HTML fixture containing a browser <script> that triggers prefer-const
Dominant language
JavaScript
Stars
166
Forks
50
Avg merge
11h 4m
Merged PRs (30d)
36

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Accenture/sfmc-devtools

All issues in Accenture/sfmc-devtools

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.