Skip to content

Commit 3531f3f

Browse files
authored
TypePanel: Add button for clearing all previous warnings (#169)
* TypePanel: Add button for clearing all previous warnings * Remove useless lint warning * Fix lint the 2nd
1 parent 1dac208 commit 3531f3f

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

.eslintrc.cjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ module.exports = {
3333
"no-dupe-else-if": "error",
3434
"no-dupe-keys": "error",
3535
"no-duplicate-case": "error",
36-
// "no-duplicate-imports": "error",
36+
"no-duplicate-imports": "off",
3737
"no-empty-character-class": "error",
3838
"no-empty-pattern": "error",
3939
"no-ex-assign": "error",
@@ -395,7 +395,7 @@ module.exports = {
395395

396396
// Style guide
397397
"import/extensions": ["error", "always", {"ts": "never", "tsx": "never"}],
398-
"import/no-duplicates": "warn",
398+
"import/no-duplicates": "off",
399399

400400
// JSDoc rules
401401
"jsdoc/check-access": "error",

src-runtime/TypePanel.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,12 @@ class TypePanel {
5757
buttonHide = document.createElement('button');
5858
buttonLoadState = document.createElement('button');
5959
buttonSaveState = document.createElement('button');
60+
buttonClear = document.createElement('button');
6061
constructor() {
61-
const {div, inputEnable, spanErrors, span, select, option_spam, option_once, option_never, buttonHide, buttonLoadState, buttonSaveState} = this;
62+
const {
63+
div, inputEnable, spanErrors, span, select, option_spam, option_once, option_never,
64+
buttonHide, buttonLoadState, buttonSaveState, buttonClear
65+
} = this;
6266
div.style.position = "absolute";
6367
div.style.bottom = "0px";
6468
div.style.right = "0px";
@@ -100,7 +104,9 @@ class TypePanel {
100104
buttonLoadState.onclick = () => this.loadState();
101105
buttonSaveState.textContent = 'Save state';
102106
buttonSaveState.onclick = () => this.saveState();
103-
div.append(inputEnable, spanErrors, span, select, buttonHide, buttonLoadState, buttonSaveState, warnedTable);
107+
buttonClear.textContent = 'Clear';
108+
buttonClear.onclick = () => this.clear();
109+
div.append(inputEnable, spanErrors, span, select, buttonHide, buttonLoadState, buttonSaveState, buttonClear, warnedTable);
104110
div.style.maxHeight = '200px';
105111
div.style.overflow = 'scroll';
106112
const finalFunc = () => document.body.append(div);
@@ -113,6 +119,14 @@ class TypePanel {
113119
}
114120
this.loadState();
115121
}
122+
clear() {
123+
const {warned} = options;
124+
for (const key in warned) {
125+
const warning = warned[key];
126+
warning.tr.remove();
127+
delete warned[key];
128+
}
129+
}
116130
get state() {
117131
/** @type {object[]} */
118132
const fullState = [];

0 commit comments

Comments
 (0)