From 485a5bd3fb27a698e9d3d1c439b1c266c27da3fe Mon Sep 17 00:00:00 2001 From: Olga Larina Date: Fri, 20 Aug 2021 11:43:34 +0300 Subject: [PATCH] eslint fix errors --- package.json | 2 +- src/entries/angular.ts | 5 ++-- src/expressions/expressionParser.ts | 4 +++ src/knockout/koquestion.ts | 1 + src/localizablestring.ts | 6 ++--- src/question_matrixdropdownbase.ts | 40 ++++++++++++++-------------- src/question_matrixdynamic.ts | 40 ++++++++++++++-------------- src/react/reactquestion_dropdown.tsx | 1 - src/survey.ts | 2 +- 9 files changed, 52 insertions(+), 49 deletions(-) diff --git a/package.json b/package.json index 948bf7783b..e1974625da 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "build_prod": "npm run build_dev && concurrently \"npm run build_knockout_prod\" \"npm run build_react_prod\" \"npm run build_angular_prod\" \"npm run build_jquery_prod\" \"npm run build_vue_prod\" \"npm run build_core_prod\"", "doc_gen": "node doc_generator/lib_docgenerator.js src/entries/chunks/model.ts", "doc_update": "chmod +x ./docupdate_npm.sh && ./docupdate_npm.sh", - "lint": "eslint ./src --quiet", + "lint": "eslint ./src", "watch_knockout_dev": "webpack --config ./build-scripts/survey-knockout/webpack.config.js --env.buildType dev --watch", "watch_react_dev": "webpack --config ./build-scripts/survey-react/webpack.config.js --env.buildType dev --watch", "watch_angular_dev": "webpack --config ./build-scripts/survey-angular/webpack.config.js --env.buildType dev --watch", diff --git a/src/entries/angular.ts b/src/entries/angular.ts index a17501813b..fcbb8b521d 100644 --- a/src/entries/angular.ts +++ b/src/entries/angular.ts @@ -33,9 +33,8 @@ export class ReactSurveyModel extends Survey { css: any = null ) { super(jsonObj, renderedElement, css); - console.warn( - "ReactSurveyModel is depricated in this context. Use Survey.Model instead." - ); + // eslint-disable-next-line no-console + console.warn("ReactSurveyModel is depricated in this context. Use Survey.Model instead."); } } diff --git a/src/expressions/expressionParser.ts b/src/expressions/expressionParser.ts index fe4dad92c7..0868a49a17 100644 --- a/src/expressions/expressionParser.ts +++ b/src/expressions/expressionParser.ts @@ -69,7 +69,9 @@ export class SyntaxError extends Error { .replace(/\t/g, "\\t") .replace(/\n/g, "\\n") .replace(/\r/g, "\\r") + // eslint-disable-next-line no-control-regex .replace(/[\x00-\x0F]/g, (ch) => "\\x0" + hex(ch)) + // eslint-disable-next-line no-control-regex .replace(/[\x10-\x1F\x7F-\x9F]/g, (ch) => "\\x" + hex(ch)); } @@ -83,7 +85,9 @@ export class SyntaxError extends Error { .replace(/\t/g, "\\t") .replace(/\n/g, "\\n") .replace(/\r/g, "\\r") + // eslint-disable-next-line no-control-regex .replace(/[\x00-\x0F]/g, (ch) => "\\x0" + hex(ch)) + // eslint-disable-next-line no-control-regex .replace(/[\x10-\x1F\x7F-\x9F]/g, (ch) => "\\x" + hex(ch)); } diff --git a/src/knockout/koquestion.ts b/src/knockout/koquestion.ts index 7621561c1a..e37c54c947 100644 --- a/src/knockout/koquestion.ts +++ b/src/knockout/koquestion.ts @@ -142,6 +142,7 @@ export class QuestionImplementor extends ImplementorBase { try { this.question.customWidget.willUnmount(this.question, el); } catch { + // eslint-disable-next-line no-console console.warn("Custom widget will unmount failed"); } } diff --git a/src/localizablestring.ts b/src/localizablestring.ts index c213b00ff0..720f84d8e5 100644 --- a/src/localizablestring.ts +++ b/src/localizablestring.ts @@ -61,6 +61,9 @@ export class LocalizableString implements ILocalizableString { public get text(): string { return this.pureText; } + public set text(value: string) { + this.setLocaleText(this.locale, value); + } public get calculatedText(): string { this.renderedText = this.calculatedTextValue !== undefined @@ -114,9 +117,6 @@ export class LocalizableString implements ILocalizableString { public get renderedHtml() { return this.textOrHtml; } - public set text(value: string) { - this.setLocaleText(this.locale, value); - } public getLocaleText(loc: string): string { if (!loc) loc = settings.defaultLocaleName; var res = this.getValue(loc); diff --git a/src/question_matrixdropdownbase.ts b/src/question_matrixdropdownbase.ts index 020ea8650d..4fbd19ea82 100644 --- a/src/question_matrixdropdownbase.ts +++ b/src/question_matrixdropdownbase.ts @@ -876,6 +876,26 @@ implements ISurveyData, ISurveyImpl, ILocalizableOwner { } return result; } + public set value(value: any) { + this.isSettingValue = true; + this.subscribeToChanges(value); + var questions = this.questions; + for (var i = 0; i < questions.length; i++) { + var question = questions[i]; + var val = this.getCellValue(value, question.getValueName()); + var oldComment = question.comment; + var comment = !!value + ? value[question.getValueName() + settings.commentPrefix] + : ""; + if (comment == undefined) comment = ""; + question.updateValueFromSurvey(val); + if (!!comment || Helpers.isTwoValueEquals(oldComment, question.comment)) { + question.updateCommentFromSurvey(comment); + } + question.onSurveyValueChanged(val); + } + this.isSettingValue = false; + } public get locText(): LocalizableString { return null; } @@ -973,26 +993,6 @@ implements ISurveyData, ISurveyImpl, ILocalizableOwner { questions[i].clearValue(); } } - public set value(value: any) { - this.isSettingValue = true; - this.subscribeToChanges(value); - var questions = this.questions; - for (var i = 0; i < questions.length; i++) { - var question = questions[i]; - var val = this.getCellValue(value, question.getValueName()); - var oldComment = question.comment; - var comment = !!value - ? value[question.getValueName() + settings.commentPrefix] - : ""; - if (comment == undefined) comment = ""; - question.updateValueFromSurvey(val); - if (!!comment || Helpers.isTwoValueEquals(oldComment, question.comment)) { - question.updateCommentFromSurvey(comment); - } - question.onSurveyValueChanged(val); - } - this.isSettingValue = false; - } public onAnyValueChanged(name: string) { var questions = this.questions; for (var i = 0; i < questions.length; i++) { diff --git a/src/question_matrixdynamic.ts b/src/question_matrixdynamic.ts index 40b058242a..04c4bd3232 100644 --- a/src/question_matrixdynamic.ts +++ b/src/question_matrixdynamic.ts @@ -210,26 +210,6 @@ export class QuestionMatrixDynamicModel extends QuestionMatrixDropdownModelBase public get rowCount(): number { return this.rowCountValue; } - /** - * Set this property to true, to allow rows drag and drop. - */ - public get allowRowsDragAndDrop(): boolean { - return this.getPropertyValue("allowRowsDragAndDrop"); - } - public set allowRowsDragAndDrop(val: boolean) { - this.setPropertyValue("allowRowsDragAndDrop", val); - } - - protected createRenderedTable(): QuestionMatrixDropdownRenderedTable { - return new QuestionMatrixDynamicRenderedTable(this); - } - - private get rowCountValue(): number { - return this.getPropertyValue("rowCount", 2); - } - private set rowCountValue(val: number) { - this.setPropertyValue("rowCount", val); - } public set rowCount(val: number) { if (val < 0 || val > settings.matrixMaximumRowCount) return; this.setRowCountValueFromData = false; @@ -264,6 +244,26 @@ export class QuestionMatrixDynamicModel extends QuestionMatrixDropdownModelBase } return res; } + /** + * Set this property to true, to allow rows drag and drop. + */ + public get allowRowsDragAndDrop(): boolean { + return this.getPropertyValue("allowRowsDragAndDrop"); + } + public set allowRowsDragAndDrop(val: boolean) { + this.setPropertyValue("allowRowsDragAndDrop", val); + } + + protected createRenderedTable(): QuestionMatrixDropdownRenderedTable { + return new QuestionMatrixDynamicRenderedTable(this); + } + + private get rowCountValue(): number { + return this.getPropertyValue("rowCount", 2); + } + private set rowCountValue(val: number) { + this.setPropertyValue("rowCount", val); + } /** * The minimum row count. A user could not delete a row if the rowCount equals to minRowCount * @see rowCount diff --git a/src/react/reactquestion_dropdown.tsx b/src/react/reactquestion_dropdown.tsx index 90f5e8cfd5..ff7b957e41 100644 --- a/src/react/reactquestion_dropdown.tsx +++ b/src/react/reactquestion_dropdown.tsx @@ -36,7 +36,6 @@ export class SurveyQuestionDropdown extends SurveyQuestionUncontrolledElement {isOtherSelected ? this.question.otherText diff --git a/src/survey.ts b/src/survey.ts index 6215320916..58d28e9fa3 100644 --- a/src/survey.ts +++ b/src/survey.ts @@ -2305,10 +2305,10 @@ export class SurveyModel extends Base this.notifyElementsOnAnyValueOrVariableChanged(""); this.runConditions(); } + private onEditingObjPropertyChanged: (sender: Base, options: any) => void; public get editingObj(): Base { return this.editingObjValue; } - private onEditingObjPropertyChanged: (sender: Base, options: any) => void; public set editingObj(val: Base) { if (this.editingObj == val) return; if (!!this.editingObj) {