Skip to content

Commit 6d2a2b1

Browse files
numbers are visible now when using underscores, no red error lines
1 parent f079530 commit 6d2a2b1

File tree

1 file changed

+51
-1
lines changed
  • client/modules/IDE/components/Editor

1 file changed

+51
-1
lines changed

client/modules/IDE/components/Editor/index.jsx

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,18 @@ class Editor extends React.Component {
140140
styleSelectedText: true,
141141
lint: {
142142
onUpdateLinting: (annotations) => {
143-
this.updateLintingMessageAccessibility(annotations);
143+
const filteredAnnotations = annotations.filter((annotation) => {
144+
const message = (annotation.message || '').toLowerCase();
145+
const isNumericSeparatorError =
146+
(message.includes('unexpected') &&
147+
(message.includes("'_'") || message.includes('_'))) ||
148+
message.includes('numeric separator') ||
149+
(message.includes('syntax') && message.includes('_')) ||
150+
(message.includes('illegal') && message.includes('_')) ||
151+
(message.includes('token') && message.includes('_'));
152+
return !isNumericSeparatorError;
153+
});
154+
this.updateLintingMessageAccessibility(filteredAnnotations);
144155
},
145156
options: {
146157
asi: true,
@@ -162,6 +173,45 @@ class Editor extends React.Component {
162173

163174
delete this._cm.options.lint.options.errors;
164175

176+
if (CodeMirror.lint && CodeMirror.lint.javascript) {
177+
const originalJSLint = CodeMirror.lint.javascript;
178+
CodeMirror.lint.javascript = (text, options, cm) => {
179+
const result = originalJSLint(text, options, cm);
180+
if (Array.isArray(result)) {
181+
const lines = text.split('\n');
182+
return result.filter((annotation) => {
183+
const lineNum = annotation.from ? annotation.from.line : 0;
184+
const lineContent = lines[lineNum] || '';
185+
const hasNumericSeparator = /\d+_\d+/.test(lineContent);
186+
const message = (annotation.message || '').toLowerCase();
187+
if (hasNumericSeparator) {
188+
if (
189+
message.includes('unexpected') ||
190+
message.includes('_') ||
191+
message.includes('syntax') ||
192+
message.includes('illegal') ||
193+
message.includes('token') ||
194+
message.includes('character')
195+
) {
196+
return false;
197+
}
198+
}
199+
200+
const isNumericSeparatorError =
201+
(message.includes('unexpected') &&
202+
(message.includes("'_'") || message.includes('_'))) ||
203+
message.includes('numeric separator') ||
204+
(message.includes('syntax') && message.includes('_')) ||
205+
(message.includes('illegal') && message.includes('_')) ||
206+
(message.includes('token') && message.includes('_'));
207+
208+
return !isNumericSeparatorError;
209+
});
210+
}
211+
return result;
212+
};
213+
}
214+
165215
this._cm.getWrapperElement().addEventListener('click', (e) => {
166216
const isCtrlClick = isMac() ? e.metaKey : e.ctrlKey;
167217

0 commit comments

Comments
 (0)