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

🐛 noRestrictedGlobals rule doesn't allow to specify restricted globals #4628

Closed
1 task done
msereniti opened this issue Jun 28, 2023 · 1 comment · Fixed by #4723
Closed
1 task done

🐛 noRestrictedGlobals rule doesn't allow to specify restricted globals #4628

msereniti opened this issue Jun 28, 2023 · 1 comment · Fixed by #4723
Labels
A-Linter Area: linter enhancement New feature request or improvement to existing functionality

Comments

@msereniti
Copy link

msereniti commented Jun 28, 2023

Environment information

CLI:
  Version:                      12.1.3
  Color support:                true

Platform:
  CPU Architecture:             aarch64
  OS:                           macos

Environment:
  ROME_LOG_DIR:                 unset
  NO_COLOR:                     unset
  TERM:                         "xterm-256color"
  JS_RUNTIME_VERSION:           "v20.3.0"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "pnpm/7.33.1"

Rome Configuration:
  Status:                       Loaded successfully
  Formatter disabled:           false
  Linter disabled:              false
  Organize imports disabled:    true
  VCS disabled:                 true

Workspace:
  Open Documents:               0

Discovering running Rome servers...

Running Rome Server: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

i The client isn't connected to any server but rage discovered this running Rome server.

Server:
  Version:                      12.1.3
  Name:                         rome_lsp
  CPU Architecture:             aarch64
  OS:                           macos

Workspace:
  Open Documents:               0

Other Active Server Workspaces:

Workspace:
  Open Documents:               8
  Client Name:                  Visual Studio Code
  Client Version:               1.79.2

Workspace:
  Open Documents:               10
  Client Name:                  Visual Studio Code
  Client Version:               1.79.2

Workspace:
  Open Documents:               11
  Client Name:                  Visual Studio Code
  Client Version:               1.79.2

What happened?

  1. Initialize js project with rome.
  2. Create rome.json file
  3. Add style/noRestrictedGlobals rule.
  4. Try to specify which globals should be restricted via "options" field. (e.g. "noRestrictedGlobals": { "level": "warn", "options": ["window"] })

Only event and error global variables from constant are being restricted.

"options" field is ignored.

Expected result

Global names listed in the "options" field are restricted because documentation says "Disallowing usage of specific global variables can be useful if you want to allow a set of global variables by enabling an environment, but still want to disallow some of those."

Code of Conduct

  • I agree to follow Rome's Code of Conduct
@msereniti msereniti added the S-To triage Status: user report of a possible bug that needs to be triaged label Jun 28, 2023
@blutorange
Copy link

Also very useful when you have to use libraries such as JQuery and want to make sure you don't accidentally use the global $ variable, but import it from the jquery package!

@ematipico ematipico added enhancement New feature request or improvement to existing functionality A-Linter Area: linter and removed S-To triage Status: user report of a possible bug that needs to be triaged labels Jul 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Linter Area: linter enhancement New feature request or improvement to existing functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants