Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Diag Type for Invalid Characters in Config #845

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions docs/errors/E0292.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# E0292: character is not allowed in global identifiers

Certain characters generate errors when used in JSON global variables in config files, such as the ```.``` below.

```example-invalid-period
{
"globals": {
"jest.": true
}
}
```

Leading spaces and numbers are also disallowed:

```example-invalid-nums
{
"globals": {
"123ABC": true
}
}
```

As are certain unicode characters:

```example-invalid-unicode
{
"globals": {
"\u2604": true
}
}
```

To fix this error, rename variables to exclude disallowed characters and leading numbers or spaces.
7 changes: 7 additions & 0 deletions src/quick-lint-js/fe/diagnostic-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,13 @@
QLJS_TRANSLATABLE("commas are not allowed between class methods"), \
unexpected_comma)) \
\
QLJS_DIAG_TYPE( \
diag_config_character_disallowed_in_identifiers, "E0292", \
diagnostic_severity::error, { source_code_span character; }, \
MESSAGE( \
QLJS_TRANSLATABLE("character is not allowed in global identifiers"), \
character)) \
\
QLJS_DIAG_TYPE( \
diag_config_json_syntax_error, "E0164", diagnostic_severity::error, \
{ source_code_span where; }, \
Expand Down