@nethru/ui 2.1.15 → 2.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,6 +23,7 @@ export default function Editor({
23
23
  basicSetup,
24
24
  keymap = [],
25
25
  eslintRules,
26
+ customVariables = [],
26
27
  extensions = [],
27
28
  format = 'javascript',
28
29
  keyword,
@@ -145,9 +146,12 @@ export default function Editor({
145
146
  }
146
147
  }, [format]);
147
148
  const eslintLinter = useMemo(() => {
149
+ const regex = /\{\{(\S+)\}\}/g;
148
150
  return format === 'javascript' ? linter(view => {
149
151
  const text = view.state.doc.toString();
150
152
  const linter = new Linter();
153
+ let replaced = text;
154
+ let hints = [];
151
155
  const config = {
152
156
  rules: {
153
157
  "func-names": "off",
@@ -155,18 +159,35 @@ export default function Editor({
155
159
  ...eslintRules
156
160
  }
157
161
  };
158
- const hints = linter.verify(text, config).map(hint => ({
159
- line: hint.line,
160
- column: hint.column,
161
- from: view.state.doc.line(hint.line).from + hint.column - 1,
162
- to: view.state.doc.line(hint.line).from + hint.column - 1 + (linter.getSourceCode()?.length || 0),
163
- severity: hint.severity === 2 ? "error" : "warning",
164
- message: hint.message
165
- }));
162
+ if (customVariables.length > 0) {
163
+ let match;
164
+ while ((match = regex.exec(text)) !== null) {
165
+ if (!customVariables.includes(match[1])) {
166
+ hints.push({
167
+ from: match.index + 2,
168
+ to: match.index + 2,
169
+ severity: 'error',
170
+ message: `${match[1]}는 정의된 변수가 아닙니다.`
171
+ });
172
+ break;
173
+ }
174
+ }
175
+ replaced = text.replace(regex, () => `''`);
176
+ }
177
+ if (hints.length === 0) {
178
+ hints = linter.verify(replaced, config).map(hint => ({
179
+ line: hint.line,
180
+ column: hint.column,
181
+ from: view.state.doc.line(hint.line).from + hint.column - 1,
182
+ to: view.state.doc.line(hint.line).from + hint.column - 1 + (linter.getSourceCode()?.length || 0),
183
+ severity: hint.severity === 2 ? "error" : "warning",
184
+ message: hint.message
185
+ }));
186
+ }
166
187
  if (onEslintUpdate) onEslintUpdate(hints);
167
188
  return hints;
168
189
  }) : undefined;
169
- }, [format, eslintRules, onEslintUpdate]);
190
+ }, [format, eslintRules, onEslintUpdate, customVariables]);
170
191
  const keymapExtension = useMemo(() => {
171
192
  return [keyMapper.of(keymap), keyMapper.of(defaultKeymap)];
172
193
  }, [keymap]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nethru/ui",
3
- "version": "2.1.15",
3
+ "version": "2.1.16",
4
4
  "main": "base/index.js",
5
5
  "files": [
6
6
  "/base"
@@ -26,7 +26,7 @@
26
26
  "dayjs": "^1.11.13",
27
27
  "days": "^1.1.1",
28
28
  "eslint-browser": "^3.8.1",
29
- "eslint-linter-browserify": "^9.17.0",
29
+ "eslint-linter-browserify": "^8.20.0",
30
30
  "eslint-utils": "^3.0.0",
31
31
  "eslint4b": "^7.32.0",
32
32
  "immer": "^10.0.3",