From 7b01ad0d6369134e16a69eccf0084d7079e6da10 Mon Sep 17 00:00:00 2001 From: Quentin Ruhier <99256289+QRuhier@users.noreply.github.com> Date: Mon, 2 Dec 2024 09:13:10 +0100 Subject: [PATCH] chore: improve husky prettier config (#878) * chore: improve husky, prettier, eslint config * chore: update tests & format scripts * chore: fix eslint config to handle classes correctly * chore: format all with new prettier rules * chore: update lint config * fix: props & test * chore: remove unused deps & update test script --- .editorconfig | 12 - .eslintignore | 3 - .eslintrc.yaml | 84 - .github/ISSUE_TEMPLATE/bug_report.md | 1 - .github/ISSUE_TEMPLATE/feature_request.md | 1 - .husky/pre-commit | 1 + .husky/pre-push | 1 - .prettierignore | 1 + .prettierrc | 8 + e2e/create-question.js | 4 +- e2e/simpleTest.js | 4 +- e2e/update-questionnaire.js | 2 +- eslint.config.js | 51 + index.html | 2 +- jison/generated-parsers/xpath-parser.js | 2391 ++++++++++++++--- jison/index.js | 5 +- package.json | 47 +- public/silent-sso.html | 14 +- scripts/generate-entrypoint.js | 6 +- src/actions/actionComponent.jsx | 12 +- src/actions/actionComponent.spec.jsx | 1 + src/actions/app-state.jsx | 50 +- src/actions/app-state.spec.jsx | 1 + src/actions/component-insert.jsx | 33 +- src/actions/component-insert.spec.jsx | 7 +- src/actions/component-move.jsx | 23 +- src/actions/component-move.spec.jsx | 1 + src/actions/component-remove.jsx | 25 +- src/actions/component-remove.spec.jsx | 5 +- src/actions/component-update.jsx | 5 +- src/actions/component-update.spec.jsx | 1 + src/actions/component.jsx | 46 +- src/actions/component.spec.jsx | 1 + src/actions/errors.jsx | 14 +- src/actions/external-questionnaire.jsx | 4 +- src/actions/general.jsx | 2 +- src/actions/metadata.jsx | 70 +- src/actions/metadata.spec.jsx | 1 + src/actions/questionnaire-list.jsx | 10 +- src/actions/questionnaire.jsx | 106 +- src/actions/search.jsx | 14 +- src/auth/hoc/hoc.jsx | 5 +- src/constants/dictionary.jsx | 2 +- .../components/control-with-suggestions.jsx | 31 +- .../input-with-suggestions-utils.jsx | 2 +- .../input-with-suggestions-utils.spec.jsx | 1 + .../components/input-with-suggestions.jsx | 7 +- .../input-with-suggestions.spec.jsx | 4 +- .../components/rich-editor.jsx | 5 +- .../rich-textarea-with-suggestions.jsx | 28 +- .../components/simple-editor.jsx | 5 +- .../components/textarea-with-suggestions.jsx | 7 +- .../textarea-with-suggestions.spec.jsx | 4 +- .../components/utils.spec.jsx | 1 + .../components/vtl-editor.jsx | 9 +- .../control-with-suggestions-container.jsx | 5 +- src/forms/controls/generic-option.jsx | 1 + src/forms/controls/generic-option.spec.jsx | 1 + .../input-autocomplete-utils.jsx | 4 +- .../input-autocomplete-utils.spec.jsx | 2 +- .../input-autocomplete/input-autocomplete.jsx | 73 +- .../input-autocomplete.spec.jsx | 4 +- src/forms/controls/input.jsx | 10 +- src/forms/controls/input.spec.jsx | 4 +- src/forms/controls/list-checkboxes.jsx | 10 +- src/forms/controls/list-checkboxes.spec.jsx | 4 +- src/forms/controls/list-radios.jsx | 6 +- .../decorators/rich-textarea-condition.jsx | 1 + .../decorators/rich-textarea-decorators.jsx | 3 +- .../decorators/rich-textarea-link.jsx | 1 + .../rich-textarea/lib/markdown-vtl-parser.jsx | 27 +- .../lib/state-from-markdown-vtl.jsx | 3 +- .../lib/state-to-markdown-vtl.jsx | 2 +- .../utils/rich-textarea-utils.jsx | 4 +- src/forms/controls/select.jsx | 8 +- src/forms/controls/select.spec.jsx | 6 +- src/forms/controls/textarea.jsx | 5 +- src/forms/controls/textarea.spec.jsx | 6 +- src/forms/controls/tree-select.jsx | 17 +- src/forms/normalize-inputs.spec.jsx | 1 + src/forms/validation-rules.jsx | 18 +- src/forms/validation-rules.spec.jsx | 1 + src/hoc/with-current-form-variables.jsx | 23 +- src/hoc/with-error-validation.jsx | 3 +- src/hoc/with-xpath-validation.jsx | 6 +- src/index.jsx | 5 +- src/layout/app/components/app.jsx | 7 +- src/layout/app/containers/app-container.jsx | 3 +- .../components/component-edit.jsx | 16 +- .../containers/component-edit-container.jsx | 6 +- .../components/component-new.jsx | 18 +- .../containers/component-new-container.jsx | 7 +- src/layout/confirm-dialog/confirm-dialog.jsx | 12 +- .../connected-widget/select-metadata.jsx | 9 +- .../components/duplicate-variables.jsx | 10 +- .../duplicate-variables-container.jsx | 3 +- .../utils/duplicate-variables-utils.jsx | 17 +- .../errors-integrity/errors-integrity.jsx | 10 +- .../components/generic-input.jsx | 13 +- .../containers/generic-input-container.jsx | 13 +- src/layout/header/header.jsx | 5 +- src/layout/header/header.spec.jsx | 4 +- src/layout/loader/component.jsx | 1 + src/layout/page-home/components/page-home.jsx | 10 +- .../containers/page-home-container.jsx | 1 + .../components/page-questionnaire.jsx | 13 +- .../components/page-questionnaire.spec.jsx | 7 +- .../page-questionnaire-container.jsx | 27 +- .../components/page-search-questionnaire.jsx | 19 +- .../page-search-questionnaire-container.jsx | 2 +- .../components/questionnaire-composition.jsx | 5 +- .../components/questionnaire-edit.jsx | 11 +- .../questionnaire-edit-container.jsx | 2 +- .../components/questionnaire-errors.jsx | 11 +- .../questionnaire-errors-container.jsx | 7 +- .../components/drop-zone/drop-zone.jsx | 4 +- .../components/drop-zone/drop-zone.spec.jsx | 2 + .../components/questionnaire-component.jsx | 33 +- .../questionnaire-list-components.jsx | 21 +- ...uestionnaire-list-components-container.jsx | 5 +- .../components/questionnaire-list-item.jsx | 10 +- .../components/questionnaire-list.jsx | 37 +- .../components/questionnaire-list.spec.jsx | 6 +- .../questionnaire-list-container.jsx | 7 +- .../components/questionnaire-merge.jsx | 3 +- .../components/arbo-simplifield.jsx | 14 +- .../components/arbo-simplifield.spec.jsx | 4 +- .../questionnaire-nav/components/nav-loop.jsx | 8 +- .../components/questionnaire-nav.jsx | 8 +- .../components/questionnaire-nav.spec.jsx | 8 +- .../questionnaire-nav-container.jsx | 9 +- .../components/questionnaire-new.jsx | 8 +- .../questionnaire-new-container.jsx | 2 +- .../questionnaire-tcm-composition.jsx | 5 +- .../user/components/user-connection.jsx | 2 +- .../formToState/codes-lists/codes-list.jsx | 8 +- .../calculated-variable.jsx | 6 +- .../calculated-variable.spec.jsx | 7 +- .../component-new-edit/collected-variable.jsx | 8 +- .../component-new-edit/component.jsx | 9 +- .../component-new-edit/control.jsx | 4 +- .../component-new-edit/control.spec.jsx | 7 +- .../component-new-edit/declaration.jsx | 4 +- .../component-new-edit/declaration.spec.jsx | 7 +- .../component-new-edit/external-variable.jsx | 6 +- .../external-variable.spec.jsx | 7 +- .../component-new-edit/redirection.jsx | 4 +- .../component-new-edit/redirection.spec.jsx | 7 +- .../response-format-multiple.jsx | 4 +- .../response-format-pairing.jsx | 4 +- .../response-format-simple.jsx | 6 +- .../response-format-single.jsx | 4 +- .../response-format-table.jsx | 24 +- .../component-new-edit/response-format.jsx | 19 +- src/model/remote-to-stores.jsx | 20 +- src/model/remote-to-stores.spec.jsx | 1 + .../transformations/calculated-variable.jsx | 4 +- .../calculated-variable.spec.jsx | 4 +- src/model/transformations/codes-list.jsx | 14 +- src/model/transformations/codes-list.spec.jsx | 1 + .../transformations/collected-variable.jsx | 40 +- .../collected-variable.spec.jsx | 4 +- src/model/transformations/component.jsx | 144 +- src/model/transformations/component.spec.jsx | 1 + src/model/transformations/control.jsx | 2 +- src/model/transformations/control.spec.jsx | 1 + src/model/transformations/declaration.jsx | 2 +- .../transformations/declaration.spec.jsx | 3 +- src/model/transformations/dimension.jsx | 4 +- src/model/transformations/dimension.spec.jsx | 1 + .../transformations/external-variable.jsx | 6 +- .../external-variable.spec.jsx | 1 + src/model/transformations/loop.jsx | 6 +- src/model/transformations/loop.spec.jsx | 1 + src/model/transformations/questionnaire.jsx | 51 +- .../transformations/questionnaire.spec.jsx | 6 +- .../transformations/redirection-filters.jsx | 10 +- src/model/transformations/redirection.jsx | 2 +- .../transformations/redirection.spec.jsx | 1 + .../response-format-multiple.jsx | 13 +- .../response-format-multiple.spec.jsx | 1 + .../response-format-pairing.jsx | 5 +- .../response-format-simple.jsx | 2 +- .../response-format-simple.spec.jsx | 1 + .../response-format-single.jsx | 7 +- .../response-format-single.spec.jsx | 1 + .../transformations/response-format-table.jsx | 38 +- .../response-format-table.spec.jsx | 1 + src/model/transformations/response-format.jsx | 7 +- .../transformations/response-format.spec.jsx | 7 +- src/model/transformations/response.jsx | 2 +- src/model/transformations/response.spec.jsx | 1 + src/model/transformations/responses.jsx | 12 +- src/model/transformations/responses.spec.jsx | 1 + .../active-calculated-variables-by-id.jsx | 2 +- ...active-calculated-variables-by-id.spec.jsx | 3 +- .../app-state/active-code-lists-by-id.jsx | 2 +- .../active-code-lists-by-id.spec.jsx | 3 +- .../app-state/active-components-by-id.jsx | 16 +- .../active-components-by-id.spec.jsx | 21 +- .../active-external-variables-by-id.jsx | 2 +- .../active-external-variables-by-id.spec.jsx | 5 +- src/reducers/app-state/app-state.jsx | 42 +- src/reducers/app-state/app-state.spec.jsx | 12 +- .../collected-variable-by-question.jsx | 4 +- .../collected-variable-by-question.spec.jsx | 39 +- .../app-state/errors-by-question-tab.jsx | 6 +- .../invalid-items-by-active-question.jsx | 5 +- ...invalid-items-by-active-questions.spec.jsx | 7 +- .../calculated-variable-by-questionnaire.jsx | 2 +- ...culated-variable-by-questionnaire.spec.jsx | 5 +- src/reducers/code-list-by-questionnaire.jsx | 2 +- .../code-list-by-questionnaire.spec.jsx | 5 +- .../collected-variable-by-questionnaire.jsx | 2 +- ...llected-variable-by-questionnaire.spec.jsx | 5 +- src/reducers/component-by-questionnaire.jsx | 4 +- .../component-by-questionnaire.spec.jsx | 3 +- src/reducers/dictionary.spec.jsx | 1 + src/reducers/errors/errors-integrity.jsx | 2 +- src/reducers/errors/errors-integrity.spec.jsx | 3 +- .../errors/errors-subform-validation.jsx | 5 +- src/reducers/errors/errors-validation.jsx | 5 +- src/reducers/errors/errors-visualization.jsx | 3 +- .../errors/errors-visualization.spec.jsx | 12 +- src/reducers/errors/errors.jsx | 2 +- .../external-variable-by-questionnaire.jsx | 2 +- ...xternal-variable-by-questionnaire.spec.jsx | 5 +- src/reducers/index.jsx | 8 +- src/reducers/questionnaire-by-id.jsx | 8 +- src/reducers/questionnaire-by-id.spec.jsx | 1 + src/reducers/questionnaire-list-by-id.jsx | 2 +- .../questionnaire-list-by-id.spec.jsx | 1 + src/reducers/search-result-by-id.jsx | 2 +- src/reducers/search-result-by-id.spec.jsx | 5 +- src/router.jsx | 2 +- src/setupTests.ts | 2 +- src/store/configure-store.jsx | 7 +- .../__mocks__/codes-lists-utils.jsx | 6 +- src/utils/codes-lists/codes-lists-utils.jsx | 10 +- .../codes-lists/codes-lists-utils.spec.jsx | 1 + .../component/component-dragndrop-utils.jsx | 4 +- .../component-dragndrop-utils.spec.jsx | 1 + .../component/component-dragndrop.spec.jsx | 1 + src/utils/component/component-utils.jsx | 6 +- src/utils/component/component-utils.spec.jsx | 1 + src/utils/component/generic-input-utils.jsx | 4 +- .../component/generic-input-utils.spec.jsx | 1 + src/utils/dictionary/dictionary.spec.jsx | 3 +- src/utils/env.jsx | 2 +- .../integrity/checker-component-targets.jsx | 6 +- .../integrity/checker-declaration-mode.jsx | 10 +- .../checker-declaration-mode.spec.jsx | 1 + .../integrity/checker-existing-target.jsx | 4 +- .../checker-existing-target.spec.jsx | 1 + .../checker-questionnaire-length.jsx | 6 +- ...checker-unique-collected-variable-name.jsx | 10 +- .../checker-unique-component-name.jsx | 14 +- .../checker-unique-component-name.spec.jsx | 1 + src/utils/integrity/checkers.jsx | 14 +- src/utils/integrity/utils.jsx | 2 +- src/utils/integrity/utils.spec.jsx | 1 + src/utils/logger/logger.jsx | 4 - src/utils/logger/logger.spec.jsx | 1 + src/utils/model/__mocks__/questionnaires.jsx | 4 +- src/utils/model/redirections-utils.jsx | 12 +- src/utils/model/redirections-utils.spec.jsx | 6 +- src/utils/oidc/build-configuration.jsx | 2 +- src/utils/oidc/index.jsx | 1 + src/utils/oidc/useAuth.jsx | 3 +- src/utils/reducer/actions-handler.spec.jsx | 1 + src/utils/remote-api.jsx | 38 +- src/utils/test/test-utils.jsx | 7 +- src/utils/utils.jsx | 10 +- src/utils/utils.spec.jsx | 1 + src/utils/validation/validate.jsx | 21 +- src/utils/validation/validation-rules.jsx | 115 +- .../validation/validation-utils.spec.jsx | 1 + .../variables/collected-variables-utils.jsx | 30 +- .../collected-variables-utils.spec.jsx | 9 +- src/utils/variables/variables-utils.jsx | 16 +- src/utils/variables/variables-utils.spec.jsx | 4 +- src/utils/widget-utils.jsx | 12 +- src/utils/widget-utils.spec.jsx | 1 + .../components/associated-fields.jsx | 12 +- .../associated-fields-container.jsx | 7 +- .../components/codes-lists-actions.jsx | 9 +- .../components/codes-lists-codes.jsx | 37 +- .../components/codes-lists-codes.spec.jsx | 4 +- .../components/codes-lists-input-code.jsx | 20 +- .../codes-lists/components/codes-lists.jsx | 31 +- .../components/codes-lists.spec.jsx | 7 +- .../components/suggester-lists.jsx | 6 +- .../codes-lists/components/upload-csv.jsx | 10 +- .../codes-lists-codes-container.jsx | 2 +- .../containers/codes-lists-container.jsx | 10 +- .../codes-lists-input-code-container.jsx | 5 +- src/widgets/codes-lists/utils/actions.jsx | 6 +- src/widgets/codes-lists/utils/movement.jsx | 16 +- .../codes-lists/utils/movement.spec.jsx | 1 + src/widgets/codes-lists/utils/utils.jsx | 18 +- src/widgets/codes-lists/utils/validation.jsx | 2 +- .../components/component-new-edit.jsx | 15 +- .../components/controls.jsx | 30 +- .../components/declarations.jsx | 34 +- .../components/filter-loop-members.jsx | 22 +- .../components/filter-new-edit.jsx | 2 +- .../components/loop-new-edit.jsx | 2 +- .../components/question-new-edit.jsx | 6 +- .../components/redirections.jsx | 21 +- .../multiple/multiple-measure-codeslist.jsx | 9 +- .../multiple/multiple-measure.jsx | 9 +- .../multiple/multiple-primary.jsx | 5 +- .../multiple/response-format-multiple.jsx | 5 +- .../response-format/response-format.jsx | 9 +- .../simple/response-format-simple.jsx | 7 +- .../response-format/simple/simple-date.jsx | 10 +- .../response-format/simple/simple-duree.jsx | 10 +- .../response-format/simple/simple-numeric.jsx | 8 +- .../response-format/simple/simple-text.jsx | 5 +- .../simple/simple-text.spec.jsx | 3 +- .../single/response-format-single.jsx | 31 +- .../response-format/table/input-measure.jsx | 7 +- .../table/response-format-table.jsx | 13 +- .../table/table-list-measures.jsx | 9 +- .../response-format/table/table-measure.jsx | 5 +- .../table/table-primary-codeslist.jsx | 5 +- .../table/table-primary-list-dynamic.jsx | 8 +- .../table/table-primary-list-fixed.jsx | 8 +- .../table/table-primary-list.jsx | 3 +- .../response-format/table/table-primary.jsx | 13 +- .../table/table-secondary-optional.jsx | 1 + .../response-format/table/table-secondary.jsx | 7 +- .../components/sequence-new-edit.jsx | 4 +- .../variables/calculated-variables.jsx | 25 +- .../variables/collected-variables.jsx | 28 +- .../variables/external-variables.jsx | 28 +- .../components/variables/utils-loops.jsx | 10 +- .../component-new-edit-container.jsx | 6 +- .../containers/component-new-edit-form.jsx | 3 +- .../collected-variables-container.jsx | 9 +- .../utils/component-new-edit-utils.jsx | 2 +- .../utils/component-new-edit-utils.spec.jsx | 1 + .../component-with-validation.jsx | 2 +- src/widgets/dropdown/component.jsx | 4 +- .../errors-panel/components/errors-panel.jsx | 3 +- .../containers/errors-panel-container.jsx | 4 +- .../external-questionnaire-dropdown.jsx | 11 +- ...ernal-questionnaire-dropdown-container.jsx | 2 +- .../goto-input/components/goto-input.jsx | 8 +- .../containers/goto-input-container.jsx | 4 +- .../goto-input/utils/goto-input-utils.jsx | 4 +- src/widgets/highlighter/highlighter.jsx | 3 +- src/widgets/highlighter/highlighter.spec.jsx | 3 +- .../components/input-filter-with-criteria.jsx | 9 +- .../input-filter-with-criteria.spec.jsx | 7 +- .../components/list-with-input-panel-item.jsx | 3 +- .../list-with-input-panel-item.spec.jsx | 5 +- .../components/list-with-input-panel-list.jsx | 10 +- .../list-with-input-panel-list.spec.jsx | 9 +- .../components/list-with-input-panel.jsx | 42 +- .../components/list-with-input-panel.spec.jsx | 11 +- .../list-with-input-panel-container.jsx | 11 +- .../utils/test-utils.jsx | 2 +- .../components/optional-view.jsx | 3 +- .../containers/optional-view-container.jsx | 5 +- .../components/questionnaire-new-edit.jsx | 12 +- .../questionnaire-new-edit-form.jsx | 3 +- .../model/questionnaire.jsx | 2 +- .../search-codes-lists/search-codes-lists.jsx | 12 +- .../search-codes-lists.spec.jsx | 44 +- .../components/search-results.jsx | 24 +- .../components/search-results.spec.jsx | 6 +- .../containers/search-results-container.jsx | 5 +- .../components/selector-view-view.jsx | 1 + .../components/selector-view-view.spec.jsx | 1 + .../components/selector-view.jsx | 13 +- .../components/selector-view.spec.jsx | 3 +- .../containers/selector-view-container.jsx | 5 +- .../statistical-context-criteria.jsx | 12 +- .../statistical-context-criteria.spec.jsx | 16 +- .../statistical-context-criteria.jsx | 1 + src/widgets/tabs/components/tab.jsx | 1 + src/widgets/tabs/components/tab.spec.jsx | 1 + src/widgets/tabs/components/tabs.jsx | 5 +- .../tabs/containers/tabs-container.jsx | 10 +- .../components/visualize-dropdown.jsx | 14 +- .../visualize-dropdown-container.jsx | 3 +- .../visualize-dropdown.spec.jsx | 4 +- yarn.lock | 1386 +++++----- 389 files changed, 4664 insertions(+), 2894 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintignore delete mode 100644 .eslintrc.yaml create mode 100644 .husky/pre-commit delete mode 100644 .husky/pre-push create mode 100644 .prettierignore create mode 100644 .prettierrc create mode 100644 eslint.config.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 4a7ea3036..000000000 --- a/.editorconfig +++ /dev/null @@ -1,12 +0,0 @@ -root = true - -[*] -indent_style = space -indent_size = 2 -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -[*.md] -trim_trailing_whitespace = false diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 452836b4a..000000000 --- a/.eslintignore +++ /dev/null @@ -1,3 +0,0 @@ -src/js/utils/draft-js/get-entity-at-cursor.js -src/forms/controls/rich-textarea/lib/markdown-vtl-parser.js -src/forms/controls/control-with-suggestions/components/vtl-suggestions.js \ No newline at end of file diff --git a/.eslintrc.yaml b/.eslintrc.yaml deleted file mode 100644 index c4d51b373..000000000 --- a/.eslintrc.yaml +++ /dev/null @@ -1,84 +0,0 @@ -extends: - - eslint-config-airbnb - - prettier - -plugins: - - prettier - - react-hooks - - react - -settings: - ecmascript: 2020 - -parser: babel-eslint - -parserOptions: - ecmaVersion: 2020 - sourceType: module - ecmaFeatures: - jsx: true - -env: - browser: true - -rules: - indent: 0 - default-param-last: 0 - no-restricted-exports: 0 - prefer-regex-literals: 0 - func-style: 0 - func-names: 0 - comma-dangle: 0 - no-param-reassign: 0 - linebreak-style: 0 - object-shorthand: 0 - no-underscore-dangle: 0 - arrow-body-style: 0 - import/no-extraneous-dependencies: 0 - import/no-unresolved: 0 - import/extensions: 0 - import/first: 0 - react/jsx-filename-extension: 0 - react/prefer-stateless-function: 0 - react/no-children-prop: 0 - react/function-component-definition: 0 - react/forbid-prop-types: 0 - react/react-in-jsx-scope: 0 - react/no-unescaped-entities: 0 - prettier/prettier: - - 'error' - - trailingComma: 'all' - singleQuote: true - endOfLine: 'auto' - react/forbid-prop-types: 0 - import/prefer-default-export: 0 - react/jsx-props-no-spreading: 0 - import/order: 0 - camelcase: 0 - no-plusplus: 0 - no-useless-escape: warn - no-restricted-globals: 0 - import/named: 0 - no-use-before-define: 0 - prefer-destructuring: off - react/destructuring-assignment: 0 - no-shadow: 0 - no-else-return: 0 - react-hooks/rules-of-hooks: 'error' - react-hooks/exhaustive-deps: 'warn' - react/prop-types: 0 - handlers: 0 - react/button-has-type: 0 - react/no-array-index-key: 0 - no-nested-ternary: 0 - react/static-property-placement: 0 - no-dupe-keys: 0 - react/default-props-match-prop-types: 0 - react/require-default-props: 0 - jsx-a11y/control-has-associated-label: 0 - jsx-a11y/click-events-have-key-events: 0 - react/no-find-dom-node: 0 - react/no-danger: 0 - jsx-a11y/anchor-is-valid: 0 - no-console: 1 - no-debugger: 1 diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 56f71188a..4ffdf80e3 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -4,7 +4,6 @@ about: Create a report to help us improve title: '' labels: bug assignees: '' - --- ## Describe the bug diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 0bcea4ccc..1acd9cf24 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -4,7 +4,6 @@ about: Suggest an idea for this project title: '' labels: enhancement assignees: '' - --- ## Feature Description diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100644 index 000000000..1a1f1f060 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1 @@ +yarn lint-staged \ No newline at end of file diff --git a/.husky/pre-push b/.husky/pre-push deleted file mode 100644 index 759567277..000000000 --- a/.husky/pre-push +++ /dev/null @@ -1 +0,0 @@ -yarn lint && yarn format:check \ No newline at end of file diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 000000000..96c0ecc38 --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +docs/ \ No newline at end of file diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 000000000..7da727a9c --- /dev/null +++ b/.prettierrc @@ -0,0 +1,8 @@ +{ + "semi": true, + "singleQuote": true, + "plugins": ["@trivago/prettier-plugin-sort-imports"], + "importOrder": ["^react$", "", "^@/(.*)$", "^[./]"], + "importOrderSeparation": true, + "importOrderSortSpecifiers": true +} diff --git a/e2e/create-question.js b/e2e/create-question.js index bc1b4daec..169786e02 100644 --- a/e2e/create-question.js +++ b/e2e/create-question.js @@ -2,7 +2,7 @@ const genericInput = require('./po/generic-input'); const editQuestion = require('./po/edit-question'); module.exports = { - 'Should close the model if Cancel is clicked': browser => { + 'Should close the model if Cancel is clicked': (browser) => { // PLEASE MAKE YOUR TESTS DATA AGNOSTICS // browser // .url(`${browser.globals.launch_url}/#/questionnaire/fr.insee-POPO-QPO-DOC`) @@ -13,7 +13,7 @@ module.exports = { // .waitForElementNotPresent(editQuestion.Tabs) // .end() }, - 'Should show declaration panel': browser => { + 'Should show declaration panel': (browser) => { // PLEASE MAKE YOUR TESTS DATA AGNOSTICS // browser // .url(`${browser.globals.launch_url}/#/questionnaire/fr.insee-POPO-QPO-DOC`) diff --git a/e2e/simpleTest.js b/e2e/simpleTest.js index da7ff3292..11a06b4f9 100644 --- a/e2e/simpleTest.js +++ b/e2e/simpleTest.js @@ -1,12 +1,12 @@ module.exports = { - 'Application assert Title': browser => { + 'Application assert Title': (browser) => { browser .url(browser.globals.launch_url) .waitForElementVisible('body') .assert.title('Pogues') .end(); }, - 'Home page fetch wip questionnaires': browser => { + 'Home page fetch wip questionnaires': (browser) => { browser .url(browser.globals.launch_url) .waitForElementVisible('.home-questionnaires') diff --git a/e2e/update-questionnaire.js b/e2e/update-questionnaire.js index fedada1aa..59dab112d 100644 --- a/e2e/update-questionnaire.js +++ b/e2e/update-questionnaire.js @@ -1,7 +1,7 @@ const questionnairePage = require('./po/questionnaire'); module.exports = { - 'Should update the title of a questionnaire': browser => { + 'Should update the title of a questionnaire': (browser) => { // PLEASE MAKE YOUR TESTS DATA AGNOSTICS // browser // .url(`${browser.globals.launch_url}/#/questionnaire/fr.insee-POPO-QPO-DOC`) diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 000000000..c54e7ac00 --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,51 @@ +import babelParser from '@babel/eslint-parser'; +import js from '@eslint/js'; +import react from 'eslint-plugin-react'; +import reactHooks from 'eslint-plugin-react-hooks'; +import reactRefresh from 'eslint-plugin-react-refresh'; +import globals from 'globals'; + +export default [ + js.configs.recommended, + { + ignores: [ + 'dist', + 'src/js/utils/draft-js/get-entity-at-cursor.js', + 'src/forms/controls/rich-textarea/lib/markdown-vtl-parser.js', + 'src/forms/controls/control-with-suggestions/components/vtl-suggestions.js', + 'e2e', + 'jison', + 'vite.config.js', + 'docs', + ], + }, + { + files: ['**/*.{js,jsx}'], + languageOptions: { + ecmaVersion: 2020, + globals: globals.browser, + sourceType: 'module', + parser: babelParser, + parserOptions: { + ecmaFeatures: { + jsx: true, + }, + requireConfigFile: false, + babelOptions: { + plugins: ['@babel/plugin-syntax-jsx'], // Add plugin for JSX support + }, + }, + }, + plugins: { + react, + 'react-hooks': reactHooks, + 'react-refresh': reactRefresh, + }, + rules: { + ...reactHooks.configs.recommended.rules, + 'react/jsx-uses-react': 'error', + 'react/jsx-uses-vars': 'error', + 'react-refresh/only-export-components': ['off'], + }, + }, +]; diff --git a/index.html b/index.html index 4f801da8e..f06b2b008 100644 --- a/index.html +++ b/index.html @@ -1,4 +1,4 @@ - + diff --git a/jison/generated-parsers/xpath-parser.js b/jison/generated-parsers/xpath-parser.js index ab96aef73..37ab07190 100644 --- a/jison/generated-parsers/xpath-parser.js +++ b/jison/generated-parsers/xpath-parser.js @@ -71,188 +71,1595 @@ recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error) } */ -var xpathParser = (function(){ -var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[1,8],$V1=[1,10],$V2=[1,12],$V3=[1,15],$V4=[1,19],$V5=[1,20],$V6=[1,14],$V7=[1,23],$V8=[1,24],$V9=[1,34],$Va=[1,28],$Vb=[1,29],$Vc=[1,30],$Vd=[1,31],$Ve=[1,32],$Vf=[1,33],$Vg=[1,16],$Vh=[1,17],$Vi=[1,36],$Vj=[1,37],$Vk=[1,38],$Vl=[1,39],$Vm=[1,40],$Vn=[1,41],$Vo=[1,42],$Vp=[1,43],$Vq=[1,44],$Vr=[1,45],$Vs=[1,46],$Vt=[1,47],$Vu=[1,48],$Vv=[1,49],$Vw=[5,12,16,17,18,19,20,21,22,23,24,25,26,27,28,29,32,41],$Vx=[1,53],$Vy=[5,12,16,17,18,19,20,21,22,23,24,25,26,27,28,29,32,34,36,40,41],$Vz=[2,58],$VA=[1,61],$VB=[1,62],$VC=[1,63],$VD=[1,65],$VE=[5,12,16,17,18,19,20,21,22,23,24,25,26,27,28,29,32,34,36,41],$VF=[30,51,52,53,54,55,56],$VG=[5,12,16,17,18,19,20,21,22,23,24,25,26,27,28,32,41],$VH=[5,12,16,17,18,19,32,41],$VI=[5,12,16,17,18,19,20,21,22,23,32,41],$VJ=[5,12,16,17,18,19,20,21,22,23,24,25,32,41],$VK=[12,32],$VL=[5,12,16,17,18,19,20,21,22,23,24,25,26,27,28,29,32,34,41]; -var parser = {trace: function trace() { }, -yy: {}, -symbols_: {"error":2,"xpath_expr":3,"expr":4,"EOF":5,"base_expr":6,"op_expr":7,"path_expr":8,"filter_expr":9,"hashtag_expr":10,"LPAREN":11,"RPAREN":12,"func_call":13,"VAR":14,"literal":15,"OR":16,"AND":17,"EQ":18,"NEQ":19,"LT":20,"LTE":21,"GT":22,"GTE":23,"PLUS":24,"MINUS":25,"MULT":26,"DIV":27,"MOD":28,"UNION":29,"QNAME":30,"arg_list":31,"COMMA":32,"loc_path":33,"SLASH":34,"rel_loc_path":35,"DBL_SLASH":36,"predicate":37,"HASH":38,"hashtag_path":39,"LBRACK":40,"RBRACK":41,"step":42,"step_unabbr":43,"DOT":44,"DBL_DOT":45,"step_body":46,"node_test":47,"axis_specifier":48,"DBL_COLON":49,"AT":50,"WILDCARD":51,"NSWILDCARD":52,"NODETYPE_NODE":53,"NODETYPE_TEXT":54,"NODETYPE_COMMENT":55,"NODETYPE_PROCINSTR":56,"STR":57,"NUM":58,"$accept":0,"$end":1}, -terminals_: {2:"error",5:"EOF",11:"LPAREN",12:"RPAREN",14:"VAR",16:"OR",17:"AND",18:"EQ",19:"NEQ",20:"LT",21:"LTE",22:"GT",23:"GTE",24:"PLUS",25:"MINUS",26:"MULT",27:"DIV",28:"MOD",29:"UNION",30:"QNAME",32:"COMMA",34:"SLASH",36:"DBL_SLASH",38:"HASH",40:"LBRACK",41:"RBRACK",44:"DOT",45:"DBL_DOT",49:"DBL_COLON",50:"AT",51:"WILDCARD",52:"NSWILDCARD",53:"NODETYPE_NODE",54:"NODETYPE_TEXT",55:"NODETYPE_COMMENT",56:"NODETYPE_PROCINSTR",57:"STR",58:"NUM"}, -productions_: [0,[3,2],[4,1],[4,1],[4,1],[4,1],[4,1],[6,3],[6,1],[6,1],[6,1],[7,3],[7,3],[7,3],[7,3],[7,3],[7,3],[7,3],[7,3],[7,3],[7,3],[7,3],[7,3],[7,3],[7,2],[7,3],[13,4],[13,3],[31,3],[31,1],[8,1],[8,3],[8,3],[8,3],[8,3],[9,2],[9,2],[10,4],[10,2],[39,1],[39,3],[37,3],[33,1],[33,2],[33,2],[33,1],[35,1],[35,3],[35,3],[42,1],[42,1],[42,1],[43,2],[43,1],[46,1],[46,2],[48,2],[48,1],[47,1],[47,1],[47,1],[47,3],[47,3],[47,3],[47,3],[47,4],[15,1],[15,1]], -performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) { -/* this == yyval */ - -var $0 = $$.length - 1; -switch (yystate) { -case 1: - return $$[$0-1]; -break; -case 2: case 3: case 4: case 5: case 6: case 9: case 42: case 45: case 50: case 51: case 54: case 57: case 58: case 59: case 60: case 66: case 67: - this.$ = $$[$0]; -break; -case 7: case 11: case 12: case 13: case 14: case 15: case 16: case 17: case 18: case 19: case 20: case 21: case 22: case 23: case 25: case 27: case 28: case 31: case 32: case 33: case 34: case 47: case 48: case 61: case 62: case 63: case 64: - this.$ = $$[$0-2]; -break; -case 24: case 35: case 36: case 38: case 43: case 44: case 52: case 55: case 56: - this.$ = $$[$0-1]; -break; -case 26: case 37: case 65: - this.$ = $$[$0-3]; -break; -case 29: - this.$ = [$$[$0]]; -break; -case 39: -this.$ = [$$[$0]]; -break; -case 40: -var path = $$[$0-2]; path.push($$[$0]); this.$ = path; -break; -case 41: - this.$ = $$[$0-1]; -break; -case 46: - this.$ = [$$[$0]]; -break; -case 49: case 53: - this.$ = $$[$0]; -break; -} -}, -table: [{3:1,4:2,6:3,7:4,8:5,9:6,10:7,11:$V0,13:9,14:$V1,15:11,25:$V2,30:$V3,33:13,34:$V4,35:18,36:$V5,38:$V6,42:21,43:22,44:$V7,45:$V8,46:25,47:26,48:27,50:$V9,51:$Va,52:$Vb,53:$Vc,54:$Vd,55:$Ve,56:$Vf,57:$Vg,58:$Vh},{1:[3]},{5:[1,35],16:$Vi,17:$Vj,18:$Vk,19:$Vl,20:$Vm,21:$Vn,22:$Vo,23:$Vp,24:$Vq,25:$Vr,26:$Vs,27:$Vt,28:$Vu,29:$Vv},o($Vw,[2,2],{37:52,34:[1,50],36:[1,51],40:$Vx}),o($Vw,[2,3]),o($Vw,[2,4]),o($Vw,[2,5],{37:56,34:[1,54],36:[1,55],40:$Vx}),o($Vw,[2,6]),{4:57,6:3,7:4,8:5,9:6,10:7,11:$V0,13:9,14:$V1,15:11,25:$V2,30:$V3,33:13,34:$V4,35:18,36:$V5,38:$V6,42:21,43:22,44:$V7,45:$V8,46:25,47:26,48:27,50:$V9,51:$Va,52:$Vb,53:$Vc,54:$Vd,55:$Ve,56:$Vf,57:$Vg,58:$Vh},o($Vy,[2,8]),o($Vy,[2,9]),o($Vy,[2,10]),{4:58,6:3,7:4,8:5,9:6,10:7,11:$V0,13:9,14:$V1,15:11,25:$V2,30:$V3,33:13,34:$V4,35:18,36:$V5,38:$V6,42:21,43:22,44:$V7,45:$V8,46:25,47:26,48:27,50:$V9,51:$Va,52:$Vb,53:$Vc,54:$Vd,55:$Ve,56:$Vf,57:$Vg,58:$Vh},o($Vw,[2,30]),{30:[1,59]},o($Vy,$Vz,{11:[1,60],49:$VA}),o($Vy,[2,66]),o($Vy,[2,67]),o($Vw,[2,42],{34:$VB,36:$VC}),o($Vw,[2,45],{42:21,43:22,46:25,47:26,48:27,35:64,30:$VD,44:$V7,45:$V8,50:$V9,51:$Va,52:$Vb,53:$Vc,54:$Vd,55:$Ve,56:$Vf}),{30:$VD,35:66,42:21,43:22,44:$V7,45:$V8,46:25,47:26,48:27,50:$V9,51:$Va,52:$Vb,53:$Vc,54:$Vd,55:$Ve,56:$Vf},o($VE,[2,46]),o($VE,[2,49],{37:67,40:$Vx}),o($VE,[2,50]),o($VE,[2,51]),o($Vy,[2,53]),o($Vy,[2,54]),{30:[1,69],47:68,51:$Va,52:$Vb,53:$Vc,54:$Vd,55:$Ve,56:$Vf},o($Vy,[2,59]),o($Vy,[2,60]),{11:[1,70]},{11:[1,71]},{11:[1,72]},{11:[1,73]},o($VF,[2,57]),{1:[2,1]},{4:74,6:3,7:4,8:5,9:6,10:7,11:$V0,13:9,14:$V1,15:11,25:$V2,30:$V3,33:13,34:$V4,35:18,36:$V5,38:$V6,42:21,43:22,44:$V7,45:$V8,46:25,47:26,48:27,50:$V9,51:$Va,52:$Vb,53:$Vc,54:$Vd,55:$Ve,56:$Vf,57:$Vg,58:$Vh},{4:75,6:3,7:4,8:5,9:6,10:7,11:$V0,13:9,14:$V1,15:11,25:$V2,30:$V3,33:13,34:$V4,35:18,36:$V5,38:$V6,42:21,43:22,44:$V7,45:$V8,46:25,47:26,48:27,50:$V9,51:$Va,52:$Vb,53:$Vc,54:$Vd,55:$Ve,56:$Vf,57:$Vg,58:$Vh},{4:76,6:3,7:4,8:5,9:6,10:7,11:$V0,13:9,14:$V1,15:11,25:$V2,30:$V3,33:13,34:$V4,35:18,36:$V5,38:$V6,42:21,43:22,44:$V7,45:$V8,46:25,47:26,48:27,50:$V9,51:$Va,52:$Vb,53:$Vc,54:$Vd,55:$Ve,56:$Vf,57:$Vg,58:$Vh},{4:77,6:3,7:4,8:5,9:6,10:7,11:$V0,13:9,14:$V1,15:11,25:$V2,30:$V3,33:13,34:$V4,35:18,36:$V5,38:$V6,42:21,43:22,44:$V7,45:$V8,46:25,47:26,48:27,50:$V9,51:$Va,52:$Vb,53:$Vc,54:$Vd,55:$Ve,56:$Vf,57:$Vg,58:$Vh},{4:78,6:3,7:4,8:5,9:6,10:7,11:$V0,13:9,14:$V1,15:11,25:$V2,30:$V3,33:13,34:$V4,35:18,36:$V5,38:$V6,42:21,43:22,44:$V7,45:$V8,46:25,47:26,48:27,50:$V9,51:$Va,52:$Vb,53:$Vc,54:$Vd,55:$Ve,56:$Vf,57:$Vg,58:$Vh},{4:79,6:3,7:4,8:5,9:6,10:7,11:$V0,13:9,14:$V1,15:11,25:$V2,30:$V3,33:13,34:$V4,35:18,36:$V5,38:$V6,42:21,43:22,44:$V7,45:$V8,46:25,47:26,48:27,50:$V9,51:$Va,52:$Vb,53:$Vc,54:$Vd,55:$Ve,56:$Vf,57:$Vg,58:$Vh},{4:80,6:3,7:4,8:5,9:6,10:7,11:$V0,13:9,14:$V1,15:11,25:$V2,30:$V3,33:13,34:$V4,35:18,36:$V5,38:$V6,42:21,43:22,44:$V7,45:$V8,46:25,47:26,48:27,50:$V9,51:$Va,52:$Vb,53:$Vc,54:$Vd,55:$Ve,56:$Vf,57:$Vg,58:$Vh},{4:81,6:3,7:4,8:5,9:6,10:7,11:$V0,13:9,14:$V1,15:11,25:$V2,30:$V3,33:13,34:$V4,35:18,36:$V5,38:$V6,42:21,43:22,44:$V7,45:$V8,46:25,47:26,48:27,50:$V9,51:$Va,52:$Vb,53:$Vc,54:$Vd,55:$Ve,56:$Vf,57:$Vg,58:$Vh},{4:82,6:3,7:4,8:5,9:6,10:7,11:$V0,13:9,14:$V1,15:11,25:$V2,30:$V3,33:13,34:$V4,35:18,36:$V5,38:$V6,42:21,43:22,44:$V7,45:$V8,46:25,47:26,48:27,50:$V9,51:$Va,52:$Vb,53:$Vc,54:$Vd,55:$Ve,56:$Vf,57:$Vg,58:$Vh},{4:83,6:3,7:4,8:5,9:6,10:7,11:$V0,13:9,14:$V1,15:11,25:$V2,30:$V3,33:13,34:$V4,35:18,36:$V5,38:$V6,42:21,43:22,44:$V7,45:$V8,46:25,47:26,48:27,50:$V9,51:$Va,52:$Vb,53:$Vc,54:$Vd,55:$Ve,56:$Vf,57:$Vg,58:$Vh},{4:84,6:3,7:4,8:5,9:6,10:7,11:$V0,13:9,14:$V1,15:11,25:$V2,30:$V3,33:13,34:$V4,35:18,36:$V5,38:$V6,42:21,43:22,44:$V7,45:$V8,46:25,47:26,48:27,50:$V9,51:$Va,52:$Vb,53:$Vc,54:$Vd,55:$Ve,56:$Vf,57:$Vg,58:$Vh},{4:85,6:3,7:4,8:5,9:6,10:7,11:$V0,13:9,14:$V1,15:11,25:$V2,30:$V3,33:13,34:$V4,35:18,36:$V5,38:$V6,42:21,43:22,44:$V7,45:$V8,46:25,47:26,48:27,50:$V9,51:$Va,52:$Vb,53:$Vc,54:$Vd,55:$Ve,56:$Vf,57:$Vg,58:$Vh},{4:86,6:3,7:4,8:5,9:6,10:7,11:$V0,13:9,14:$V1,15:11,25:$V2,30:$V3,33:13,34:$V4,35:18,36:$V5,38:$V6,42:21,43:22,44:$V7,45:$V8,46:25,47:26,48:27,50:$V9,51:$Va,52:$Vb,53:$Vc,54:$Vd,55:$Ve,56:$Vf,57:$Vg,58:$Vh},{4:87,6:3,7:4,8:5,9:6,10:7,11:$V0,13:9,14:$V1,15:11,25:$V2,30:$V3,33:13,34:$V4,35:18,36:$V5,38:$V6,42:21,43:22,44:$V7,45:$V8,46:25,47:26,48:27,50:$V9,51:$Va,52:$Vb,53:$Vc,54:$Vd,55:$Ve,56:$Vf,57:$Vg,58:$Vh},{30:$VD,35:88,42:21,43:22,44:$V7,45:$V8,46:25,47:26,48:27,50:$V9,51:$Va,52:$Vb,53:$Vc,54:$Vd,55:$Ve,56:$Vf},{30:$VD,35:89,42:21,43:22,44:$V7,45:$V8,46:25,47:26,48:27,50:$V9,51:$Va,52:$Vb,53:$Vc,54:$Vd,55:$Ve,56:$Vf},o($Vy,[2,35]),{4:90,6:3,7:4,8:5,9:6,10:7,11:$V0,13:9,14:$V1,15:11,25:$V2,30:$V3,33:13,34:$V4,35:18,36:$V5,38:$V6,42:21,43:22,44:$V7,45:$V8,46:25,47:26,48:27,50:$V9,51:$Va,52:$Vb,53:$Vc,54:$Vd,55:$Ve,56:$Vf,57:$Vg,58:$Vh},{30:$VD,35:91,42:21,43:22,44:$V7,45:$V8,46:25,47:26,48:27,50:$V9,51:$Va,52:$Vb,53:$Vc,54:$Vd,55:$Ve,56:$Vf},{30:$VD,35:92,42:21,43:22,44:$V7,45:$V8,46:25,47:26,48:27,50:$V9,51:$Va,52:$Vb,53:$Vc,54:$Vd,55:$Ve,56:$Vf},o($Vy,[2,36]),{12:[1,93],16:$Vi,17:$Vj,18:$Vk,19:$Vl,20:$Vm,21:$Vn,22:$Vo,23:$Vp,24:$Vq,25:$Vr,26:$Vs,27:$Vt,28:$Vu,29:$Vv},o($VG,[2,24],{29:$Vv}),o($Vw,[2,38],{34:[1,94]}),{4:97,6:3,7:4,8:5,9:6,10:7,11:$V0,12:[1,96],13:9,14:$V1,15:11,25:$V2,30:$V3,31:95,33:13,34:$V4,35:18,36:$V5,38:$V6,42:21,43:22,44:$V7,45:$V8,46:25,47:26,48:27,50:$V9,51:$Va,52:$Vb,53:$Vc,54:$Vd,55:$Ve,56:$Vf,57:$Vg,58:$Vh},o($VF,[2,56]),{30:$VD,42:98,43:22,44:$V7,45:$V8,46:25,47:26,48:27,50:$V9,51:$Va,52:$Vb,53:$Vc,54:$Vd,55:$Ve,56:$Vf},{30:$VD,42:99,43:22,44:$V7,45:$V8,46:25,47:26,48:27,50:$V9,51:$Va,52:$Vb,53:$Vc,54:$Vd,55:$Ve,56:$Vf},o($Vw,[2,43],{34:$VB,36:$VC}),o($Vy,$Vz,{49:$VA}),o($Vw,[2,44],{34:$VB,36:$VC}),o($Vy,[2,52]),o($Vy,[2,55]),o($Vy,$Vz),{12:[1,100]},{12:[1,101]},{12:[1,102]},{12:[1,103],57:[1,104]},o([5,12,32,41],[2,11],{16:$Vi,17:$Vj,18:$Vk,19:$Vl,20:$Vm,21:$Vn,22:$Vo,23:$Vp,24:$Vq,25:$Vr,26:$Vs,27:$Vt,28:$Vu,29:$Vv}),o([5,12,16,32,41],[2,12],{17:$Vj,18:$Vk,19:$Vl,20:$Vm,21:$Vn,22:$Vo,23:$Vp,24:$Vq,25:$Vr,26:$Vs,27:$Vt,28:$Vu,29:$Vv}),o($VH,[2,13],{20:$Vm,21:$Vn,22:$Vo,23:$Vp,24:$Vq,25:$Vr,26:$Vs,27:$Vt,28:$Vu,29:$Vv}),o($VH,[2,14],{20:$Vm,21:$Vn,22:$Vo,23:$Vp,24:$Vq,25:$Vr,26:$Vs,27:$Vt,28:$Vu,29:$Vv}),o($VI,[2,15],{24:$Vq,25:$Vr,26:$Vs,27:$Vt,28:$Vu,29:$Vv}),o($VI,[2,16],{24:$Vq,25:$Vr,26:$Vs,27:$Vt,28:$Vu,29:$Vv}),o($VI,[2,17],{24:$Vq,25:$Vr,26:$Vs,27:$Vt,28:$Vu,29:$Vv}),o($VI,[2,18],{24:$Vq,25:$Vr,26:$Vs,27:$Vt,28:$Vu,29:$Vv}),o($VJ,[2,19],{26:$Vs,27:$Vt,28:$Vu,29:$Vv}),o($VJ,[2,20],{26:$Vs,27:$Vt,28:$Vu,29:$Vv}),o($VG,[2,21],{29:$Vv}),o($VG,[2,22],{29:$Vv}),o($VG,[2,23],{29:$Vv}),o($Vw,[2,25]),o($Vw,[2,33],{34:$VB,36:$VC}),o($Vw,[2,34],{34:$VB,36:$VC}),{16:$Vi,17:$Vj,18:$Vk,19:$Vl,20:$Vm,21:$Vn,22:$Vo,23:$Vp,24:$Vq,25:$Vr,26:$Vs,27:$Vt,28:$Vu,29:$Vv,41:[1,105]},o($Vw,[2,31],{34:$VB,36:$VC}),o($Vw,[2,32],{34:$VB,36:$VC}),o($Vy,[2,7]),{30:[1,107],39:106},{12:[1,108],32:[1,109]},o($Vy,[2,27]),o($VK,[2,29],{16:$Vi,17:$Vj,18:$Vk,19:$Vl,20:$Vm,21:$Vn,22:$Vo,23:$Vp,24:$Vq,25:$Vr,26:$Vs,27:$Vt,28:$Vu,29:$Vv}),o($VE,[2,47]),o($VE,[2,48]),o($Vy,[2,61]),o($Vy,[2,62]),o($Vy,[2,63]),o($Vy,[2,64]),{12:[1,110]},o($Vy,[2,41]),o($Vw,[2,37],{34:[1,111]}),o($VL,[2,39]),o($Vy,[2,26]),{4:112,6:3,7:4,8:5,9:6,10:7,11:$V0,13:9,14:$V1,15:11,25:$V2,30:$V3,33:13,34:$V4,35:18,36:$V5,38:$V6,42:21,43:22,44:$V7,45:$V8,46:25,47:26,48:27,50:$V9,51:$Va,52:$Vb,53:$Vc,54:$Vd,55:$Ve,56:$Vf,57:$Vg,58:$Vh},o($Vy,[2,65]),{30:[1,113]},o($VK,[2,28],{16:$Vi,17:$Vj,18:$Vk,19:$Vl,20:$Vm,21:$Vn,22:$Vo,23:$Vp,24:$Vq,25:$Vr,26:$Vs,27:$Vt,28:$Vu,29:$Vv}),o($VL,[2,40])], -defaultActions: {35:[2,1]}, -parseError: function parseError(str, hash) { - if (hash.recoverable) { +var xpathParser = (function () { + var o = function (k, v, o, l) { + for (o = o || {}, l = k.length; l--; o[k[l]] = v); + return o; + }, + $V0 = [1, 8], + $V1 = [1, 10], + $V2 = [1, 12], + $V3 = [1, 15], + $V4 = [1, 19], + $V5 = [1, 20], + $V6 = [1, 14], + $V7 = [1, 23], + $V8 = [1, 24], + $V9 = [1, 34], + $Va = [1, 28], + $Vb = [1, 29], + $Vc = [1, 30], + $Vd = [1, 31], + $Ve = [1, 32], + $Vf = [1, 33], + $Vg = [1, 16], + $Vh = [1, 17], + $Vi = [1, 36], + $Vj = [1, 37], + $Vk = [1, 38], + $Vl = [1, 39], + $Vm = [1, 40], + $Vn = [1, 41], + $Vo = [1, 42], + $Vp = [1, 43], + $Vq = [1, 44], + $Vr = [1, 45], + $Vs = [1, 46], + $Vt = [1, 47], + $Vu = [1, 48], + $Vv = [1, 49], + $Vw = [ + 5, 12, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 32, 41, + ], + $Vx = [1, 53], + $Vy = [ + 5, 12, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 32, 34, 36, + 40, 41, + ], + $Vz = [2, 58], + $VA = [1, 61], + $VB = [1, 62], + $VC = [1, 63], + $VD = [1, 65], + $VE = [ + 5, 12, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 32, 34, 36, + 41, + ], + $VF = [30, 51, 52, 53, 54, 55, 56], + $VG = [5, 12, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 32, 41], + $VH = [5, 12, 16, 17, 18, 19, 32, 41], + $VI = [5, 12, 16, 17, 18, 19, 20, 21, 22, 23, 32, 41], + $VJ = [5, 12, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 32, 41], + $VK = [12, 32], + $VL = [ + 5, 12, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 32, 34, 41, + ]; + var parser = { + trace: function trace() {}, + yy: {}, + symbols_: { + error: 2, + xpath_expr: 3, + expr: 4, + EOF: 5, + base_expr: 6, + op_expr: 7, + path_expr: 8, + filter_expr: 9, + hashtag_expr: 10, + LPAREN: 11, + RPAREN: 12, + func_call: 13, + VAR: 14, + literal: 15, + OR: 16, + AND: 17, + EQ: 18, + NEQ: 19, + LT: 20, + LTE: 21, + GT: 22, + GTE: 23, + PLUS: 24, + MINUS: 25, + MULT: 26, + DIV: 27, + MOD: 28, + UNION: 29, + QNAME: 30, + arg_list: 31, + COMMA: 32, + loc_path: 33, + SLASH: 34, + rel_loc_path: 35, + DBL_SLASH: 36, + predicate: 37, + HASH: 38, + hashtag_path: 39, + LBRACK: 40, + RBRACK: 41, + step: 42, + step_unabbr: 43, + DOT: 44, + DBL_DOT: 45, + step_body: 46, + node_test: 47, + axis_specifier: 48, + DBL_COLON: 49, + AT: 50, + WILDCARD: 51, + NSWILDCARD: 52, + NODETYPE_NODE: 53, + NODETYPE_TEXT: 54, + NODETYPE_COMMENT: 55, + NODETYPE_PROCINSTR: 56, + STR: 57, + NUM: 58, + $accept: 0, + $end: 1, + }, + terminals_: { + 2: 'error', + 5: 'EOF', + 11: 'LPAREN', + 12: 'RPAREN', + 14: 'VAR', + 16: 'OR', + 17: 'AND', + 18: 'EQ', + 19: 'NEQ', + 20: 'LT', + 21: 'LTE', + 22: 'GT', + 23: 'GTE', + 24: 'PLUS', + 25: 'MINUS', + 26: 'MULT', + 27: 'DIV', + 28: 'MOD', + 29: 'UNION', + 30: 'QNAME', + 32: 'COMMA', + 34: 'SLASH', + 36: 'DBL_SLASH', + 38: 'HASH', + 40: 'LBRACK', + 41: 'RBRACK', + 44: 'DOT', + 45: 'DBL_DOT', + 49: 'DBL_COLON', + 50: 'AT', + 51: 'WILDCARD', + 52: 'NSWILDCARD', + 53: 'NODETYPE_NODE', + 54: 'NODETYPE_TEXT', + 55: 'NODETYPE_COMMENT', + 56: 'NODETYPE_PROCINSTR', + 57: 'STR', + 58: 'NUM', + }, + productions_: [ + 0, + [3, 2], + [4, 1], + [4, 1], + [4, 1], + [4, 1], + [4, 1], + [6, 3], + [6, 1], + [6, 1], + [6, 1], + [7, 3], + [7, 3], + [7, 3], + [7, 3], + [7, 3], + [7, 3], + [7, 3], + [7, 3], + [7, 3], + [7, 3], + [7, 3], + [7, 3], + [7, 3], + [7, 2], + [7, 3], + [13, 4], + [13, 3], + [31, 3], + [31, 1], + [8, 1], + [8, 3], + [8, 3], + [8, 3], + [8, 3], + [9, 2], + [9, 2], + [10, 4], + [10, 2], + [39, 1], + [39, 3], + [37, 3], + [33, 1], + [33, 2], + [33, 2], + [33, 1], + [35, 1], + [35, 3], + [35, 3], + [42, 1], + [42, 1], + [42, 1], + [43, 2], + [43, 1], + [46, 1], + [46, 2], + [48, 2], + [48, 1], + [47, 1], + [47, 1], + [47, 1], + [47, 3], + [47, 3], + [47, 3], + [47, 3], + [47, 4], + [15, 1], + [15, 1], + ], + performAction: function anonymous( + yytext, + yyleng, + yylineno, + yy, + yystate /* action[1] */, + $$ /* vstack */, + _$ /* lstack */, + ) { + /* this == yyval */ + + var $0 = $$.length - 1; + switch (yystate) { + case 1: + return $$[$0 - 1]; + break; + case 2: + case 3: + case 4: + case 5: + case 6: + case 9: + case 42: + case 45: + case 50: + case 51: + case 54: + case 57: + case 58: + case 59: + case 60: + case 66: + case 67: + this.$ = $$[$0]; + break; + case 7: + case 11: + case 12: + case 13: + case 14: + case 15: + case 16: + case 17: + case 18: + case 19: + case 20: + case 21: + case 22: + case 23: + case 25: + case 27: + case 28: + case 31: + case 32: + case 33: + case 34: + case 47: + case 48: + case 61: + case 62: + case 63: + case 64: + this.$ = $$[$0 - 2]; + break; + case 24: + case 35: + case 36: + case 38: + case 43: + case 44: + case 52: + case 55: + case 56: + this.$ = $$[$0 - 1]; + break; + case 26: + case 37: + case 65: + this.$ = $$[$0 - 3]; + break; + case 29: + this.$ = [$$[$0]]; + break; + case 39: + this.$ = [$$[$0]]; + break; + case 40: + var path = $$[$0 - 2]; + path.push($$[$0]); + this.$ = path; + break; + case 41: + this.$ = $$[$0 - 1]; + break; + case 46: + this.$ = [$$[$0]]; + break; + case 49: + case 53: + this.$ = $$[$0]; + break; + } + }, + table: [ + { + 3: 1, + 4: 2, + 6: 3, + 7: 4, + 8: 5, + 9: 6, + 10: 7, + 11: $V0, + 13: 9, + 14: $V1, + 15: 11, + 25: $V2, + 30: $V3, + 33: 13, + 34: $V4, + 35: 18, + 36: $V5, + 38: $V6, + 42: 21, + 43: 22, + 44: $V7, + 45: $V8, + 46: 25, + 47: 26, + 48: 27, + 50: $V9, + 51: $Va, + 52: $Vb, + 53: $Vc, + 54: $Vd, + 55: $Ve, + 56: $Vf, + 57: $Vg, + 58: $Vh, + }, + { 1: [3] }, + { + 5: [1, 35], + 16: $Vi, + 17: $Vj, + 18: $Vk, + 19: $Vl, + 20: $Vm, + 21: $Vn, + 22: $Vo, + 23: $Vp, + 24: $Vq, + 25: $Vr, + 26: $Vs, + 27: $Vt, + 28: $Vu, + 29: $Vv, + }, + o($Vw, [2, 2], { 37: 52, 34: [1, 50], 36: [1, 51], 40: $Vx }), + o($Vw, [2, 3]), + o($Vw, [2, 4]), + o($Vw, [2, 5], { 37: 56, 34: [1, 54], 36: [1, 55], 40: $Vx }), + o($Vw, [2, 6]), + { + 4: 57, + 6: 3, + 7: 4, + 8: 5, + 9: 6, + 10: 7, + 11: $V0, + 13: 9, + 14: $V1, + 15: 11, + 25: $V2, + 30: $V3, + 33: 13, + 34: $V4, + 35: 18, + 36: $V5, + 38: $V6, + 42: 21, + 43: 22, + 44: $V7, + 45: $V8, + 46: 25, + 47: 26, + 48: 27, + 50: $V9, + 51: $Va, + 52: $Vb, + 53: $Vc, + 54: $Vd, + 55: $Ve, + 56: $Vf, + 57: $Vg, + 58: $Vh, + }, + o($Vy, [2, 8]), + o($Vy, [2, 9]), + o($Vy, [2, 10]), + { + 4: 58, + 6: 3, + 7: 4, + 8: 5, + 9: 6, + 10: 7, + 11: $V0, + 13: 9, + 14: $V1, + 15: 11, + 25: $V2, + 30: $V3, + 33: 13, + 34: $V4, + 35: 18, + 36: $V5, + 38: $V6, + 42: 21, + 43: 22, + 44: $V7, + 45: $V8, + 46: 25, + 47: 26, + 48: 27, + 50: $V9, + 51: $Va, + 52: $Vb, + 53: $Vc, + 54: $Vd, + 55: $Ve, + 56: $Vf, + 57: $Vg, + 58: $Vh, + }, + o($Vw, [2, 30]), + { 30: [1, 59] }, + o($Vy, $Vz, { 11: [1, 60], 49: $VA }), + o($Vy, [2, 66]), + o($Vy, [2, 67]), + o($Vw, [2, 42], { 34: $VB, 36: $VC }), + o($Vw, [2, 45], { + 42: 21, + 43: 22, + 46: 25, + 47: 26, + 48: 27, + 35: 64, + 30: $VD, + 44: $V7, + 45: $V8, + 50: $V9, + 51: $Va, + 52: $Vb, + 53: $Vc, + 54: $Vd, + 55: $Ve, + 56: $Vf, + }), + { + 30: $VD, + 35: 66, + 42: 21, + 43: 22, + 44: $V7, + 45: $V8, + 46: 25, + 47: 26, + 48: 27, + 50: $V9, + 51: $Va, + 52: $Vb, + 53: $Vc, + 54: $Vd, + 55: $Ve, + 56: $Vf, + }, + o($VE, [2, 46]), + o($VE, [2, 49], { 37: 67, 40: $Vx }), + o($VE, [2, 50]), + o($VE, [2, 51]), + o($Vy, [2, 53]), + o($Vy, [2, 54]), + { + 30: [1, 69], + 47: 68, + 51: $Va, + 52: $Vb, + 53: $Vc, + 54: $Vd, + 55: $Ve, + 56: $Vf, + }, + o($Vy, [2, 59]), + o($Vy, [2, 60]), + { 11: [1, 70] }, + { 11: [1, 71] }, + { 11: [1, 72] }, + { 11: [1, 73] }, + o($VF, [2, 57]), + { 1: [2, 1] }, + { + 4: 74, + 6: 3, + 7: 4, + 8: 5, + 9: 6, + 10: 7, + 11: $V0, + 13: 9, + 14: $V1, + 15: 11, + 25: $V2, + 30: $V3, + 33: 13, + 34: $V4, + 35: 18, + 36: $V5, + 38: $V6, + 42: 21, + 43: 22, + 44: $V7, + 45: $V8, + 46: 25, + 47: 26, + 48: 27, + 50: $V9, + 51: $Va, + 52: $Vb, + 53: $Vc, + 54: $Vd, + 55: $Ve, + 56: $Vf, + 57: $Vg, + 58: $Vh, + }, + { + 4: 75, + 6: 3, + 7: 4, + 8: 5, + 9: 6, + 10: 7, + 11: $V0, + 13: 9, + 14: $V1, + 15: 11, + 25: $V2, + 30: $V3, + 33: 13, + 34: $V4, + 35: 18, + 36: $V5, + 38: $V6, + 42: 21, + 43: 22, + 44: $V7, + 45: $V8, + 46: 25, + 47: 26, + 48: 27, + 50: $V9, + 51: $Va, + 52: $Vb, + 53: $Vc, + 54: $Vd, + 55: $Ve, + 56: $Vf, + 57: $Vg, + 58: $Vh, + }, + { + 4: 76, + 6: 3, + 7: 4, + 8: 5, + 9: 6, + 10: 7, + 11: $V0, + 13: 9, + 14: $V1, + 15: 11, + 25: $V2, + 30: $V3, + 33: 13, + 34: $V4, + 35: 18, + 36: $V5, + 38: $V6, + 42: 21, + 43: 22, + 44: $V7, + 45: $V8, + 46: 25, + 47: 26, + 48: 27, + 50: $V9, + 51: $Va, + 52: $Vb, + 53: $Vc, + 54: $Vd, + 55: $Ve, + 56: $Vf, + 57: $Vg, + 58: $Vh, + }, + { + 4: 77, + 6: 3, + 7: 4, + 8: 5, + 9: 6, + 10: 7, + 11: $V0, + 13: 9, + 14: $V1, + 15: 11, + 25: $V2, + 30: $V3, + 33: 13, + 34: $V4, + 35: 18, + 36: $V5, + 38: $V6, + 42: 21, + 43: 22, + 44: $V7, + 45: $V8, + 46: 25, + 47: 26, + 48: 27, + 50: $V9, + 51: $Va, + 52: $Vb, + 53: $Vc, + 54: $Vd, + 55: $Ve, + 56: $Vf, + 57: $Vg, + 58: $Vh, + }, + { + 4: 78, + 6: 3, + 7: 4, + 8: 5, + 9: 6, + 10: 7, + 11: $V0, + 13: 9, + 14: $V1, + 15: 11, + 25: $V2, + 30: $V3, + 33: 13, + 34: $V4, + 35: 18, + 36: $V5, + 38: $V6, + 42: 21, + 43: 22, + 44: $V7, + 45: $V8, + 46: 25, + 47: 26, + 48: 27, + 50: $V9, + 51: $Va, + 52: $Vb, + 53: $Vc, + 54: $Vd, + 55: $Ve, + 56: $Vf, + 57: $Vg, + 58: $Vh, + }, + { + 4: 79, + 6: 3, + 7: 4, + 8: 5, + 9: 6, + 10: 7, + 11: $V0, + 13: 9, + 14: $V1, + 15: 11, + 25: $V2, + 30: $V3, + 33: 13, + 34: $V4, + 35: 18, + 36: $V5, + 38: $V6, + 42: 21, + 43: 22, + 44: $V7, + 45: $V8, + 46: 25, + 47: 26, + 48: 27, + 50: $V9, + 51: $Va, + 52: $Vb, + 53: $Vc, + 54: $Vd, + 55: $Ve, + 56: $Vf, + 57: $Vg, + 58: $Vh, + }, + { + 4: 80, + 6: 3, + 7: 4, + 8: 5, + 9: 6, + 10: 7, + 11: $V0, + 13: 9, + 14: $V1, + 15: 11, + 25: $V2, + 30: $V3, + 33: 13, + 34: $V4, + 35: 18, + 36: $V5, + 38: $V6, + 42: 21, + 43: 22, + 44: $V7, + 45: $V8, + 46: 25, + 47: 26, + 48: 27, + 50: $V9, + 51: $Va, + 52: $Vb, + 53: $Vc, + 54: $Vd, + 55: $Ve, + 56: $Vf, + 57: $Vg, + 58: $Vh, + }, + { + 4: 81, + 6: 3, + 7: 4, + 8: 5, + 9: 6, + 10: 7, + 11: $V0, + 13: 9, + 14: $V1, + 15: 11, + 25: $V2, + 30: $V3, + 33: 13, + 34: $V4, + 35: 18, + 36: $V5, + 38: $V6, + 42: 21, + 43: 22, + 44: $V7, + 45: $V8, + 46: 25, + 47: 26, + 48: 27, + 50: $V9, + 51: $Va, + 52: $Vb, + 53: $Vc, + 54: $Vd, + 55: $Ve, + 56: $Vf, + 57: $Vg, + 58: $Vh, + }, + { + 4: 82, + 6: 3, + 7: 4, + 8: 5, + 9: 6, + 10: 7, + 11: $V0, + 13: 9, + 14: $V1, + 15: 11, + 25: $V2, + 30: $V3, + 33: 13, + 34: $V4, + 35: 18, + 36: $V5, + 38: $V6, + 42: 21, + 43: 22, + 44: $V7, + 45: $V8, + 46: 25, + 47: 26, + 48: 27, + 50: $V9, + 51: $Va, + 52: $Vb, + 53: $Vc, + 54: $Vd, + 55: $Ve, + 56: $Vf, + 57: $Vg, + 58: $Vh, + }, + { + 4: 83, + 6: 3, + 7: 4, + 8: 5, + 9: 6, + 10: 7, + 11: $V0, + 13: 9, + 14: $V1, + 15: 11, + 25: $V2, + 30: $V3, + 33: 13, + 34: $V4, + 35: 18, + 36: $V5, + 38: $V6, + 42: 21, + 43: 22, + 44: $V7, + 45: $V8, + 46: 25, + 47: 26, + 48: 27, + 50: $V9, + 51: $Va, + 52: $Vb, + 53: $Vc, + 54: $Vd, + 55: $Ve, + 56: $Vf, + 57: $Vg, + 58: $Vh, + }, + { + 4: 84, + 6: 3, + 7: 4, + 8: 5, + 9: 6, + 10: 7, + 11: $V0, + 13: 9, + 14: $V1, + 15: 11, + 25: $V2, + 30: $V3, + 33: 13, + 34: $V4, + 35: 18, + 36: $V5, + 38: $V6, + 42: 21, + 43: 22, + 44: $V7, + 45: $V8, + 46: 25, + 47: 26, + 48: 27, + 50: $V9, + 51: $Va, + 52: $Vb, + 53: $Vc, + 54: $Vd, + 55: $Ve, + 56: $Vf, + 57: $Vg, + 58: $Vh, + }, + { + 4: 85, + 6: 3, + 7: 4, + 8: 5, + 9: 6, + 10: 7, + 11: $V0, + 13: 9, + 14: $V1, + 15: 11, + 25: $V2, + 30: $V3, + 33: 13, + 34: $V4, + 35: 18, + 36: $V5, + 38: $V6, + 42: 21, + 43: 22, + 44: $V7, + 45: $V8, + 46: 25, + 47: 26, + 48: 27, + 50: $V9, + 51: $Va, + 52: $Vb, + 53: $Vc, + 54: $Vd, + 55: $Ve, + 56: $Vf, + 57: $Vg, + 58: $Vh, + }, + { + 4: 86, + 6: 3, + 7: 4, + 8: 5, + 9: 6, + 10: 7, + 11: $V0, + 13: 9, + 14: $V1, + 15: 11, + 25: $V2, + 30: $V3, + 33: 13, + 34: $V4, + 35: 18, + 36: $V5, + 38: $V6, + 42: 21, + 43: 22, + 44: $V7, + 45: $V8, + 46: 25, + 47: 26, + 48: 27, + 50: $V9, + 51: $Va, + 52: $Vb, + 53: $Vc, + 54: $Vd, + 55: $Ve, + 56: $Vf, + 57: $Vg, + 58: $Vh, + }, + { + 4: 87, + 6: 3, + 7: 4, + 8: 5, + 9: 6, + 10: 7, + 11: $V0, + 13: 9, + 14: $V1, + 15: 11, + 25: $V2, + 30: $V3, + 33: 13, + 34: $V4, + 35: 18, + 36: $V5, + 38: $V6, + 42: 21, + 43: 22, + 44: $V7, + 45: $V8, + 46: 25, + 47: 26, + 48: 27, + 50: $V9, + 51: $Va, + 52: $Vb, + 53: $Vc, + 54: $Vd, + 55: $Ve, + 56: $Vf, + 57: $Vg, + 58: $Vh, + }, + { + 30: $VD, + 35: 88, + 42: 21, + 43: 22, + 44: $V7, + 45: $V8, + 46: 25, + 47: 26, + 48: 27, + 50: $V9, + 51: $Va, + 52: $Vb, + 53: $Vc, + 54: $Vd, + 55: $Ve, + 56: $Vf, + }, + { + 30: $VD, + 35: 89, + 42: 21, + 43: 22, + 44: $V7, + 45: $V8, + 46: 25, + 47: 26, + 48: 27, + 50: $V9, + 51: $Va, + 52: $Vb, + 53: $Vc, + 54: $Vd, + 55: $Ve, + 56: $Vf, + }, + o($Vy, [2, 35]), + { + 4: 90, + 6: 3, + 7: 4, + 8: 5, + 9: 6, + 10: 7, + 11: $V0, + 13: 9, + 14: $V1, + 15: 11, + 25: $V2, + 30: $V3, + 33: 13, + 34: $V4, + 35: 18, + 36: $V5, + 38: $V6, + 42: 21, + 43: 22, + 44: $V7, + 45: $V8, + 46: 25, + 47: 26, + 48: 27, + 50: $V9, + 51: $Va, + 52: $Vb, + 53: $Vc, + 54: $Vd, + 55: $Ve, + 56: $Vf, + 57: $Vg, + 58: $Vh, + }, + { + 30: $VD, + 35: 91, + 42: 21, + 43: 22, + 44: $V7, + 45: $V8, + 46: 25, + 47: 26, + 48: 27, + 50: $V9, + 51: $Va, + 52: $Vb, + 53: $Vc, + 54: $Vd, + 55: $Ve, + 56: $Vf, + }, + { + 30: $VD, + 35: 92, + 42: 21, + 43: 22, + 44: $V7, + 45: $V8, + 46: 25, + 47: 26, + 48: 27, + 50: $V9, + 51: $Va, + 52: $Vb, + 53: $Vc, + 54: $Vd, + 55: $Ve, + 56: $Vf, + }, + o($Vy, [2, 36]), + { + 12: [1, 93], + 16: $Vi, + 17: $Vj, + 18: $Vk, + 19: $Vl, + 20: $Vm, + 21: $Vn, + 22: $Vo, + 23: $Vp, + 24: $Vq, + 25: $Vr, + 26: $Vs, + 27: $Vt, + 28: $Vu, + 29: $Vv, + }, + o($VG, [2, 24], { 29: $Vv }), + o($Vw, [2, 38], { 34: [1, 94] }), + { + 4: 97, + 6: 3, + 7: 4, + 8: 5, + 9: 6, + 10: 7, + 11: $V0, + 12: [1, 96], + 13: 9, + 14: $V1, + 15: 11, + 25: $V2, + 30: $V3, + 31: 95, + 33: 13, + 34: $V4, + 35: 18, + 36: $V5, + 38: $V6, + 42: 21, + 43: 22, + 44: $V7, + 45: $V8, + 46: 25, + 47: 26, + 48: 27, + 50: $V9, + 51: $Va, + 52: $Vb, + 53: $Vc, + 54: $Vd, + 55: $Ve, + 56: $Vf, + 57: $Vg, + 58: $Vh, + }, + o($VF, [2, 56]), + { + 30: $VD, + 42: 98, + 43: 22, + 44: $V7, + 45: $V8, + 46: 25, + 47: 26, + 48: 27, + 50: $V9, + 51: $Va, + 52: $Vb, + 53: $Vc, + 54: $Vd, + 55: $Ve, + 56: $Vf, + }, + { + 30: $VD, + 42: 99, + 43: 22, + 44: $V7, + 45: $V8, + 46: 25, + 47: 26, + 48: 27, + 50: $V9, + 51: $Va, + 52: $Vb, + 53: $Vc, + 54: $Vd, + 55: $Ve, + 56: $Vf, + }, + o($Vw, [2, 43], { 34: $VB, 36: $VC }), + o($Vy, $Vz, { 49: $VA }), + o($Vw, [2, 44], { 34: $VB, 36: $VC }), + o($Vy, [2, 52]), + o($Vy, [2, 55]), + o($Vy, $Vz), + { 12: [1, 100] }, + { 12: [1, 101] }, + { 12: [1, 102] }, + { 12: [1, 103], 57: [1, 104] }, + o([5, 12, 32, 41], [2, 11], { + 16: $Vi, + 17: $Vj, + 18: $Vk, + 19: $Vl, + 20: $Vm, + 21: $Vn, + 22: $Vo, + 23: $Vp, + 24: $Vq, + 25: $Vr, + 26: $Vs, + 27: $Vt, + 28: $Vu, + 29: $Vv, + }), + o([5, 12, 16, 32, 41], [2, 12], { + 17: $Vj, + 18: $Vk, + 19: $Vl, + 20: $Vm, + 21: $Vn, + 22: $Vo, + 23: $Vp, + 24: $Vq, + 25: $Vr, + 26: $Vs, + 27: $Vt, + 28: $Vu, + 29: $Vv, + }), + o($VH, [2, 13], { + 20: $Vm, + 21: $Vn, + 22: $Vo, + 23: $Vp, + 24: $Vq, + 25: $Vr, + 26: $Vs, + 27: $Vt, + 28: $Vu, + 29: $Vv, + }), + o($VH, [2, 14], { + 20: $Vm, + 21: $Vn, + 22: $Vo, + 23: $Vp, + 24: $Vq, + 25: $Vr, + 26: $Vs, + 27: $Vt, + 28: $Vu, + 29: $Vv, + }), + o($VI, [2, 15], { 24: $Vq, 25: $Vr, 26: $Vs, 27: $Vt, 28: $Vu, 29: $Vv }), + o($VI, [2, 16], { 24: $Vq, 25: $Vr, 26: $Vs, 27: $Vt, 28: $Vu, 29: $Vv }), + o($VI, [2, 17], { 24: $Vq, 25: $Vr, 26: $Vs, 27: $Vt, 28: $Vu, 29: $Vv }), + o($VI, [2, 18], { 24: $Vq, 25: $Vr, 26: $Vs, 27: $Vt, 28: $Vu, 29: $Vv }), + o($VJ, [2, 19], { 26: $Vs, 27: $Vt, 28: $Vu, 29: $Vv }), + o($VJ, [2, 20], { 26: $Vs, 27: $Vt, 28: $Vu, 29: $Vv }), + o($VG, [2, 21], { 29: $Vv }), + o($VG, [2, 22], { 29: $Vv }), + o($VG, [2, 23], { 29: $Vv }), + o($Vw, [2, 25]), + o($Vw, [2, 33], { 34: $VB, 36: $VC }), + o($Vw, [2, 34], { 34: $VB, 36: $VC }), + { + 16: $Vi, + 17: $Vj, + 18: $Vk, + 19: $Vl, + 20: $Vm, + 21: $Vn, + 22: $Vo, + 23: $Vp, + 24: $Vq, + 25: $Vr, + 26: $Vs, + 27: $Vt, + 28: $Vu, + 29: $Vv, + 41: [1, 105], + }, + o($Vw, [2, 31], { 34: $VB, 36: $VC }), + o($Vw, [2, 32], { 34: $VB, 36: $VC }), + o($Vy, [2, 7]), + { 30: [1, 107], 39: 106 }, + { 12: [1, 108], 32: [1, 109] }, + o($Vy, [2, 27]), + o($VK, [2, 29], { + 16: $Vi, + 17: $Vj, + 18: $Vk, + 19: $Vl, + 20: $Vm, + 21: $Vn, + 22: $Vo, + 23: $Vp, + 24: $Vq, + 25: $Vr, + 26: $Vs, + 27: $Vt, + 28: $Vu, + 29: $Vv, + }), + o($VE, [2, 47]), + o($VE, [2, 48]), + o($Vy, [2, 61]), + o($Vy, [2, 62]), + o($Vy, [2, 63]), + o($Vy, [2, 64]), + { 12: [1, 110] }, + o($Vy, [2, 41]), + o($Vw, [2, 37], { 34: [1, 111] }), + o($VL, [2, 39]), + o($Vy, [2, 26]), + { + 4: 112, + 6: 3, + 7: 4, + 8: 5, + 9: 6, + 10: 7, + 11: $V0, + 13: 9, + 14: $V1, + 15: 11, + 25: $V2, + 30: $V3, + 33: 13, + 34: $V4, + 35: 18, + 36: $V5, + 38: $V6, + 42: 21, + 43: 22, + 44: $V7, + 45: $V8, + 46: 25, + 47: 26, + 48: 27, + 50: $V9, + 51: $Va, + 52: $Vb, + 53: $Vc, + 54: $Vd, + 55: $Ve, + 56: $Vf, + 57: $Vg, + 58: $Vh, + }, + o($Vy, [2, 65]), + { 30: [1, 113] }, + o($VK, [2, 28], { + 16: $Vi, + 17: $Vj, + 18: $Vk, + 19: $Vl, + 20: $Vm, + 21: $Vn, + 22: $Vo, + 23: $Vp, + 24: $Vq, + 25: $Vr, + 26: $Vs, + 27: $Vt, + 28: $Vu, + 29: $Vv, + }), + o($VL, [2, 40]), + ], + defaultActions: { 35: [2, 1] }, + parseError: function parseError(str, hash) { + if (hash.recoverable) { this.trace(str); - } else { + } else { var error = new Error(str); error.hash = hash; throw error; - } -}, -parse: function parse(input) { - var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1; - var args = lstack.slice.call(arguments, 1); - var lexer = Object.create(this.lexer); - var sharedState = { yy: {} }; - for (var k in this.yy) { + } + }, + parse: function parse(input) { + var self = this, + stack = [0], + tstack = [], + vstack = [null], + lstack = [], + table = this.table, + yytext = '', + yylineno = 0, + yyleng = 0, + recovering = 0, + TERROR = 2, + EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { if (Object.prototype.hasOwnProperty.call(this.yy, k)) { - sharedState.yy[k] = this.yy[k]; + sharedState.yy[k] = this.yy[k]; } - } - lexer.setInput(input, sharedState.yy); - sharedState.yy.lexer = lexer; - sharedState.yy.parser = this; - if (typeof lexer.yylloc == 'undefined') { + } + lexer.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer; + sharedState.yy.parser = this; + if (typeof lexer.yylloc == 'undefined') { lexer.yylloc = {}; - } - var yyloc = lexer.yylloc; - lstack.push(yyloc); - var ranges = lexer.options && lexer.options.ranges; - if (typeof sharedState.yy.parseError === 'function') { + } + var yyloc = lexer.yylloc; + lstack.push(yyloc); + var ranges = lexer.options && lexer.options.ranges; + if (typeof sharedState.yy.parseError === 'function') { this.parseError = sharedState.yy.parseError; - } else { + } else { this.parseError = Object.getPrototypeOf(this).parseError; - } - function popStack(n) { + } + function popStack(n) { stack.length = stack.length - 2 * n; vstack.length = vstack.length - n; lstack.length = lstack.length - n; - } - - var lex = function () { - var token; - token = lexer.lex() || EOF; - if (typeof token !== 'number') { - token = self.symbols_[token] || token; - } - return token; - }; - var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected; - while (true) { + } + + var lex = function () { + var token; + token = lexer.lex() || EOF; + if (typeof token !== 'number') { + token = self.symbols_[token] || token; + } + return token; + }; + var symbol, + preErrorSymbol, + state, + action, + a, + r, + yyval = {}, + p, + len, + newState, + expected; + while (true) { state = stack[stack.length - 1]; if (this.defaultActions[state]) { - action = this.defaultActions[state]; + action = this.defaultActions[state]; } else { - if (symbol === null || typeof symbol == 'undefined') { - symbol = lex(); - } - action = table[state] && table[state][symbol]; + if (symbol === null || typeof symbol == 'undefined') { + symbol = lex(); + } + action = table[state] && table[state][symbol]; } - if (typeof action === 'undefined' || !action.length || !action[0]) { - var errStr = ''; - expected = []; - for (p in table[state]) { - if (this.terminals_[p] && p > TERROR) { - expected.push('\'' + this.terminals_[p] + '\''); - } - } - if (lexer.showPosition) { - errStr = 'Parse error on line ' + (yylineno + 1) + ':\n' + lexer.showPosition() + '\nExpecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\''; - } else { - errStr = 'Parse error on line ' + (yylineno + 1) + ': Unexpected ' + (symbol == EOF ? 'end of input' : '\'' + (this.terminals_[symbol] || symbol) + '\''); - } - this.parseError(errStr, { - text: lexer.match, - token: this.terminals_[symbol] || symbol, - line: lexer.yylineno, - loc: yyloc, - expected: expected - }); + if (typeof action === 'undefined' || !action.length || !action[0]) { + var errStr = ''; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); } + } + if (lexer.showPosition) { + errStr = + 'Parse error on line ' + + (yylineno + 1) + + ':\n' + + lexer.showPosition() + + '\nExpecting ' + + expected.join(', ') + + ", got '" + + (this.terminals_[symbol] || symbol) + + "'"; + } else { + errStr = + 'Parse error on line ' + + (yylineno + 1) + + ': Unexpected ' + + (symbol == EOF + ? 'end of input' + : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer.match, + token: this.terminals_[symbol] || symbol, + line: lexer.yylineno, + loc: yyloc, + expected: expected, + }); + } if (action[0] instanceof Array && action.length > 1) { - throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol); + throw new Error( + 'Parse Error: multiple actions possible at state: ' + + state + + ', token: ' + + symbol, + ); } switch (action[0]) { - case 1: + case 1: stack.push(symbol); vstack.push(lexer.yytext); lstack.push(lexer.yylloc); stack.push(action[1]); symbol = null; if (!preErrorSymbol) { - yyleng = lexer.yyleng; - yytext = lexer.yytext; - yylineno = lexer.yylineno; - yyloc = lexer.yylloc; - if (recovering > 0) { - recovering--; - } + yyleng = lexer.yyleng; + yytext = lexer.yytext; + yylineno = lexer.yylineno; + yyloc = lexer.yylloc; + if (recovering > 0) { + recovering--; + } } else { - symbol = preErrorSymbol; - preErrorSymbol = null; + symbol = preErrorSymbol; + preErrorSymbol = null; } break; - case 2: + case 2: len = this.productions_[action[1]][1]; yyval.$ = vstack[vstack.length - len]; yyval._$ = { - first_line: lstack[lstack.length - (len || 1)].first_line, - last_line: lstack[lstack.length - 1].last_line, - first_column: lstack[lstack.length - (len || 1)].first_column, - last_column: lstack[lstack.length - 1].last_column + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column, }; if (ranges) { - yyval._$.range = [ - lstack[lstack.length - (len || 1)].range[0], - lstack[lstack.length - 1].range[1] - ]; + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1], + ]; } - r = this.performAction.apply(yyval, [ + r = this.performAction.apply( + yyval, + [ yytext, yyleng, yylineno, sharedState.yy, action[1], vstack, - lstack - ].concat(args)); + lstack, + ].concat(args), + ); if (typeof r !== 'undefined') { - return r; + return r; } if (len) { - stack = stack.slice(0, -1 * len * 2); - vstack = vstack.slice(0, -1 * len); - lstack = lstack.slice(0, -1 * len); + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); } stack.push(this.productions_[action[1]][0]); vstack.push(yyval.$); @@ -260,28 +1667,28 @@ parse: function parse(input) { newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; stack.push(newState); break; - case 3: + case 3: return true; } - } - return true; -}}; -/* generated by jison-lex 0.3.4 */ -var lexer = (function(){ -var lexer = ({ - -EOF:1, + } + return true; + }, + }; + /* generated by jison-lex 0.3.4 */ + var lexer = (function () { + var lexer = { + EOF: 1, -parseError:function parseError(str, hash) { + parseError: function parseError(str, hash) { if (this.yy.parser) { - this.yy.parser.parseError(str, hash); + this.yy.parser.parseError(str, hash); } else { - throw new Error(str); + throw new Error(str); } - }, + }, -// resets the lexer, sets new input -setInput:function (input, yy) { + // resets the lexer, sets new input + setInput: function (input, yy) { this.yy = yy || this.yy || {}; this._input = input; this._more = this._backtrack = this.done = false; @@ -289,20 +1696,20 @@ setInput:function (input, yy) { this.yytext = this.matched = this.match = ''; this.conditionStack = ['INITIAL']; this.yylloc = { - first_line: 1, - first_column: 0, - last_line: 1, - last_column: 0 + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0, }; if (this.options.ranges) { - this.yylloc.range = [0,0]; + this.yylloc.range = [0, 0]; } this.offset = 0; return this; - }, + }, -// consumes and returns one char from the input -input:function () { + // consumes and returns one char from the input + input: function () { var ch = this._input[0]; this.yytext += ch; this.yyleng++; @@ -311,21 +1718,21 @@ input:function () { this.matched += ch; var lines = ch.match(/(?:\r\n?|\n).*/g); if (lines) { - this.yylineno++; - this.yylloc.last_line++; + this.yylineno++; + this.yylloc.last_line++; } else { - this.yylloc.last_column++; + this.yylloc.last_column++; } if (this.options.ranges) { - this.yylloc.range[1]++; + this.yylloc.range[1]++; } this._input = this._input.slice(1); return ch; - }, + }, -// unshifts one char (or a string) into the input -unput:function (ch) { + // unshifts one char (or a string) into the input + unput: function (ch) { var len = ch.length; var lines = ch.split(/(?:\r\n?|\n)/g); @@ -338,356 +1745,490 @@ unput:function (ch) { this.matched = this.matched.substr(0, this.matched.length - 1); if (lines.length - 1) { - this.yylineno -= lines.length - 1; + this.yylineno -= lines.length - 1; } var r = this.yylloc.range; this.yylloc = { - first_line: this.yylloc.first_line, - last_line: this.yylineno + 1, - first_column: this.yylloc.first_column, - last_column: lines ? - (lines.length === oldLines.length ? this.yylloc.first_column : 0) - + oldLines[oldLines.length - lines.length].length - lines[0].length : - this.yylloc.first_column - len + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines + ? (lines.length === oldLines.length + ? this.yylloc.first_column + : 0) + + oldLines[oldLines.length - lines.length].length - + lines[0].length + : this.yylloc.first_column - len, }; if (this.options.ranges) { - this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; } this.yyleng = this.yytext.length; return this; - }, + }, -// When called from action, caches matched text and appends it on next action -more:function () { + // When called from action, caches matched text and appends it on next action + more: function () { this._more = true; return this; - }, + }, -// When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. -reject:function () { + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function () { if (this.options.backtrack_lexer) { - this._backtrack = true; + this._backtrack = true; } else { - return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + this.showPosition(), { - text: "", - token: null, - line: this.yylineno - }); - + return this.parseError( + 'Lexical error on line ' + + (this.yylineno + 1) + + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + + this.showPosition(), + { + text: '', + token: null, + line: this.yylineno, + }, + ); } return this; - }, + }, -// retain first n characters of the match -less:function (n) { + // retain first n characters of the match + less: function (n) { this.unput(this.match.slice(n)); - }, + }, -// displays already matched input, i.e. for error messages -pastInput:function () { - var past = this.matched.substr(0, this.matched.length - this.match.length); - return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, ""); - }, + // displays already matched input, i.e. for error messages + pastInput: function () { + var past = this.matched.substr( + 0, + this.matched.length - this.match.length, + ); + return ( + (past.length > 20 ? '...' : '') + past.substr(-20).replace(/\n/g, '') + ); + }, -// displays upcoming input, i.e. for error messages -upcomingInput:function () { + // displays upcoming input, i.e. for error messages + upcomingInput: function () { var next = this.match; if (next.length < 20) { - next += this._input.substr(0, 20-next.length); + next += this._input.substr(0, 20 - next.length); } - return (next.substr(0,20) + (next.length > 20 ? '...' : '')).replace(/\n/g, ""); - }, + return (next.substr(0, 20) + (next.length > 20 ? '...' : '')).replace( + /\n/g, + '', + ); + }, -// displays the character position where the lexing error occurred, i.e. for error messages -showPosition:function () { + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function () { var pre = this.pastInput(); - var c = new Array(pre.length + 1).join("-"); - return pre + this.upcomingInput() + "\n" + c + "^"; - }, + var c = new Array(pre.length + 1).join('-'); + return pre + this.upcomingInput() + '\n' + c + '^'; + }, -// test the lexed token: return FALSE when not a match, otherwise return token -test_match:function (match, indexed_rule) { - var token, - lines, - backup; + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function (match, indexed_rule) { + var token, lines, backup; if (this.options.backtrack_lexer) { - // save context - backup = { - yylineno: this.yylineno, - yylloc: { - first_line: this.yylloc.first_line, - last_line: this.last_line, - first_column: this.yylloc.first_column, - last_column: this.yylloc.last_column - }, - yytext: this.yytext, - match: this.match, - matches: this.matches, - matched: this.matched, - yyleng: this.yyleng, - offset: this.offset, - _more: this._more, - _input: this._input, - yy: this.yy, - conditionStack: this.conditionStack.slice(0), - done: this.done - }; - if (this.options.ranges) { - backup.yylloc.range = this.yylloc.range.slice(0); - } + // save context + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column, + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done, + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } } lines = match[0].match(/(?:\r\n?|\n).*/g); if (lines) { - this.yylineno += lines.length; + this.yylineno += lines.length; } this.yylloc = { - first_line: this.yylloc.last_line, - last_line: this.yylineno + 1, - first_column: this.yylloc.last_column, - last_column: lines ? - lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : - this.yylloc.last_column + match[0].length + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines + ? lines[lines.length - 1].length - + lines[lines.length - 1].match(/\r?\n?/)[0].length + : this.yylloc.last_column + match[0].length, }; this.yytext += match[0]; this.match += match[0]; this.matches = match; this.yyleng = this.yytext.length; if (this.options.ranges) { - this.yylloc.range = [this.offset, this.offset += this.yyleng]; + this.yylloc.range = [this.offset, (this.offset += this.yyleng)]; } this._more = false; this._backtrack = false; this._input = this._input.slice(match[0].length); this.matched += match[0]; - token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + token = this.performAction.call( + this, + this.yy, + this, + indexed_rule, + this.conditionStack[this.conditionStack.length - 1], + ); if (this.done && this._input) { - this.done = false; + this.done = false; } if (token) { - return token; + return token; } else if (this._backtrack) { - // recover context - for (var k in backup) { - this[k] = backup[k]; - } - return false; // rule action called reject() implying the next rule should be tested instead. + // recover context + for (var k in backup) { + this[k] = backup[k]; + } + return false; // rule action called reject() implying the next rule should be tested instead. } return false; - }, + }, -// return next match in input -next:function () { + // return next match in input + next: function () { if (this.done) { - return this.EOF; + return this.EOF; } if (!this._input) { - this.done = true; + this.done = true; } - var token, - match, - tempMatch, - index; + var token, match, tempMatch, index; if (!this._more) { - this.yytext = ''; - this.match = ''; + this.yytext = ''; + this.match = ''; } var rules = this._currentRules(); for (var i = 0; i < rules.length; i++) { - tempMatch = this._input.match(this.rules[rules[i]]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rules[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = false; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; - } - } else if (!this.options.flex) { - break; - } + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } + } } if (match) { - token = this.test_match(match, rules[index]); - if (token !== false) { - return token; - } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - if (this._input === "") { - return this.EOF; + if (this._input === '') { + return this.EOF; } else { - return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), { - text: "", - token: null, - line: this.yylineno - }); + return this.parseError( + 'Lexical error on line ' + + (this.yylineno + 1) + + '. Unrecognized text.\n' + + this.showPosition(), + { + text: '', + token: null, + line: this.yylineno, + }, + ); } - }, + }, -// return next match that has a token -lex:function lex() { + // return next match that has a token + lex: function lex() { var r = this.next(); if (r) { - return r; + return r; } else { - return this.lex(); + return this.lex(); } - }, + }, -// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) -begin:function begin(condition) { + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { this.conditionStack.push(condition); - }, + }, -// pop the previously active lexer condition state off the condition stack -popState:function popState() { + // pop the previously active lexer condition state off the condition stack + popState: function popState() { var n = this.conditionStack.length - 1; if (n > 0) { - return this.conditionStack.pop(); + return this.conditionStack.pop(); } else { - return this.conditionStack[0]; + return this.conditionStack[0]; } - }, + }, -// produce the lexer rule set which is active for the currently active lexer condition state -_currentRules:function _currentRules() { - if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { - return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if ( + this.conditionStack.length && + this.conditionStack[this.conditionStack.length - 1] + ) { + return this.conditions[ + this.conditionStack[this.conditionStack.length - 1] + ].rules; } else { - return this.conditions["INITIAL"].rules; + return this.conditions['INITIAL'].rules; } - }, + }, -// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available -topState:function topState(n) { + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { - return this.conditionStack[n]; + return this.conditionStack[n]; } else { - return "INITIAL"; + return 'INITIAL'; } - }, + }, -// alias for begin(condition) -pushState:function pushState(condition) { + // alias for begin(condition) + pushState: function pushState(condition) { this.begin(condition); - }, + }, -// return the number of states currently on the stack -stateStackSize:function stateStackSize() { + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { return this.conditionStack.length; - }, -options: {}, -performAction: function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) { -var YYSTATE=YY_START; -switch($avoiding_name_collisions) { -case 0:/* ignore whitespace */ -break; -case 1: return "NODETYPE_NODE"; -break; -case 2: return "NODETYPE_TEXT"; -break; -case 3: return "NODETYPE_COMMENT"; -break; -case 4: return "NODETYPE_PROCINSTR"; -break; -case 5: return "VAR"; -break; -case 6: return "NSWILDCARD"; -break; -case 7: return "QNAME"; -break; -case 8: return "WILDCARD"; -break; -case 9: return "MULT"; -break; -case 10: return "AND"; -break; -case 11: return "OR"; -break; -case 12: return "DIV"; -break; -case 13: return "MOD"; -break; -case 14: return "NUM"; -break; -case 15: return "EQ"; -break; -case 16: return "NEQ"; -break; -case 17: return "LTE"; -break; -case 18: return "LT"; -break; -case 19: return "GTE"; -break; -case 20: return "GT"; -break; -case 21: return "PLUS"; -break; -case 22: return "MINUS"; -break; -case 23: return "UNION"; -break; -case 24: return "DBL_SLASH"; -break; -case 25: return "SLASH"; -break; -case 26: return "LBRACK"; -break; -case 27: return "RBRACK"; -break; -case 28: return "LPAREN"; -break; -case 29: return "RPAREN"; -break; -case 30: return "DBL_DOT"; -break; -case 31: return "DOT"; -break; -case 32: return "AT"; -break; -case 33: return "DBL_COLON"; -break; -case 34: return "COMMA"; -break; -case 35: return "HASH"; -break; -case 36: return "STR"; -break; -case 37:return 5; -break; -} -}, -rules: [/^(?:((\s+)))/,/^(?:node(?=(((\s+))?\()))/,/^(?:text(?=(((\s+))?\()))/,/^(?:comment(?=(((\s+))?\()))/,/^(?:processing-instruction(?=(((\s+))?\()))/,/^(?:\$([A-Za-z_][A-Za-z0-9._-]*(:[A-Za-z_][A-Za-z0-9._-]*)?))/,/^(?:([A-Za-z_][A-Za-z0-9._-]*):\*)/,/^(?:([A-Za-z_][A-Za-z0-9._-]*(:[A-Za-z_][A-Za-z0-9._-]*)?))/,/^(?:\*)/,/^(?:\*)/,/^(?:(and))/,/^(?:(or))/,/^(?:(div))/,/^(?:(mod))/,/^(?:(([0-9])+(\.([0-9])*)?|(\.([0-9])+)))/,/^(?:=)/,/^(?:!=)/,/^(?:<=)/,/^(?:<)/,/^(?:>=)/,/^(?:>)/,/^(?:\+)/,/^(?:-)/,/^(?:\|)/,/^(?:\/\/)/,/^(?:\/)/,/^(?:\[)/,/^(?:\])/,/^(?:\()/,/^(?:\))/,/^(?:\.\.)/,/^(?:\.)/,/^(?:@)/,/^(?:::)/,/^(?:,)/,/^(?:#)/,/^(?:("[^"\""]*"|'[^'\'']*'))/,/^(?:$)/], -conditions: {"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37],"inclusive":true},"OP_CONTEXT":{"rules":[0,1,2,3,4,5,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37],"inclusive":true},"VAL_CONTEXT":{"rules":[0,1,2,3,4,5,6,7,8,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37],"inclusive":true}} -}); -return lexer; -})(); -parser.lexer = lexer; -function Parser () { - this.yy = {}; -} -Parser.prototype = parser;parser.Parser = Parser; -return new Parser; + }, + options: {}, + performAction: function anonymous( + yy, + yy_, + $avoiding_name_collisions, + YY_START, + ) { + var YYSTATE = YY_START; + switch ($avoiding_name_collisions) { + case 0 /* ignore whitespace */: + break; + case 1: + return 'NODETYPE_NODE'; + break; + case 2: + return 'NODETYPE_TEXT'; + break; + case 3: + return 'NODETYPE_COMMENT'; + break; + case 4: + return 'NODETYPE_PROCINSTR'; + break; + case 5: + return 'VAR'; + break; + case 6: + return 'NSWILDCARD'; + break; + case 7: + return 'QNAME'; + break; + case 8: + return 'WILDCARD'; + break; + case 9: + return 'MULT'; + break; + case 10: + return 'AND'; + break; + case 11: + return 'OR'; + break; + case 12: + return 'DIV'; + break; + case 13: + return 'MOD'; + break; + case 14: + return 'NUM'; + break; + case 15: + return 'EQ'; + break; + case 16: + return 'NEQ'; + break; + case 17: + return 'LTE'; + break; + case 18: + return 'LT'; + break; + case 19: + return 'GTE'; + break; + case 20: + return 'GT'; + break; + case 21: + return 'PLUS'; + break; + case 22: + return 'MINUS'; + break; + case 23: + return 'UNION'; + break; + case 24: + return 'DBL_SLASH'; + break; + case 25: + return 'SLASH'; + break; + case 26: + return 'LBRACK'; + break; + case 27: + return 'RBRACK'; + break; + case 28: + return 'LPAREN'; + break; + case 29: + return 'RPAREN'; + break; + case 30: + return 'DBL_DOT'; + break; + case 31: + return 'DOT'; + break; + case 32: + return 'AT'; + break; + case 33: + return 'DBL_COLON'; + break; + case 34: + return 'COMMA'; + break; + case 35: + return 'HASH'; + break; + case 36: + return 'STR'; + break; + case 37: + return 5; + break; + } + }, + rules: [ + /^(?:((\s+)))/, + /^(?:node(?=(((\s+))?\()))/, + /^(?:text(?=(((\s+))?\()))/, + /^(?:comment(?=(((\s+))?\()))/, + /^(?:processing-instruction(?=(((\s+))?\()))/, + /^(?:\$([A-Za-z_][A-Za-z0-9._-]*(:[A-Za-z_][A-Za-z0-9._-]*)?))/, + /^(?:([A-Za-z_][A-Za-z0-9._-]*):\*)/, + /^(?:([A-Za-z_][A-Za-z0-9._-]*(:[A-Za-z_][A-Za-z0-9._-]*)?))/, + /^(?:\*)/, + /^(?:\*)/, + /^(?:(and))/, + /^(?:(or))/, + /^(?:(div))/, + /^(?:(mod))/, + /^(?:(([0-9])+(\.([0-9])*)?|(\.([0-9])+)))/, + /^(?:=)/, + /^(?:!=)/, + /^(?:<=)/, + /^(?:<)/, + /^(?:>=)/, + /^(?:>)/, + /^(?:\+)/, + /^(?:-)/, + /^(?:\|)/, + /^(?:\/\/)/, + /^(?:\/)/, + /^(?:\[)/, + /^(?:\])/, + /^(?:\()/, + /^(?:\))/, + /^(?:\.\.)/, + /^(?:\.)/, + /^(?:@)/, + /^(?:::)/, + /^(?:,)/, + /^(?:#)/, + /^(?:("[^"\""]*"|'[^'\'']*'))/, + /^(?:$)/, + ], + conditions: { + INITIAL: { + rules: [ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, + ], + inclusive: true, + }, + OP_CONTEXT: { + rules: [ + 0, 1, 2, 3, 4, 5, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, + ], + inclusive: true, + }, + VAL_CONTEXT: { + rules: [ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, + ], + inclusive: true, + }, + }, + }; + return lexer; + })(); + parser.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser; + parser.Parser = Parser; + return new Parser(); })(); - if (typeof require !== 'undefined' && typeof exports !== 'undefined') { -exports.parser = xpathParser; -exports.Parser = xpathParser.Parser; -exports.parse = function () { return xpathParser.parse.apply(xpathParser, arguments); }; -} \ No newline at end of file + exports.parser = xpathParser; + exports.Parser = xpathParser.Parser; + exports.parse = function () { + return xpathParser.parse.apply(xpathParser, arguments); + }; +} diff --git a/jison/index.js b/jison/index.js index 85dd17634..a05a06ee6 100644 --- a/jison/index.js +++ b/jison/index.js @@ -19,7 +19,7 @@ import xpathParser from './generated-parsers/xpath-parser'; * @returns error message if anything went wrong during the parsing of the expression */ const validateXpath = (xpath) => { - if(xpath) { + if (xpath) { try { // Throws an error if the syntax isn't valid xpathParser.parse(xpath); @@ -30,6 +30,3 @@ const validateXpath = (xpath) => { }; export { validateXpath }; - - - diff --git a/package.json b/package.json index 69f99d742..f22fb5056 100644 --- a/package.json +++ b/package.json @@ -68,28 +68,29 @@ "synthetic-dom": "1.4.0" }, "devDependencies": { + "@babel/eslint-parser": "^7.25.9", + "@babel/plugin-syntax-jsx": "^7.25.9", + "@eslint/js": "^9.15.0", "@testing-library/dom": "^10.2.0", "@testing-library/react": "^16.0.0", "@testing-library/user-event": "^14.5.2", + "@trivago/prettier-plugin-sort-imports": "^4.3.0", "@vitejs/plugin-react": "^4.2.1", "@vitest/coverage-v8": "^2.0.0", - "babel-eslint": "^10.1.0", "bootstrap-sass": "3.4.1", "depcheck": "^1.4.7", "enzyme": "3.11.0", "enzyme-adapter-react-16": "^1.14.0", - "eslint": "^7.24.0", - "eslint-config-airbnb": "19.0.4", - "eslint-config-prettier": "^9.0.0", - "eslint-plugin-import": "2.30.0", - "eslint-plugin-jsx-a11y": "6.10.0", - "eslint-plugin-prettier": "^5.0.0", - "eslint-plugin-react": "7.36.1", - "eslint-plugin-react-hooks": "^4.6.2", + "eslint": "^9.15.0", + "eslint-plugin-react": "^7.37.2", + "eslint-plugin-react-hooks": "^5.0.0", + "eslint-plugin-react-refresh": "^0.4.14", "font-awesome": "4.7.0", - "husky": "^9.0.0", + "globals": "^15.12.0", + "husky": "^9.1.7", "jsdom": "^25.0.0", - "prettier": "^3.0.0", + "lint-staged": "^15.2.10", + "prettier": "^3.4.1", "react-classset": "0.0.2", "react-test-renderer": "^18.3.1", "redux-devtools": "3.7.0", @@ -101,24 +102,25 @@ "vitest": "^2.0.0" }, "scripts": { - "test": "vitest", + "test": "vitest run", + "test:watch": "vitest", "test:coverage": "vitest --coverage", "start": "vite", "build": "npm run generate-entrypoint && vite build", - "lint": "eslint ./src -f table || true", - "lint:fix": "eslint ./src -f table --fix || true", - "_format": "prettier \"{src,build-config,e2e}/**/*.{js,jsx,css,scss}\"", + "lint": "eslint .", + "_format": "prettier --ignore-unknown .", "format": "npm run _format -- --write", "format:check": "npm run _format -- --list-different", "generate-entrypoint": "node scripts/generate-entrypoint.js", "postinstall": "shx cp src/bootstrap-custom/_variables.scss node_modules/bootstrap-sass/assets/stylesheets/bootstrap/", "prepare": "husky" }, - "eslintConfig": { - "extends": [ - "react-app", - "react-app/vitest" - ] + "lint-staged": { + "*.{js,jsx,ts,tsx}": [ + "eslint --fix", + "prettier --write --list-different" + ], + "!(*.js|*.jsx|*.ts|*.tsx)": "prettier --write --ignore-unknown --list-different" }, "browserslist": { "production": [ @@ -132,10 +134,5 @@ "last 1 safari version" ] }, - "prettier": { - "arrowParens": "avoid", - "singleQuote": true, - "trailingComma": "all" - }, "type": "module" } diff --git a/public/silent-sso.html b/public/silent-sso.html index c8102831f..b3bd540de 100644 --- a/public/silent-sso.html +++ b/public/silent-sso.html @@ -1,9 +1,7 @@ - - - - - - \ No newline at end of file + + + + diff --git a/scripts/generate-entrypoint.js b/scripts/generate-entrypoint.js index 50e3d6f46..7cc3fd66a 100644 --- a/scripts/generate-entrypoint.js +++ b/scripts/generate-entrypoint.js @@ -3,9 +3,9 @@ import { readFile, writeFileSync } from 'fs'; readFile('.env', 'utf8', (_, contents) => { const content = contents .split('\n') - .filter(line => !line.startsWith('#')) - .map(line => line.split('=')) - .filter(data => data.length === 2) + .filter((line) => !line.startsWith('#')) + .map((line) => line.split('=')) + .filter((data) => data.length === 2) .map( ([key]) => `echo "window._env_['${key.replace('VITE_', '')}'] = '$${key.replace( diff --git a/src/actions/actionComponent.jsx b/src/actions/actionComponent.jsx index 8fc962d05..7ac17f19f 100644 --- a/src/actions/actionComponent.jsx +++ b/src/actions/actionComponent.jsx @@ -1,6 +1,6 @@ -import { remove } from './component-remove'; import { COMPONENT_TYPE } from '../constants/pogues-constants'; import { setActiveVariables } from './app-state'; +import { remove } from './component-remove'; const { LOOP } = COMPONENT_TYPE; @@ -42,18 +42,18 @@ export const updateComponent = !activeComponentsById[componentId].basedOn ) { const loops = Object.values(activeComponentsById).filter( - element => element.type === LOOP && element.basedOn === componentId, + (element) => element.type === LOOP && element.basedOn === componentId, ); const loopsCalculated = {}; const loopsExternal = {}; - Object.values(activeCalculatedVariablesById).forEach(element => { + Object.values(activeCalculatedVariablesById).forEach((element) => { if (element.scope === componentId) { element.scope = componentsStore[componentId].basedOn; } loopsCalculated[element.id] = element; }); - Object.values(activeExternalVariablesById).forEach(element => { + Object.values(activeExternalVariablesById).forEach((element) => { if (element.scope === componentId) { element.scope = componentsStore[componentId].basedOn; } @@ -65,7 +65,7 @@ export const updateComponent = collectedVariableByQuestion: collectedVariableByQuestion, }); if (loops.length > 0) { - loops.forEach(loop => { + loops.forEach((loop) => { loop.basedOn = componentsStore[componentId].basedOn; const { id } = loop; dispatch({ @@ -108,7 +108,7 @@ export const updateComponent = * * @param {string} idDeletedComponent the id of the component we want to remove */ -export const removeComponent = idDeletedComponent => (dispatch, getState) => { +export const removeComponent = (idDeletedComponent) => (dispatch, getState) => { const state = getState(); const { activeComponentsById } = state.appState; diff --git a/src/actions/actionComponent.spec.jsx b/src/actions/actionComponent.spec.jsx index 03588a08f..8dc4c44ac 100644 --- a/src/actions/actionComponent.spec.jsx +++ b/src/actions/actionComponent.spec.jsx @@ -1,4 +1,5 @@ import { describe, expect, test, vi } from 'vitest'; + import * as actionComponent from './actionComponent'; vi.mock('./component-update'); diff --git a/src/actions/app-state.jsx b/src/actions/app-state.jsx index b087a601a..721b5b5d6 100644 --- a/src/actions/app-state.jsx +++ b/src/actions/app-state.jsx @@ -1,12 +1,12 @@ +import { TCM } from '../constants/pogues-constants'; +import { questionnaireRemoteToStores } from '../model/remote-to-stores'; +import * as Questionnaire from '../model/transformations/questionnaire'; import { - putQuestionnaire, getContextFromCampaign, getVisualization, + putQuestionnaire, } from '../utils/remote-api'; import { addVisualizationError } from './errors'; -import { TCM } from '../constants/pogues-constants'; -import { questionnaireRemoteToStores } from '../model/remote-to-stores'; -import * as Questionnaire from '../model/transformations/questionnaire'; export const SET_ACTIVE_QUESTIONNAIRE = 'SET_ACTIVE_QUESTIONNAIRE'; export const SET_ACTIVE_COMPONENTS = 'SET_ACTIVE_COMPONENTS'; @@ -45,7 +45,7 @@ export const END_LOADING_VISUALIZATION = 'END_LOADING_VISUALIZATION'; * @param {object} questionnaire The questionnaire to set as active * @return {object} SET_ACTIVE_QUESTIONNAIRE action */ -export const setActiveQuestionnaire = questionnaire => ({ +export const setActiveQuestionnaire = (questionnaire) => ({ type: SET_ACTIVE_QUESTIONNAIRE, payload: questionnaire, }); @@ -58,7 +58,7 @@ export const setActiveQuestionnaire = questionnaire => ({ * @param {object} activeComponents The components to set as actives * @return {object} SET_ACTIVE_COMPONENTS action */ -export const setActiveComponents = activeComponents => ({ +export const setActiveComponents = (activeComponents) => ({ type: SET_ACTIVE_COMPONENTS, payload: activeComponents, }); @@ -73,7 +73,7 @@ export const setActiveComponents = activeComponents => ({ * @param {object} activeCodes The codes to set as actives * @return {object} SET_ACTIVE_CODE_LISTS action */ -export const setActiveCodeLists = activeCodeLists => ({ +export const setActiveCodeLists = (activeCodeLists) => ({ type: SET_ACTIVE_CODE_LISTS, payload: { activeCodeLists, @@ -90,7 +90,7 @@ export const setActiveCodeLists = activeCodeLists => ({ * * @return {object} SET_ACTIVE_VARIABLES action */ -export const setActiveVariables = variables => { +export const setActiveVariables = (variables) => { const { activeCalculatedVariablesById, activeExternalVariablesById, @@ -114,7 +114,7 @@ export const setActiveVariables = variables => { * @param {object} activeComponents The components to set as actives * @return {object} SET_ACTIVE_COMPONENTS action */ -export const setActiveDeclarations = activeDeclarations => ({ +export const setActiveDeclarations = (activeDeclarations) => ({ type: SET_ACTIVE_DECLARATIONS, payload: activeDeclarations, }); @@ -127,7 +127,7 @@ export const setActiveDeclarations = activeDeclarations => ({ * @param {string} id The component id * @return {object} SET_SELECTED_COMPONENT action */ -export const setSelectedComponentId = id => ({ +export const setSelectedComponentId = (id) => ({ type: SET_SELECTED_COMPONENT, payload: id, }); @@ -155,7 +155,7 @@ export const setEditingComponentId = (id = '') => ({ * @param {string} label The new questionnaire label. * @return {object} UPDATE_ACTIVE_QUESTIONNAIRE action */ -export const updateActiveQuestionnaire = updatedState => { +export const updateActiveQuestionnaire = (updatedState) => { const { name, label, @@ -256,7 +256,7 @@ function getQuestionnaireModel(state, customComponentsStore) { * * @return {function} Thunk which may dispatch SAVE_ACTIVE_QUESTIONNAIRE_SUCCESS or SAVE_ACTIVE_QUESTIONNAIRE_FAILURE */ -export const saveActiveQuestionnaire = token => { +export const saveActiveQuestionnaire = (token) => { return (dispatch, getState) => { dispatch({ type: SAVE_ACTIVE_QUESTIONNAIRE, @@ -274,7 +274,7 @@ export const saveActiveQuestionnaire = token => { ), ); }) - .catch(err => { + .catch((err) => { return dispatch( saveActiveQuestionnaireFailure(questionnaireModel.id, err), ); @@ -299,7 +299,7 @@ function getPathFromComponent(componentId, componentsById) { return []; } return [ - ...children.map(i => componentsById[i]), + ...children.map((i) => componentsById[i]), ...children.reduce((acc, c) => { return [...acc, ...addChild(c)]; }, []), @@ -313,7 +313,7 @@ function getPathFromComponent(componentId, componentsById) { return [ { ...componentsById[parentId], - children: componentsById[parentId].children.filter(i => i === id), + children: componentsById[parentId].children.filter((i) => i === id), }, ...addParent(parentId), ]; @@ -336,7 +336,7 @@ function getPathFromComponent(componentId, componentsById) { * This method will reset Controls and redirections when we want to visualize a part of the questionnaire. * @param {*} activeComponentsById the components list on which we need to reset all controls and redirections */ -export const removeControlsAndRedirections = activeComponentsById => { +export const removeControlsAndRedirections = (activeComponentsById) => { return Object.keys(activeComponentsById).reduce((acc, componentId) => { return { ...acc, @@ -384,7 +384,7 @@ export const visualizeActiveQuestionnaire = (type, componentId, token) => { const visualize = () => { getVisualization(type, questionnaireModel, containsRef, token) .then(() => dispatch(endLoadingVisualization())) - .catch(error => { + .catch((error) => { dispatch(endLoadingVisualization()); dispatch(addVisualizationError(error)); }); @@ -420,19 +420,19 @@ export const visualizeActiveQuestionnaire = (type, componentId, token) => { * * @return {function} Thunk which may dispatch SET_INVALID_ITEMS */ -export const setInvalidItemsFromErrors = questionId => { +export const setInvalidItemsFromErrors = (questionId) => { return (dispatch, getState) => { const state = getState(); const { errorsByCode } = state.appState; const invalidItems = Object.keys(errorsByCode) - .filter(code => errorsByCode[code].errors.length > 0) + .filter((code) => errorsByCode[code].errors.length > 0) .reduce((acc, code) => { const { errors } = errorsByCode[code]; return { ...acc, ...errors - .filter(e => e.id === questionId) + .filter((e) => e.id === questionId) .reduce((accInner, eInner) => { const { itemId, ...params } = eInner.params; return { @@ -464,7 +464,7 @@ export const setInvalidItemsFromErrors = questionId => { * * @return {object} REMOVE_INVALID_ITEM action */ -export const removeInvalidItem = invalidItemIdToRemove => ({ +export const removeInvalidItem = (invalidItemIdToRemove) => ({ type: REMOVE_INVALID_ITEM, payload: { invalidItemIdToRemove, @@ -492,12 +492,12 @@ export const loadStatisticalContextSuccess = ({ serie, operation }) => ({ payload: { serie, operation }, }); -export const loadStatisticalContextFailure = err => ({ +export const loadStatisticalContextFailure = (err) => ({ type: LOAD_STATISTICAL_CONTEXT_FAILURE, payload: err, }); -export const loadStatisticalContext = (idCampaign, token) => dispatch => { +export const loadStatisticalContext = (idCampaign, token) => (dispatch) => { dispatch({ type: LOAD_STATISTICAL_CONTEXT, payload: null, @@ -512,10 +512,10 @@ export const loadStatisticalContext = (idCampaign, token) => dispatch => { .then(({ serieId: serie, operationId: operation }) => { return dispatch(loadStatisticalContextSuccess({ serie, operation })); }) - .catch(err => dispatch(loadStatisticalContextFailure(err))); + .catch((err) => dispatch(loadStatisticalContextFailure(err))); }; -export const deleteAppState = () => dispatch => { +export const deleteAppState = () => (dispatch) => { dispatch({ type: DELETE_APPSTATE, }); diff --git a/src/actions/app-state.spec.jsx b/src/actions/app-state.spec.jsx index bd5b4ca38..1a12c73dc 100644 --- a/src/actions/app-state.spec.jsx +++ b/src/actions/app-state.spec.jsx @@ -1,4 +1,5 @@ import { describe, expect, test } from 'vitest'; + import { SAVE_ACTIVE_QUESTIONNAIRE_FAILURE, SAVE_ACTIVE_QUESTIONNAIRE_SUCCESS, diff --git a/src/actions/component-insert.jsx b/src/actions/component-insert.jsx index 8538694e6..6286acf11 100644 --- a/src/actions/component-insert.jsx +++ b/src/actions/component-insert.jsx @@ -1,21 +1,22 @@ -import sortBy from 'lodash.sortby'; import cloneDeep from 'lodash.clonedeep'; +import sortBy from 'lodash.sortby'; + import { COMPONENT_TYPE } from '../constants/pogues-constants'; import { - toComponents, isQuestion, - isSubSequence, isSequence, + isSubSequence, + toComponents, toId, updateNewComponentParent, } from '../utils/component/component-utils'; import { getClosestComponentIdByType } from '../utils/component/generic-input-utils'; +import { uuid } from '../utils/utils'; import { - resetWeight, increaseWeightOfAll, resetChildren, + resetWeight, } from './component-update'; -import { uuid } from '../utils/utils'; const { SEQUENCE } = COMPONENT_TYPE; @@ -80,7 +81,7 @@ export function moveQuestionToSubSequence( oldParent.children, activesComponents, ).filter( - child => + (child) => ((!keepChildren && child.weight === selectedComponent.weight + 1) || (keepChildren && (child.weight > selectedComponent.weight || @@ -96,7 +97,7 @@ export function moveQuestionToSubSequence( */ if (questionsToMove.length > 0) { const newChildren = oldParent.children.filter( - child => questionsToMoveId.indexOf(child) < 0, + (child) => questionsToMoveId.indexOf(child) < 0, ); /** @@ -118,7 +119,7 @@ export function moveQuestionToSubSequence( if (!isQuestion(oldParent)) { moves = { ...moves, - ...resetWeight(newChildren.map(id => moves[id])), + ...resetWeight(newChildren.map((id) => moves[id])), }; moves = { ...moves, @@ -155,7 +156,9 @@ export function moveQuestionAndSubSequenceToSequence( /** * We get the list of components of the parent of the selected element */ - const listOfComponent = oldParent.children.map(id => activesComponents[id]); + const listOfComponent = oldParent.children.map( + (id) => activesComponents[id], + ); /** * Based on this list, we fetch only the component to move (with the @@ -164,7 +167,7 @@ export function moveQuestionAndSubSequenceToSequence( */ let listOfComponentsToMove = sortBy(listOfComponent, ['weight']) .filter( - child => + (child) => child.weight > selectedComponent.weight || (includeSelectedComponent && child.weight === selectedComponent.weight), @@ -183,7 +186,7 @@ export function moveQuestionAndSubSequenceToSequence( * List of components that should stay in the previous parent */ const listOfComponentsToKeep = listOfComponent.filter( - child => + (child) => child.weight < selectedComponent.weight || (!includeSelectedComponent && child.weight === selectedComponent.weight), @@ -219,8 +222,8 @@ export function moveQuestionAndSubSequenceToSequence( listOfComponentsToMove = [ ...listOfComponentsToMove, ...parentSequence.children - .map(c => activesComponents[c]) - .filter(c => c.weight > component.weight) + .map((c) => activesComponents[c]) + .filter((c) => c.weight > component.weight) .map((c, i) => { return { ...c, @@ -250,7 +253,7 @@ export function moveQuestionAndSubSequenceToSequence( ...activesComponents, ...moveComponents( Object.keys(listOfComponentsToMove).map( - key => listOfComponentsToMove[key], + (key) => listOfComponentsToMove[key], ), newComponent, ), @@ -258,7 +261,7 @@ export function moveQuestionAndSubSequenceToSequence( ...resetChildren( parentSequence, toComponents(parentSequence.children, activesComponents).filter( - c => + (c) => c.weight < component.weight || (!includeSelectedComponent && c.weight === component.weight), ), diff --git a/src/actions/component-insert.spec.jsx b/src/actions/component-insert.spec.jsx index 336016a6e..098762b8c 100644 --- a/src/actions/component-insert.spec.jsx +++ b/src/actions/component-insert.spec.jsx @@ -1,4 +1,5 @@ import { describe, expect, test } from 'vitest'; + import { COMPONENT_TYPE } from '../constants/pogues-constants'; import * as component from './component-insert'; @@ -391,7 +392,7 @@ describe('duplicate', () => { test('should duplicate the question', () => { const result = component.duplicate(activesComponents, '2'); const newId = Object.keys(result).find( - id => Object.keys(activesComponents).indexOf(id) < 0, + (id) => Object.keys(activesComponents).indexOf(id) < 0, ); expect(result['1']).toEqual({ @@ -534,7 +535,7 @@ describe('duplicateComponentAndVars', () => { ); const newId = Object.keys(output.activeComponentsById).find( - id => Object.keys(activesComponents).indexOf(id) < 0, + (id) => Object.keys(activesComponents).indexOf(id) < 0, ); const duplicated = output.activeComponentsById[idComponent]; @@ -561,7 +562,7 @@ describe('duplicateComponentAndVars', () => { expect(Object.keys(duplicate.declarations)).not.toEqual( Object.keys(duplicated.declarations), ); - Object.keys(duplicate.declarations).forEach(declarationId => { + Object.keys(duplicate.declarations).forEach((declarationId) => { expect(declarationId).toBe(duplicate.declarations[declarationId].id); }); }); diff --git a/src/actions/component-move.jsx b/src/actions/component-move.jsx index 5e7447ead..fa2b2f41c 100644 --- a/src/actions/component-move.jsx +++ b/src/actions/component-move.jsx @@ -1,17 +1,18 @@ import sortBy from 'lodash.sortby'; + +import { getDragnDropLevel } from '../utils/component/component-dragndrop-utils'; import { - isSubSequence, - isSequence, isQuestion, + isSequence, + isSubSequence, toComponents, } from '../utils/component/component-utils'; import { getClosestComponentIdByType } from '../utils/component/generic-input-utils'; -import { getDragnDropLevel } from '../utils/component/component-dragndrop-utils'; -import { resetAllWeight, increaseWeightOfAll } from './component-update'; import { - moveQuestionToSubSequence, moveQuestionAndSubSequenceToSequence, + moveQuestionToSubSequence, } from './component-insert'; +import { increaseWeightOfAll, resetAllWeight } from './component-update'; export function dummyFunction() { return 'Hello world'; @@ -83,11 +84,11 @@ function attachQuestionToPreviousSubSequence(activesComponents) { const moves = { ...activesComponents, }; - const sequences = Object.keys(activesComponents).filter(key => + const sequences = Object.keys(activesComponents).filter((key) => isSequence(moves[key]), ); - sequences.forEach(sequence => { + sequences.forEach((sequence) => { const children = sortBy(toComponents(moves[sequence].children, moves), [ 'weight', ]); @@ -109,7 +110,7 @@ function attachQuestionToPreviousSubSequence(activesComponents) { moves[children[i].parent] = { ...moves[children[i].parent], children: moves[children[i].parent].children.filter( - id => id !== children[i].id, + (id) => id !== children[i].id, ), }; } @@ -191,7 +192,7 @@ export function moveComponent( ) { includeSelectedComponent = true; droppedComponent = toComponents(droppedComponent.children, moves).find( - c => c.weight === 0, + (c) => c.weight === 0, ); } @@ -217,7 +218,7 @@ export function moveComponent( ) { includeSelectedComponent = true; droppedComponent = toComponents(droppedComponent.children, moves).find( - c => c.weight === 0, + (c) => c.weight === 0, ); } @@ -262,7 +263,7 @@ export function moveComponent( }, [oldParent.id]: { ...oldParent, - children: oldParent.children.filter(id => id !== moveComponentId), + children: oldParent.children.filter((id) => id !== moveComponentId), }, }; } diff --git a/src/actions/component-move.spec.jsx b/src/actions/component-move.spec.jsx index 1a6d0958c..781eb12a5 100644 --- a/src/actions/component-move.spec.jsx +++ b/src/actions/component-move.spec.jsx @@ -1,4 +1,5 @@ import { describe, expect, test, vi } from 'vitest'; + import { COMPONENT_TYPE } from '../constants/pogues-constants'; import * as component from './component-move'; diff --git a/src/actions/component-remove.jsx b/src/actions/component-remove.jsx index 81bdb1f0e..acf879aed 100644 --- a/src/actions/component-remove.jsx +++ b/src/actions/component-remove.jsx @@ -1,17 +1,18 @@ -import sortBy from 'lodash.sortby'; import find from 'lodash.find'; -import takeWhile from 'lodash.takewhile'; +import sortBy from 'lodash.sortby'; import takeRight from 'lodash.takeright'; +import takeWhile from 'lodash.takewhile'; + +import { COMPONENT_TYPE } from '../constants/pogues-constants'; import { - toComponents, - isQuestion, - isSubSequence, - isLoop, isFilter, + isLoop, isNestedFilter, + isQuestion, + isSubSequence, + toComponents, toId, } from '../utils/component/component-utils'; -import { COMPONENT_TYPE } from '../constants/pogues-constants'; import { resetWeight } from './component-update'; const { SEQUENCE } = COMPONENT_TYPE; @@ -37,7 +38,7 @@ export function removeComponentFromActivesComponent( ...activesComponents[currentElement.id], children: activesComponents[currentElement.id]?.children ? activesComponents[currentElement.id].children.filter( - childId => childId !== deletedComponent.id, + (childId) => childId !== deletedComponent.id, ) : [], }; @@ -85,8 +86,8 @@ export function removeSubSequence(activesComponents, deletedComponent) { const previousSubSequence = activesComponents[ deletedComponent.parent ].children - .map(id => activesComponents[id]) - .find(c => c.weight === deletedComponent.weight - 1); + .map((id) => activesComponents[id]) + .find((c) => c.weight === deletedComponent.weight - 1); let newChildren = deletedComponent.children; let newParentId; @@ -193,7 +194,7 @@ export function removeSequence(activesComponents, deletedComponent) { // We will find the previous sibling SEQUENCE const previousSequence = find( toComponents(parent.children, activesComponents), - c => c.weight === previousSequenceWeight, + (c) => c.weight === previousSequenceWeight, ); // From the previous SEQUENCE, we will get the last component @@ -206,7 +207,7 @@ export function removeSequence(activesComponents, deletedComponent) { // If the last component is a subsequence, we will get the first n QUESTION of the deleted component if (isSubSequence(lastComponentFromPreviousSequence)) { - firstQuestionsToMove = takeWhile(childrenToMove, c => isQuestion(c)); + firstQuestionsToMove = takeWhile(childrenToMove, (c) => isQuestion(c)); } // Based on the previous firstQuestionsToMove array, we will get the other item in another array diff --git a/src/actions/component-remove.spec.jsx b/src/actions/component-remove.spec.jsx index cc3cac294..c8bdbc8df 100644 --- a/src/actions/component-remove.spec.jsx +++ b/src/actions/component-remove.spec.jsx @@ -1,4 +1,5 @@ import { describe, expect, test } from 'vitest'; + import { COMPONENT_TYPE } from '../constants/pogues-constants'; import * as component from './component-remove'; @@ -85,7 +86,7 @@ describe('remove', () => { }, }, }; - [SEQUENCE, SUBSEQUENCE, QUESTION].forEach(type => { + [SEQUENCE, SUBSEQUENCE, QUESTION].forEach((type) => { test(`should only remove the component if it is a ${type} without child`, () => { const activesComponents = { 1: { id: '1', weight: 0, type: QUESTIONNAIRE, children: ['2', '6'] }, @@ -618,7 +619,7 @@ describe('remove', () => { }); describe('remove', () => { - [SEQUENCE, SUBSEQUENCE, QUESTION].forEach(type => { + [SEQUENCE, SUBSEQUENCE, QUESTION].forEach((type) => { test(`For a ${type} without children, should call removeLeafComponent`, () => { const activesComponents = { 1: { id: '1', weight: 0, type: QUESTIONNAIRE, children: ['2', '6'] }, diff --git a/src/actions/component-update.jsx b/src/actions/component-update.jsx index 58cdc9abd..e67bca1c9 100644 --- a/src/actions/component-update.jsx +++ b/src/actions/component-update.jsx @@ -1,6 +1,7 @@ import sortBy from 'lodash.sortby'; -import { toComponents, toId } from '../utils/component/component-utils'; + import { COMPONENT_TYPE } from '../constants/pogues-constants'; +import { toComponents, toId } from '../utils/component/component-utils'; const { FILTER, LOOP } = COMPONENT_TYPE; /** @@ -90,7 +91,7 @@ export function resetWeight(components) { */ export function resetAllWeight(activesComponents) { return Object.keys(activesComponents) - .map(key => activesComponents[key]) + .map((key) => activesComponents[key]) .reduce((acc, component) => { if (component.children && component.children.length > 0) { return { diff --git a/src/actions/component-update.spec.jsx b/src/actions/component-update.spec.jsx index 4920ca5ad..452c5d066 100644 --- a/src/actions/component-update.spec.jsx +++ b/src/actions/component-update.spec.jsx @@ -1,4 +1,5 @@ import { describe, expect, test } from 'vitest'; + import { increaseWeightOfAll, resetAllWeight, diff --git a/src/actions/component.jsx b/src/actions/component.jsx index 741ae7ede..2a61e12af 100644 --- a/src/actions/component.jsx +++ b/src/actions/component.jsx @@ -1,24 +1,24 @@ +import { COMPONENT_TYPE } from '../constants/pogues-constants'; import { - isSubSequence, - isSequence, - isQuestion, - toComponents, - updateNewComponentParent, isExternalQuestionnaire, - isLoop, isFilter, + isLoop, isNestedFilter, + isQuestion, + isSequence, + isSubSequence, + toComponents, + updateNewComponentParent, } from '../utils/component/component-utils'; -import { increaseWeightOfAll } from './component-update'; -import { remove } from './component-remove'; import { - moveQuestionToSubSequence, - moveQuestionAndSubSequenceToSequence, duplicate, duplicateComponentAndVars, + moveQuestionAndSubSequenceToSequence, + moveQuestionToSubSequence, } from './component-insert'; import { moveComponent } from './component-move'; -import { COMPONENT_TYPE } from '../constants/pogues-constants'; +import { remove } from './component-remove'; +import { increaseWeightOfAll } from './component-update'; export const CREATE_COMPONENT = 'CREATE_COMPONENT'; export const DUPLICATE_COMPONENT = 'DUPLICATE_COMPONENT'; @@ -49,11 +49,11 @@ export const createComponent = collectedVariablesStore, codesListsStore, ) => - dispatch => { + (dispatch) => { const activeComponentsStore = { [componentState.id]: componentState, }; - return new Promise(resolve => { + return new Promise((resolve) => { const result = dispatch({ type: CREATE_COMPONENT, payload: { @@ -136,7 +136,7 @@ export const orderComponents = const siblingSelectedComponent = toComponents( activesComponents[selectedComponent.parent].children, activesComponents, - ).find(c => c.weight === selectedComponent.weight + 1); + ).find((c) => c.weight === selectedComponent.weight + 1); const childrenSelectedComponentLength = selectedComponent.children.length; /** @@ -158,7 +158,7 @@ export const orderComponents = : toComponents( activesComponents[selectedComponent.id].children, activesComponents, - ).find(c => c.weight === 0); + ).find((c) => c.weight === 0); activeComponentsById = moveQuestionToSubSequence( activesComponents, @@ -186,7 +186,7 @@ export const orderComponents = : toComponents( activesComponents[selectedComponent.id].children, activesComponents, - ).find(c => c.weight === 0); + ).find((c) => c.weight === 0); activeComponentsById = moveQuestionAndSubSequenceToSequence( activesComponents, comp, @@ -262,16 +262,16 @@ export const dragComponent = const externalVariablesStore = state.appState.activeExternalVariablesById; const find_Filters = Object.values(activesComponents).filter( - element => + (element) => element.type === FILTER && (element.initialMember === idTargetComponent || element.finalMember === idTargetComponent), ); if (find_Filters.length > 0) { - find_Filters.forEach(filter => { + find_Filters.forEach((filter) => { if (filter.finalMember !== idTargetComponent) { const next_element = Object.values(activesComponents).find( - element => + (element) => activesComponents[filter.initialMember] && element.type === activesComponents[filter.initialMember].type && element.parent === @@ -303,7 +303,7 @@ export const dragComponent = } } else if (filter.initialMember !== idTargetComponent) { const next_element = Object.values(activesComponents).find( - element => + (element) => activesComponents[filter.finalMember] && element.type === activesComponents[filter.finalMember].type && element.parent === activesComponents[filter.finalMember].parent && @@ -365,7 +365,7 @@ export const dragComponent = * * @param {string} idDeletedComponent the id of the component we want to remove */ -export const removeComponent = idDeletedComponent => (dispatch, getState) => { +export const removeComponent = (idDeletedComponent) => (dispatch, getState) => { const state = getState(); const { activeComponentsById } = state.appState; @@ -380,7 +380,7 @@ export const removeComponent = idDeletedComponent => (dispatch, getState) => { * * @param {string} idDeletedComponent the id of the component we want to remove */ -export const duplicateComponent = idComponent => (dispatch, getState) => { +export const duplicateComponent = (idComponent) => (dispatch, getState) => { const state = getState(); const { activeComponentsById } = state.appState; dispatch({ @@ -399,7 +399,7 @@ export const duplicateComponent = idComponent => (dispatch, getState) => { * @param {string} idComponent the id of the component we want to remove */ export const duplicateComponentAndVariables = - idComponent => (dispatch, getState) => { + (idComponent) => (dispatch, getState) => { const state = getState(); const { activeComponentsById } = state.appState; const collectedVariables = diff --git a/src/actions/component.spec.jsx b/src/actions/component.spec.jsx index e51040f9f..da3bf885a 100644 --- a/src/actions/component.spec.jsx +++ b/src/actions/component.spec.jsx @@ -1,4 +1,5 @@ import { describe, expect, test, vi } from 'vitest'; + import { COMPONENT_TYPE } from '../constants/pogues-constants'; import * as component from './component'; diff --git a/src/actions/errors.jsx b/src/actions/errors.jsx index 68bf3f432..9d3ff34a3 100644 --- a/src/actions/errors.jsx +++ b/src/actions/errors.jsx @@ -12,21 +12,21 @@ export const SET_ERRORS_BY_COMPONENT = 'SET_ERRORS_BY_COMPONENT'; export const ADD_VISUALIZATION_ERROR = 'ADD_VISUALIZATION_ERROR'; export const REMOVE_VISUALIZATION_ERROR = 'REMOVE_VISUALIZATION_ERROR'; -export const addValidationErrors = errors => { +export const addValidationErrors = (errors) => { return { type: ADD_VALIDATION_ERRORS, payload: { errors }, }; }; -export const setValidationErrors = errors => { +export const setValidationErrors = (errors) => { return { type: SET_VALIDATION_ERRORS, payload: { errors }, }; }; -export const removeValidationErrors = paths => { +export const removeValidationErrors = (paths) => { return { type: REMOVE_VALIDATION_ERRORS, payload: paths, @@ -40,21 +40,21 @@ export const clearValidationErrors = () => { }; }; -export const addSubformValidationErrors = errors => { +export const addSubformValidationErrors = (errors) => { return { type: ADD_SUBFORM_VALIDATION_ERRORS, payload: { errors }, }; }; -export const setSubformValidationErrors = errors => { +export const setSubformValidationErrors = (errors) => { return { type: SET_SUBFORM_VALIDATION_ERRORS, payload: { errors }, }; }; -export const removeSubformValidationErrors = paths => { +export const removeSubformValidationErrors = (paths) => { return { type: REMOVE_SUBFORM_VALIDATION_ERRORS, payload: paths, @@ -79,7 +79,7 @@ export const removeIntegrityError = (componentId, typeError, itemListId) => { }; }; -export const addVisualizationError = error => { +export const addVisualizationError = (error) => { return { type: ADD_VISUALIZATION_ERROR, payload: { error }, diff --git a/src/actions/external-questionnaire.jsx b/src/actions/external-questionnaire.jsx index a7f7271ed..76d215048 100644 --- a/src/actions/external-questionnaire.jsx +++ b/src/actions/external-questionnaire.jsx @@ -1,14 +1,14 @@ export const CREATE_QUESTIONNAIRE_REF = 'CREATE_QUESTIONNAIRE_REF'; export const REMOVE_QUESTIONNAIRE_REF = 'REMOVE_QUESTIONNAIRE_REF'; -export const handleNewChildQuestionnaireRef = id => ({ +export const handleNewChildQuestionnaireRef = (id) => ({ type: CREATE_QUESTIONNAIRE_REF, payload: { id, }, }); -export const removeQuestionnaireRef = id => ({ +export const removeQuestionnaireRef = (id) => ({ type: REMOVE_QUESTIONNAIRE_REF, payload: { id, diff --git a/src/actions/general.jsx b/src/actions/general.jsx index dd51a9d4b..aef138ba2 100644 --- a/src/actions/general.jsx +++ b/src/actions/general.jsx @@ -1,6 +1,6 @@ export const SET_SELECTED_STAMP = 'SET_SELECTED_STAMP'; -export const setSelectedStamp = stamp => ({ +export const setSelectedStamp = (stamp) => ({ type: SET_SELECTED_STAMP, payload: stamp, }); diff --git a/src/actions/metadata.jsx b/src/actions/metadata.jsx index 94691f354..b396f7ba4 100644 --- a/src/actions/metadata.jsx +++ b/src/actions/metadata.jsx @@ -1,13 +1,13 @@ import { DIMENSION_LENGTH } from '../constants/pogues-constants'; import { - getUnitsList, - getSeries, - getOperations, getCampaigns, - getVariablesById, - getQuestionnaire, - getNomenclatures, getNomenclature, + getNomenclatures, + getOperations, + getQuestionnaire, + getSeries, + getUnitsList, + getVariablesById, } from '../utils/remote-api'; const { NON_DYNAMIC } = DIMENSION_LENGTH; @@ -38,7 +38,7 @@ export const loadMetadataSuccess = (type, metadata) => { }; }; -export const loadMetadataFailure = err => ({ +export const loadMetadataFailure = (err) => ({ type: LOAD_METADATA_FAILURE, payload: err, }); @@ -52,15 +52,15 @@ export const loadMetadataFailure = err => ({ * * @return {function} Thunk which may dispatch LOAD_METADATA_SUCCESS or LOAD_METADATA_FAILURE */ -export const loadUnits = token => dispatch => { +export const loadUnits = (token) => (dispatch) => { dispatch({ type: LOAD_UNITS, payload: null, }); return getUnitsList(token) - .then(listUnits => { + .then((listUnits) => { const units = listUnits - .map(u => ({ + .map((u) => ({ id: u.uri, uri: u.uri, label: u.label, @@ -70,10 +70,10 @@ export const loadUnits = token => dispatch => { }); return dispatch(loadMetadataSuccess('units', units)); }) - .catch(err => dispatch(loadMetadataFailure(err))); + .catch((err) => dispatch(loadMetadataFailure(err))); }; -export const loadUnitsIfNeeded = token => (dispatch, getState) => { +export const loadUnitsIfNeeded = (token) => (dispatch, getState) => { const state = getState(); const { units } = state.metadataByType; if (!units) dispatch(loadUnits(token)); @@ -81,25 +81,25 @@ export const loadUnitsIfNeeded = token => (dispatch, getState) => { // Metadata series -export const loadSeries = token => dispatch => { +export const loadSeries = (token) => (dispatch) => { dispatch({ type: LOAD_SERIES, payload: null, }); return getSeries(token) - .then(series => { - const seriesMetadata = series.map(s => ({ + .then((series) => { + const seriesMetadata = series.map((s) => ({ id: s.id, value: s.id, label: s.label, })); return dispatch(loadMetadataSuccess('series', seriesMetadata)); }) - .catch(err => dispatch(loadMetadataFailure(err))); + .catch((err) => dispatch(loadMetadataFailure(err))); }; -export const loadSeriesIfNeeded = token => (dispatch, getState) => { +export const loadSeriesIfNeeded = (token) => (dispatch, getState) => { const state = getState(); const { series } = state.metadataByType; if (!series) dispatch(loadSeries(token)); @@ -107,15 +107,15 @@ export const loadSeriesIfNeeded = token => (dispatch, getState) => { // Metadata operations -export const loadOperations = (idSerie, token) => dispatch => { +export const loadOperations = (idSerie, token) => (dispatch) => { dispatch({ type: LOAD_OPERATIONS, payload: null, }); return getOperations(idSerie, token) - .then(operations => { - const operationsMetadata = operations.map(o => ({ + .then((operations) => { + const operationsMetadata = operations.map((o) => ({ id: o.id, value: o.id, label: o.label, @@ -123,7 +123,7 @@ export const loadOperations = (idSerie, token) => dispatch => { })); return dispatch(loadMetadataSuccess('operations', operationsMetadata)); }) - .catch(err => dispatch(loadMetadataFailure(err))); + .catch((err) => dispatch(loadMetadataFailure(err))); }; export const loadOperationsIfNeeded = @@ -142,15 +142,15 @@ export const loadOperationsIfNeeded = // Metadata campaigns -export const loadCampaigns = (idOperation, token) => dispatch => { +export const loadCampaigns = (idOperation, token) => (dispatch) => { dispatch({ type: LOAD_CAMPAIGNS, payload: null, }); return getCampaigns(idOperation, token) - .then(campaigns => { - const campaignsMetadata = campaigns.map(c => ({ + .then((campaigns) => { + const campaignsMetadata = campaigns.map((c) => ({ id: c.id, value: c.id, label: c.label, @@ -158,7 +158,7 @@ export const loadCampaigns = (idOperation, token) => dispatch => { })); return dispatch(loadMetadataSuccess('campaigns', campaignsMetadata)); }) - .catch(err => dispatch(loadMetadataFailure(err))); + .catch((err) => dispatch(loadMetadataFailure(err))); }; export const loadCampaignsIfNeeded = @@ -179,7 +179,7 @@ export const loadCampaignsIfNeeded = // Metadata : variables from external elements export const loadExternalQuestionnairesVariables = - (idExternalQuestionnaire, token) => async dispatch => { + (idExternalQuestionnaire, token) => async (dispatch) => { dispatch({ type: LOAD_EXTERNAL_ELEMENTS_VARIABLES, payload: null, @@ -209,12 +209,12 @@ export const loadExternalQuestionnairesVariables = // Metadata : loops from external elements -const isQuestionLoop = component => { +const isQuestionLoop = (component) => { return ( component.type === 'QuestionType' && ((component.questionType === 'TABLE' && component.ResponseStructure.Dimension.some( - dim => + (dim) => dim.dimensionType === 'PRIMARY' && dim.dynamic !== '0' && dim.dynamic !== NON_DYNAMIC, @@ -224,7 +224,7 @@ const isQuestionLoop = component => { }; export const loadExternalQuestionnairesLoops = - (idExternalQuestionnaire, token) => async dispatch => { + (idExternalQuestionnaire, token) => async (dispatch) => { dispatch({ type: LOAD_EXTERNAL_ELEMENTS_LOOPS, payload: null, @@ -268,8 +268,8 @@ export const loadExternalQuestionnairesLoops = }, []); const externalQuestionnaireLoops = externalQuestionnaire.Iterations?.Iteration.filter( - loop => !loop.IterableReference, - ).map(loop => ({ id: loop.id, name: loop.Name })); + (loop) => !loop.IterableReference, + ).map((loop) => ({ id: loop.id, name: loop.Name })); const externalQuestionnairesMetadata = [ { @@ -309,7 +309,7 @@ export const loadExternalQuestionnairesIfNeeded = // Metadata : Nomenclatures -export const loadNomenclatures = token => async dispatch => { +export const loadNomenclatures = (token) => async (dispatch) => { dispatch({ type: LOAD_NOMENCLATURES, payload: null, @@ -318,7 +318,7 @@ export const loadNomenclatures = token => async dispatch => { try { const nomenclatures = await getNomenclatures(token); const nomenclaturesMetadata = Object.values(nomenclatures.nomenclatures) - .map(nomenclature => ({ + .map((nomenclature) => ({ id: nomenclature.id, label: nomenclature.label, })) @@ -333,14 +333,14 @@ export const loadNomenclatures = token => async dispatch => { } }; -export const loadNomenclaturesIfNeeded = token => (dispatch, getState) => { +export const loadNomenclaturesIfNeeded = (token) => (dispatch, getState) => { const state = getState(); const { nomenclatures } = state.metadataByType; if (!nomenclatures) dispatch(loadNomenclatures(token)); }; export const loadNomenclature = - (token, id, nomenclatures) => async dispatch => { + (token, id, nomenclatures) => async (dispatch) => { dispatch({ type: LOAD_NOMENCLATURES, payload: null, diff --git a/src/actions/metadata.spec.jsx b/src/actions/metadata.spec.jsx index 75b212c90..7317a3d20 100644 --- a/src/actions/metadata.spec.jsx +++ b/src/actions/metadata.spec.jsx @@ -1,4 +1,5 @@ import { describe, expect, it, vi } from 'vitest'; + import { loadUnitsIfNeeded } from './metadata'; describe('loadUnitsIfNeeded', () => { diff --git a/src/actions/questionnaire-list.jsx b/src/actions/questionnaire-list.jsx index a1fc279bf..e1fc979b7 100644 --- a/src/actions/questionnaire-list.jsx +++ b/src/actions/questionnaire-list.jsx @@ -1,5 +1,5 @@ -import { getQuestionnaireList } from '../utils/remote-api'; import { questionnaireListRemoteToStores } from '../model/remote-to-stores'; +import { getQuestionnaireList } from '../utils/remote-api'; export const LOAD_QLIST = 'LOAD_QLIST'; export const LOAD_QLIST_SUCCESS = 'LOAD_QLIST_SUCCESS'; @@ -24,7 +24,7 @@ export const DELETE_QLIST_SUCCESS = 'DELETE_QLIST_SUCCESS'; * @param {array} updatesList The new values to update in the different stores affected. * @return {object} LOAD_QLIST_SUCCESS action. */ -export const loadQuestionnaireListSuccess = updatesList => ({ +export const loadQuestionnaireListSuccess = (updatesList) => ({ type: LOAD_QLIST_SUCCESS, payload: updatesList, }); @@ -37,7 +37,7 @@ export const loadQuestionnaireListSuccess = updatesList => ({ * @param {string} err The error returned for the fetch process. * @return {object} LOAD_QLIST_FAILURE action */ -export const loadQuestionnaireListFailure = err => ({ +export const loadQuestionnaireListFailure = (err) => ({ type: LOAD_QLIST_FAILURE, payload: err, }); @@ -49,7 +49,7 @@ export const loadQuestionnaireListFailure = err => ({ * * @return {function} Thunk which may dispatch LOAD_QLIST_SUCCESS or LOAD_QLIST_FAILURE */ -export const loadQuestionnaireList = (stamp, token) => async dispatch => { +export const loadQuestionnaireList = (stamp, token) => async (dispatch) => { dispatch({ type: LOAD_QLIST, payload: null, @@ -64,7 +64,7 @@ export const loadQuestionnaireList = (stamp, token) => async dispatch => { } }; -export const deleteQuestionnaireList = () => dispatch => { +export const deleteQuestionnaireList = () => (dispatch) => { dispatch({ type: DELETE_QLIST_SUCCESS, }); diff --git a/src/actions/questionnaire.jsx b/src/actions/questionnaire.jsx index 35983758e..b931fd507 100644 --- a/src/actions/questionnaire.jsx +++ b/src/actions/questionnaire.jsx @@ -1,14 +1,13 @@ +import { COMPONENT_TYPE } from '../constants/pogues-constants'; +import { Component } from '../model'; +import { questionnaireRemoteToStores } from '../model/remote-to-stores'; +import * as Questionnaire from '../model/transformations/questionnaire'; import { + deleteQuestionnaire, getQuestionnaire, postQuestionnaire, - deleteQuestionnaire, } from '../utils/remote-api'; -import { uuid, getSupWeight } from '../utils/utils'; -import { questionnaireRemoteToStores } from '../model/remote-to-stores'; - -import * as Questionnaire from '../model/transformations/questionnaire'; -import { Component } from '../model'; -import { COMPONENT_TYPE } from '../constants/pogues-constants'; +import { getSupWeight, uuid } from '../utils/utils'; const { QUESTION, SEQUENCE, QUESTIONNAIRE } = COMPONENT_TYPE; @@ -45,7 +44,7 @@ export const UPDATE_COMPONENT = 'UPDATE_COMPONENT'; * @param {object} update The new values to update in the different stores affected. * @return {object} LOAD_QUESTIONNAIRE_SUCCESS action. */ -export const loadQuestionnaireSuccess = update => ({ +export const loadQuestionnaireSuccess = (update) => ({ type: LOAD_QUESTIONNAIRE_SUCCESS, payload: { update, @@ -86,7 +85,7 @@ export const loadQuestionnaireStart = () => ({ * @param {string} id The questionnaire id. * @return {function} Thunk which may dispatch LOAD_QUESTIONNAIRE_SUCCESS or LOAD_QUESTIONNAIRE_FAILURE */ -export const loadQuestionnaire = (id, token) => async dispatch => { +export const loadQuestionnaire = (id, token) => async (dispatch) => { dispatch(loadQuestionnaireStart()); dispatch({ type: LOAD_QUESTIONNAIRE, @@ -127,7 +126,7 @@ export const createQuestionnaireSuccess = (id, update) => ({ * @param {string} err The error returned for the creation process. * @return {object} CREATE_QUESTIONNAIRE_FAILURE action */ -export const createQuestionnaireFailure = err => ({ +export const createQuestionnaireFailure = (err) => ({ type: CREATE_QUESTIONNAIRE_FAILURE, payload: err, }); @@ -174,12 +173,12 @@ export const createQuestionnaire = ), ); }) - .catch(err => { + .catch((err) => { return dispatch(createQuestionnaireFailure(err)); }); }; -export const removeQuestionnaireSuccess = payload => ({ +export const removeQuestionnaireSuccess = (payload) => ({ type: DELETE_QUESTIONNAIRE_SUCCESS, payload, }); @@ -214,29 +213,30 @@ export const removeQuestionnaire = .then(() => { return dispatch(removeQuestionnaireSuccess(questionnairesList)); }) - .catch(err => { + .catch((err) => { return dispatch(removeQuestionnaireFailure(idQuestionnaire, err)); }); }; -export const duplicateQuestionnaire = (idQuestionnaire, token) => dispatch => { - getQuestionnaire(idQuestionnaire, token).then(question => { - question.id = uuid(); - question.Label[0] += ' Copie'; - return postQuestionnaire(question, token) - .then(() => { - return dispatch( - createQuestionnaireSuccess( - question.id, - questionnaireRemoteToStores(question), - ), - ); - }) - .catch(err => { - return dispatch(createQuestionnaireFailure(err)); - }); - }); -}; +export const duplicateQuestionnaire = + (idQuestionnaire, token) => (dispatch) => { + getQuestionnaire(idQuestionnaire, token).then((question) => { + question.id = uuid(); + question.Label[0] += ' Copie'; + return postQuestionnaire(question, token) + .then(() => { + return dispatch( + createQuestionnaireSuccess( + question.id, + questionnaireRemoteToStores(question), + ), + ); + }) + .catch((err) => { + return dispatch(createQuestionnaireFailure(err)); + }); + }); + }; /** * Method used when we click on merge question to merge 2 questions @@ -258,27 +258,27 @@ export const mergeQuestionnaires = (idMerge, token) => (dispatch, getState) => { payload: idMerge, }); - const manageDuplicateCollectedVariable = mergedCollectedVariable => { - Object.values(collectedVariableByQuestion).forEach(element => { + const manageDuplicateCollectedVariable = (mergedCollectedVariable) => { + Object.values(collectedVariableByQuestion).forEach((element) => { const find = Object.values(element).find( - varib => varib.name === mergedCollectedVariable.name, + (varib) => varib.name === mergedCollectedVariable.name, ); if (find) { mergedCollectedVariable.name = `${mergedCollectedVariable.name}_2`; } }); }; - const manageDuplicateCodeList = mergedCodeList => { + const manageDuplicateCodeList = (mergedCodeList) => { const find = Object.values(activeCodeListsById).find( - element => element.label === mergedCodeList.label, + (element) => element.label === mergedCodeList.label, ); if (find && mergedCodeList.id !== find.id) { mergedCodeList.label = `${mergedCodeList.label}_2`; } }; - const manageDuplicateCalculatedVariable = mergedCalculatedVariable => { + const manageDuplicateCalculatedVariable = (mergedCalculatedVariable) => { const find = Object.values(activeCalculatedVariablesById).find( - element => element.name === mergedCalculatedVariable.name, + (element) => element.name === mergedCalculatedVariable.name, ); if (find) { mergedCalculatedVariable.name = `${mergedCalculatedVariable.name}_2`; @@ -287,9 +287,9 @@ export const mergeQuestionnaires = (idMerge, token) => (dispatch, getState) => { activeCalculatedVariablesById[mergedCalculatedVariable.id] = mergedCalculatedVariable; }; - const manageDuplicateExternalVariable = mergedExternalVariable => { + const manageDuplicateExternalVariable = (mergedExternalVariable) => { const find = Object.values(activeExternalVariablesById).find( - element => element.name === mergedExternalVariable.name, + (element) => element.name === mergedExternalVariable.name, ); if (find) { mergedExternalVariable.name = `${mergedExternalVariable.name}_2`; @@ -308,17 +308,17 @@ export const mergeQuestionnaires = (idMerge, token) => (dispatch, getState) => { addedWeight, ) => { const findName = Object.values(activeComponentsById).find( - active => active.name === mergedComponent.name, + (active) => active.name === mergedComponent.name, ); if (findName) { mergedComponent.name = `${mergedComponent.name}_2`; } const findId = Object.values(activeComponentsById).find( - active => active.id === mergedComponent.id, + (active) => active.id === mergedComponent.id, ); if (findId) { mergedComponent.id = uuid(); - Object.values(mergedComponentByQuestionnaire).forEach(element => { + Object.values(mergedComponentByQuestionnaire).forEach((element) => { if (element.parent === findId.id) { element.parent = mergedComponent.id; } @@ -368,9 +368,9 @@ export const mergeQuestionnaires = (idMerge, token) => (dispatch, getState) => { } else { if (mergedComponent.type === QUESTION) { mergedComponent.collectedVariables = - mergedComponent.collectedVariables.map(variable => { + mergedComponent.collectedVariables.map((variable) => { const find = Object.values(mergedCollectedVariables).find( - element => element.id === variable, + (element) => element.id === variable, ); const newId = uuid(); find.id = newId; @@ -378,7 +378,7 @@ export const mergeQuestionnaires = (idMerge, token) => (dispatch, getState) => { return newId; }); // We change Id of the responseFormat (to deal with the case of the fusion of questionnaires sharing the same ids (duplication)) - Object.values(mergedComponent.responseFormat).forEach(resp => { + Object.values(mergedComponent.responseFormat).forEach((resp) => { if (resp?.id) resp.id = uuid(); }); } @@ -403,7 +403,7 @@ export const mergeQuestionnaires = (idMerge, token) => (dispatch, getState) => { } }; - return getQuestionnaire(idMerge, token).then(qr => { + return getQuestionnaire(idMerge, token).then((qr) => { const mergedQuestionnaire = questionnaireRemoteToStores(qr); const mergedQuestionnaireId = Object.keys( mergedQuestionnaire.questionnaireById, @@ -425,24 +425,24 @@ export const mergeQuestionnaires = (idMerge, token) => (dispatch, getState) => { const mergedComponentByQuestionnaire = mergedQuestionnaire.componentByQuestionnaire[mergedQuestionnaireId]; const QuestionnaireId = activeQuestionnaire.id; - Object.values(mergedCollectedVariables).forEach(variable => + Object.values(mergedCollectedVariables).forEach((variable) => manageDuplicateCollectedVariable(variable), ); - Object.values(mergedCodeListByQuestionnaire).forEach(codelist => + Object.values(mergedCodeListByQuestionnaire).forEach((codelist) => manageDuplicateCodeList(codelist), ); - Object.values(mergedCalculatedVariableByQuestionnaire).forEach(variable => + Object.values(mergedCalculatedVariableByQuestionnaire).forEach((variable) => manageDuplicateCalculatedVariable(variable), ); - Object.values(mergedExternalVariableByQuestionnaire).forEach(variable => + Object.values(mergedExternalVariableByQuestionnaire).forEach((variable) => manageDuplicateExternalVariable(variable), ); Object.values(mergedComponentByQuestionnaire) .filter( - element => + (element) => element.type !== QUESTIONNAIRE && element.id !== 'idendquest', ) - .forEach(component => { + .forEach((component) => { manageComponentOnMerge( component, QuestionnaireId, diff --git a/src/actions/search.jsx b/src/actions/search.jsx index f4aa6b98d..80c9db0d2 100644 --- a/src/actions/search.jsx +++ b/src/actions/search.jsx @@ -1,10 +1,10 @@ +import { getSearchResults } from '../utils/remote-api'; + export const LOAD_SEARCH_RESULT = 'LOAD_SEARCH_RESULT'; export const LOAD_SEARCH_RESULT_SUCCESS = 'LOAD_SEARCH_RESULT_SUCCESS'; export const LOAD_SEARCH_RESULT_FAILURE = 'LOAD_SEARCH_RESULT_FAILURE'; export const CLEAR_SEARCH_RESULTS = 'CLEAR_SEARCH_RESULTS'; -import { getSearchResults } from '../utils/remote-api'; - /** * Clear search result list * @@ -25,7 +25,7 @@ export const clearSearchResult = () => ({ * @param {string} resultsList The list of results found. * @return {object} LOAD_SEARCH_RESULT_SUCCESS action */ -export const loadSearchResultSuccess = resultsList => ({ +export const loadSearchResultSuccess = (resultsList) => ({ type: LOAD_SEARCH_RESULT_SUCCESS, payload: resultsList, }); @@ -38,7 +38,7 @@ export const loadSearchResultSuccess = resultsList => ({ * @param {string} err The error returned for the fetch process. * @return {object} LOAD_SEARCH_RESULT_FAILURE action */ -export const loadSearchResultFailure = err => ({ +export const loadSearchResultFailure = (err) => ({ type: LOAD_SEARCH_RESULT_FAILURE, payload: err, }); @@ -52,12 +52,12 @@ export const loadSearchResultFailure = err => ({ * @return {object} LOAD_SEARCH_RESULT action */ export const loadSearchResult = - (token, typeItem, criterias, filter) => dispatch => { + (token, typeItem, criterias, filter) => (dispatch) => { dispatch({ type: LOAD_SEARCH_RESULT, payload: null, }); return getSearchResults(token, typeItem, criterias, filter) - .then(resultsList => dispatch(loadSearchResultSuccess(resultsList))) - .catch(err => dispatch(loadSearchResultFailure(err))); + .then((resultsList) => dispatch(loadSearchResultSuccess(resultsList))) + .catch((err) => dispatch(loadSearchResultFailure(err))); }; diff --git a/src/auth/hoc/hoc.jsx b/src/auth/hoc/hoc.jsx index fe22ab5a2..fed52daf3 100644 --- a/src/auth/hoc/hoc.jsx +++ b/src/auth/hoc/hoc.jsx @@ -1,6 +1,9 @@ import React from 'react'; + import Comp from './component'; -const secure = Component => props => ; +const secure = (Component) => (props) => ( + +); export default secure; diff --git a/src/constants/dictionary.jsx b/src/constants/dictionary.jsx index a7eb05559..170991ef7 100644 --- a/src/constants/dictionary.jsx +++ b/src/constants/dictionary.jsx @@ -1,4 +1,4 @@ -import { COMPONENT_TYPE, CODELISTS_ACTIONS } from './pogues-constants'; +import { CODELISTS_ACTIONS, COMPONENT_TYPE } from './pogues-constants'; const { QUESTION, SEQUENCE, SUBSEQUENCE, LOOP, ROUNDABOUT, FILTER } = COMPONENT_TYPE; diff --git a/src/forms/controls/control-with-suggestions/components/control-with-suggestions.jsx b/src/forms/controls/control-with-suggestions/components/control-with-suggestions.jsx index baf3e606e..bff28e97b 100644 --- a/src/forms/controls/control-with-suggestions/components/control-with-suggestions.jsx +++ b/src/forms/controls/control-with-suggestions/components/control-with-suggestions.jsx @@ -1,18 +1,18 @@ import React, { Component } from 'react'; + import PropTypes from 'prop-types'; -import { fieldInputPropTypes, fieldMetaPropTypes } from 'redux-form'; import ClassSet from 'react-classset'; -import { getValueWithSuggestion, getPattern } from './utils'; +import { fieldInputPropTypes, fieldMetaPropTypes } from 'redux-form'; +import { CONTROL_WITH_SUGGESTIONS } from '../../../../constants/dom-constants'; +import { getKey } from '../../../../utils/widget-utils'; +import { HighLighter } from '../../../../widgets/highlighter'; import { - updateSuggestions, - initialize, getNewIndex, + initialize, + updateSuggestions, } from './input-with-suggestions-utils'; -import { HighLighter } from '../../../../widgets/highlighter'; -import { getKey } from '../../../../utils/widget-utils'; - -import { CONTROL_WITH_SUGGESTIONS } from '../../../../constants/dom-constants'; +import { getPattern, getValueWithSuggestion } from './utils'; const { COMPONENT_CLASS, LIST_CLASS, ITEM_CLASS, ITEM_SELECTED_CLASS } = CONTROL_WITH_SUGGESTIONS; @@ -24,11 +24,8 @@ const InputRegex = new RegExp(/\$(\w+)\b(?!\s)/); export const propTypes = { input: PropTypes.shape(fieldInputPropTypes).isRequired, meta: PropTypes.shape(fieldMetaPropTypes).isRequired, - // eslint-disable-next-line react/no-unused-prop-types label: PropTypes.string.isRequired, - // eslint-disable-next-line react/no-unused-prop-types required: PropTypes.bool, - // eslint-disable-next-line react/no-unused-prop-types disabled: PropTypes.bool, numSuggestionsShown: PropTypes.number, availableSuggestions: PropTypes.arrayOf(PropTypes.string), @@ -75,7 +72,7 @@ class ControlWithSuggestions extends Component { } // OnChange of the input - handleInputChange = value => { + handleInputChange = (value) => { this.setState( updateSuggestions( getPattern(value, this.input.selectionStart), @@ -89,7 +86,7 @@ class ControlWithSuggestions extends Component { }; // OnClick of an item - handleSuggestionClick = suggestion => { + handleSuggestionClick = (suggestion) => { const newValue = getValueWithSuggestion( suggestion, this.input.selectionStart, @@ -104,7 +101,7 @@ class ControlWithSuggestions extends Component { }; // OnKeyDown of the input - handleInputKeyDown = e => { + handleInputKeyDown = (e) => { if (e.key === 'Tab') { this.handleTab(e); } else if (e.key === 'Enter') { @@ -112,7 +109,7 @@ class ControlWithSuggestions extends Component { } }; - handleTab = e => { + handleTab = (e) => { const { numSuggestionsShown } = this.props; const { suggestions, hoveredSuggestionIndex } = this.state; @@ -128,7 +125,7 @@ class ControlWithSuggestions extends Component { } }; - handleEnter = e => { + handleEnter = (e) => { const { suggestions, hoveredSuggestionIndex } = this.state; if (suggestions.length > 0) { @@ -168,7 +165,7 @@ class ControlWithSuggestions extends Component { [ITEM_SELECTED_CLASS]: index === hoveredSuggestionIndex, })} title={suggest} - ref={node => { + ref={(node) => { if (index === hoveredSuggestionIndex) this.activeItem = node; }} diff --git a/src/forms/controls/control-with-suggestions/components/input-with-suggestions-utils.jsx b/src/forms/controls/control-with-suggestions/components/input-with-suggestions-utils.jsx index 4768f499f..1805628cd 100644 --- a/src/forms/controls/control-with-suggestions/components/input-with-suggestions-utils.jsx +++ b/src/forms/controls/control-with-suggestions/components/input-with-suggestions-utils.jsx @@ -3,7 +3,7 @@ export function updateSuggestions(text, regex, availableSuggestions) { let suggestions = []; if (matches) { - suggestions = availableSuggestions.filter(suggestion => + suggestions = availableSuggestions.filter((suggestion) => suggestion.toLowerCase().includes(matches[1].toLocaleLowerCase()), ); } diff --git a/src/forms/controls/control-with-suggestions/components/input-with-suggestions-utils.spec.jsx b/src/forms/controls/control-with-suggestions/components/input-with-suggestions-utils.spec.jsx index 6fa4da957..8cd85ebe8 100644 --- a/src/forms/controls/control-with-suggestions/components/input-with-suggestions-utils.spec.jsx +++ b/src/forms/controls/control-with-suggestions/components/input-with-suggestions-utils.spec.jsx @@ -1,4 +1,5 @@ import { describe, expect, test } from 'vitest'; + import { getNewIndex, initialize, diff --git a/src/forms/controls/control-with-suggestions/components/input-with-suggestions.jsx b/src/forms/controls/control-with-suggestions/components/input-with-suggestions.jsx index e59dbe0b6..5fe50849a 100644 --- a/src/forms/controls/control-with-suggestions/components/input-with-suggestions.jsx +++ b/src/forms/controls/control-with-suggestions/components/input-with-suggestions.jsx @@ -1,9 +1,8 @@ import React from 'react'; -import ControlWithSuggestion from './control-with-suggestions'; - -import { getControlId } from '../../../../utils/widget-utils'; import { CONTROL_INPUT } from '../../../../constants/dom-constants'; +import { getControlId } from '../../../../utils/widget-utils'; +import ControlWithSuggestion from './control-with-suggestions'; const { COMPONENT_CLASS } = CONTROL_INPUT; @@ -42,7 +41,7 @@ class InputWithSuggestions extends ControlWithSuggestion { this.handleInputFocus(); input.onFocus(); }} - ref={node => { + ref={(node) => { this.input = node; }} /> diff --git a/src/forms/controls/control-with-suggestions/components/input-with-suggestions.spec.jsx b/src/forms/controls/control-with-suggestions/components/input-with-suggestions.spec.jsx index a92ddbe49..f8cec8f4e 100644 --- a/src/forms/controls/control-with-suggestions/components/input-with-suggestions.spec.jsx +++ b/src/forms/controls/control-with-suggestions/components/input-with-suggestions.spec.jsx @@ -1,9 +1,9 @@ -import { shallow } from 'enzyme'; import React from 'react'; + +import { shallow } from 'enzyme'; import { describe, expect, test } from 'vitest'; import { fakeFieldProps } from '../../../../utils/test/test-utils'; - import ControlWithSuggestions from './control-with-suggestions'; import InputWithSuggestions from './input-with-suggestions'; diff --git a/src/forms/controls/control-with-suggestions/components/rich-editor.jsx b/src/forms/controls/control-with-suggestions/components/rich-editor.jsx index d8f387762..42bf35119 100644 --- a/src/forms/controls/control-with-suggestions/components/rich-editor.jsx +++ b/src/forms/controls/control-with-suggestions/components/rich-editor.jsx @@ -1,9 +1,8 @@ import React from 'react'; -import VTLEditor from './vtl-editor'; -import RichTextareaWithSuggestions from './rich-textarea-with-suggestions'; - import { FORMULA_LANGUAGE } from '../../../../constants/pogues-constants'; +import RichTextareaWithSuggestions from './rich-textarea-with-suggestions'; +import VTLEditor from './vtl-editor'; const { XPATH, VTL } = FORMULA_LANGUAGE; diff --git a/src/forms/controls/control-with-suggestions/components/rich-textarea-with-suggestions.jsx b/src/forms/controls/control-with-suggestions/components/rich-textarea-with-suggestions.jsx index ce92ffdd9..009167f5b 100644 --- a/src/forms/controls/control-with-suggestions/components/rich-textarea-with-suggestions.jsx +++ b/src/forms/controls/control-with-suggestions/components/rich-textarea-with-suggestions.jsx @@ -1,22 +1,22 @@ -import { EditorState, Modifier, getDefaultKeyBinding } from 'draft-js'; -import PropTypes from 'prop-types'; import React from 'react'; + +import { EditorState, Modifier, getDefaultKeyBinding } from 'draft-js'; import RichTextEditor from 'gillespie59-react-rte/dist/react-rte'; -import ControlWithSuggestion from './control-with-suggestions'; -import { updateSuggestions } from './input-with-suggestions-utils'; -import { getPattern, getStartValueWithSuggestion } from './utils'; +import PropTypes from 'prop-types'; +import { CONTROL_RICH_TEXTAREA } from '../../../../constants/dom-constants'; +import { getControlId } from '../../../../utils/widget-utils'; import { contentStateToString, formatURL, getEditorValue, + rootStyle, toolbarConfig, toolbarConfigQuestion, - rootStyle, } from '../../rich-textarea'; - -import { CONTROL_RICH_TEXTAREA } from '../../../../constants/dom-constants'; -import { getControlId } from '../../../../utils/widget-utils'; +import ControlWithSuggestion from './control-with-suggestions'; +import { updateSuggestions } from './input-with-suggestions-utils'; +import { getPattern, getStartValueWithSuggestion } from './utils'; const { COMPONENT_CLASS } = CONTROL_RICH_TEXTAREA; @@ -80,7 +80,7 @@ class RichTextareaWithSuggestions extends ControlWithSuggestion { } } - handleChange = value => { + handleChange = (value) => { const editorState = value.getEditorState(); const contentState = editorState.getCurrentContent(); const transformedValue = contentStateToString(contentState); @@ -110,7 +110,7 @@ class RichTextareaWithSuggestions extends ControlWithSuggestion { this.props.input.onChange(transformedValue); }; - handleReturn = e => { + handleReturn = (e) => { if (this.props.submitOnEnter) { e.preventDefault(); e.target.closest('form').querySelector('button[type=submit]').click(); @@ -124,7 +124,7 @@ class RichTextareaWithSuggestions extends ControlWithSuggestion { this.setState({ value, currentValue }); } - handleSuggestionClick = suggestion => { + handleSuggestionClick = (suggestion) => { const caretCursor = this.state.value .getEditorState() .getSelection() @@ -169,7 +169,7 @@ class RichTextareaWithSuggestions extends ControlWithSuggestion { this.textChange(this.state.value.setEditorState(newEditorState)); }; - handleKeyCommand = command => { + handleKeyCommand = (command) => { if (command === 'myeditor-save') { return 'handled'; } @@ -208,7 +208,7 @@ class RichTextareaWithSuggestions extends ControlWithSuggestion { this.handleInputFocus(); input.onFocus(); }} - ref={node => { + ref={(node) => { this.input = node; }} handleKeyCommand={this.handleKeyCommand} diff --git a/src/forms/controls/control-with-suggestions/components/simple-editor.jsx b/src/forms/controls/control-with-suggestions/components/simple-editor.jsx index 9f163e158..be5236e80 100644 --- a/src/forms/controls/control-with-suggestions/components/simple-editor.jsx +++ b/src/forms/controls/control-with-suggestions/components/simple-editor.jsx @@ -1,9 +1,8 @@ import React from 'react'; -import VTLEditor from './vtl-editor'; -import TextareaWithSuggestions from './textarea-with-suggestions'; - import { FORMULA_LANGUAGE } from '../../../../constants/pogues-constants'; +import TextareaWithSuggestions from './textarea-with-suggestions'; +import VTLEditor from './vtl-editor'; const { XPATH, VTL } = FORMULA_LANGUAGE; diff --git a/src/forms/controls/control-with-suggestions/components/textarea-with-suggestions.jsx b/src/forms/controls/control-with-suggestions/components/textarea-with-suggestions.jsx index 01fb99b07..363cb645b 100644 --- a/src/forms/controls/control-with-suggestions/components/textarea-with-suggestions.jsx +++ b/src/forms/controls/control-with-suggestions/components/textarea-with-suggestions.jsx @@ -1,9 +1,8 @@ import React from 'react'; -import ControlWithSuggestion from './control-with-suggestions'; - -import { getControlId } from '../../../../utils/widget-utils'; import { CONTROL_TEXTAREA } from '../../../../constants/dom-constants'; +import { getControlId } from '../../../../utils/widget-utils'; +import ControlWithSuggestion from './control-with-suggestions'; const { COMPONENT_CLASS } = CONTROL_TEXTAREA; @@ -40,7 +39,7 @@ class TextareaWithSuggestions extends ControlWithSuggestion { this.handleInputFocus(); input.onFocus(); }} - ref={node => { + ref={(node) => { this.input = node; }} /> diff --git a/src/forms/controls/control-with-suggestions/components/textarea-with-suggestions.spec.jsx b/src/forms/controls/control-with-suggestions/components/textarea-with-suggestions.spec.jsx index 7881b9b87..f43839e21 100644 --- a/src/forms/controls/control-with-suggestions/components/textarea-with-suggestions.spec.jsx +++ b/src/forms/controls/control-with-suggestions/components/textarea-with-suggestions.spec.jsx @@ -1,9 +1,9 @@ -import { shallow } from 'enzyme'; import React from 'react'; + +import { shallow } from 'enzyme'; import { describe, expect, test } from 'vitest'; import { fakeFieldProps } from '../../../../utils/test/test-utils'; - import ControlWithSuggestions from './control-with-suggestions'; import TextareaWithSuggestions from './textarea-with-suggestions'; diff --git a/src/forms/controls/control-with-suggestions/components/utils.spec.jsx b/src/forms/controls/control-with-suggestions/components/utils.spec.jsx index 17ee272ed..18d64a196 100644 --- a/src/forms/controls/control-with-suggestions/components/utils.spec.jsx +++ b/src/forms/controls/control-with-suggestions/components/utils.spec.jsx @@ -1,4 +1,5 @@ import { describe, expect, test } from 'vitest'; + import { getPattern, getValueWithSuggestion } from './utils'; describe('getPattern', () => { diff --git a/src/forms/controls/control-with-suggestions/components/vtl-editor.jsx b/src/forms/controls/control-with-suggestions/components/vtl-editor.jsx index 1a23062ea..a216867f9 100644 --- a/src/forms/controls/control-with-suggestions/components/vtl-editor.jsx +++ b/src/forms/controls/control-with-suggestions/components/vtl-editor.jsx @@ -1,11 +1,10 @@ -/* eslint-disable no-console */ import React, { useState } from 'react'; -import { AntlrEditor } from '@making-sense/antlr-editor'; +import { AntlrEditor } from '@making-sense/antlr-editor'; import * as tools from '@making-sense/vtl-2-0-antlr-tools-ts'; import { - monarchDefinition, getSuggestionsFromRange, + monarchDefinition, } from '@making-sense/vtl-2-0-monaco-tools-ts'; import { CONTROL_VTL_EDITOR } from '../../../../constants/dom-constants'; @@ -37,7 +36,7 @@ const VTLEditor = ({ const { value, onChange, name: id } = input; - const handleErrors = e => { + const handleErrors = (e) => { setErrors(e); if (setDisableValidation) { if (e.length > 0) setDisableValidation(true); @@ -45,7 +44,7 @@ const VTLEditor = ({ } }; - const localOnChange = e => { + const localOnChange = (e) => { onChange(e); if (!e) { if (setDisableValidation) { diff --git a/src/forms/controls/control-with-suggestions/containers/control-with-suggestions-container.jsx b/src/forms/controls/control-with-suggestions/containers/control-with-suggestions-container.jsx index 248abeece..592cf32a5 100644 --- a/src/forms/controls/control-with-suggestions/containers/control-with-suggestions-container.jsx +++ b/src/forms/controls/control-with-suggestions/containers/control-with-suggestions-container.jsx @@ -1,10 +1,9 @@ import withCurrentFormVariables from '../../../../hoc/with-current-form-variables'; - import InputWithSuggestions from '../components/input-with-suggestions'; -import TextareaWithSuggestions from '../components/textarea-with-suggestions'; -import RichTextareaWithSuggestions from '../components/rich-textarea-with-suggestions'; import RichEditor from '../components/rich-editor'; +import RichTextareaWithSuggestions from '../components/rich-textarea-with-suggestions'; import SimpleEditor from '../components/simple-editor'; +import TextareaWithSuggestions from '../components/textarea-with-suggestions'; export const InputWithSuggestionsContainer = withCurrentFormVariables(InputWithSuggestions); diff --git a/src/forms/controls/generic-option.jsx b/src/forms/controls/generic-option.jsx index b58ba99cc..9e5fda730 100644 --- a/src/forms/controls/generic-option.jsx +++ b/src/forms/controls/generic-option.jsx @@ -1,4 +1,5 @@ import React from 'react'; + import PropTypes from 'prop-types'; // PropTypes and defaultProps diff --git a/src/forms/controls/generic-option.spec.jsx b/src/forms/controls/generic-option.spec.jsx index 2b5469109..17a58093e 100644 --- a/src/forms/controls/generic-option.spec.jsx +++ b/src/forms/controls/generic-option.spec.jsx @@ -1,4 +1,5 @@ import React from 'react'; + import renderer from 'react-test-renderer'; import { describe, expect, test } from 'vitest'; diff --git a/src/forms/controls/input-autocomplete/input-autocomplete-utils.jsx b/src/forms/controls/input-autocomplete/input-autocomplete-utils.jsx index 477e69118..5f7660e53 100644 --- a/src/forms/controls/input-autocomplete/input-autocomplete-utils.jsx +++ b/src/forms/controls/input-autocomplete/input-autocomplete-utils.jsx @@ -18,7 +18,7 @@ export function setSuggestions( const flags = caseSensitive ? 'g' : 'gi'; const regEx = new RegExp(withText, flags); filteredSuggestions = options - .filter(o => getOptionLabel(o.label, o.value).search(regEx) !== -1) + .filter((o) => getOptionLabel(o.label, o.value).search(regEx) !== -1) .splice(0, numSuggestionsShown); } @@ -30,7 +30,7 @@ export function setSuggestions( } export function init(options, value) { - const indexSelectedOption = options.map(o => o.value).indexOf(value); + const indexSelectedOption = options.map((o) => o.value).indexOf(value); const selectedOption = options[indexSelectedOption] || {}; return { diff --git a/src/forms/controls/input-autocomplete/input-autocomplete-utils.spec.jsx b/src/forms/controls/input-autocomplete/input-autocomplete-utils.spec.jsx index 2e3a8bedc..6e1faa97c 100644 --- a/src/forms/controls/input-autocomplete/input-autocomplete-utils.spec.jsx +++ b/src/forms/controls/input-autocomplete/input-autocomplete-utils.spec.jsx @@ -27,7 +27,7 @@ describe('Form controls - Input autocomplete - Utils', () => { }); test('setSuggestions', () => { - const getOptionLabel = label => { + const getOptionLabel = (label) => { return label; }; const getOptionName = (label, name) => { diff --git a/src/forms/controls/input-autocomplete/input-autocomplete.jsx b/src/forms/controls/input-autocomplete/input-autocomplete.jsx index 5cf289be8..259461ba2 100644 --- a/src/forms/controls/input-autocomplete/input-autocomplete.jsx +++ b/src/forms/controls/input-autocomplete/input-autocomplete.jsx @@ -1,25 +1,25 @@ import React, { Component } from 'react'; -import { fieldInputPropTypes, fieldMetaPropTypes } from 'redux-form'; + +import debounce from 'lodash.debounce'; import PropTypes from 'prop-types'; import ClassSet from 'react-classset'; -import debounce from 'lodash.debounce'; +import { fieldInputPropTypes, fieldMetaPropTypes } from 'redux-form'; +import { CONTROL_INPUT_AUTOCOMPLETE } from '../../../constants/dom-constants'; +import { + getControlId, + getValuesFromGenericOptions, +} from '../../../utils/widget-utils'; +import { HighLighter } from '../../../widgets/highlighter'; import { clearSuggestions, - setSuggestions, + init, moveDown, moveUp, + setSuggestions, updateSelectedOption, - init, } from './input-autocomplete-utils'; -import { - getControlId, - getValuesFromGenericOptions, -} from '../../../utils/widget-utils'; -import { HighLighter } from '../../../widgets/highlighter'; -import { CONTROL_INPUT_AUTOCOMPLETE } from '../../../constants/dom-constants'; - const { COMPONENT_CLASS, BUTTON_CLEAR_CLASS, @@ -46,7 +46,7 @@ export const defaultProps = { required: false, children: [], numSuggestionsShown: 10, - getOptionLabel: label => { + getOptionLabel: (label) => { return label; }, caseSensitive: true, @@ -97,7 +97,6 @@ class InputAutocomplete extends Component { } = nextProps; if (value !== this.props.input.value) { - // eslint-disable-next-line react/no-will-update-set-state this.setState(init(getValuesFromGenericOptions(children), value)); } } @@ -189,7 +188,7 @@ class InputAutocomplete extends Component { value={this.state.inputSearch} className="form-control" type="text" - onKeyDown={event => { + onKeyDown={(event) => { // In this way the form submit is avoided if (event.key === 'Enter') event.preventDefault(); }} @@ -198,15 +197,14 @@ class InputAutocomplete extends Component { this.setState({ showSuggestions: true }); }} onBlur={debounce(this.onBlur, 500)} - onChange={event => { + onChange={(event) => { this.setState({ inputSearch: event.currentTarget.value }); }} - ref={node => { + ref={(node) => { this.input = node; }} /> {value && ( - // eslint-disable-next-line jsx-a11y/no-static-element-interactions
{ @@ -222,30 +220,25 @@ class InputAutocomplete extends Component { {suggestions.length > 0 && (
    - {suggestions.map( - ( - su, - index, // eslint-disable-next-line jsx-a11y/no-static-element-interactions - ) => ( -
  • { - this.onClick(index); - }} + {suggestions.map((su, index) => ( +
  • { + this.onClick(index); + }} + > + - - {this.props.getOptionLabel(su.label, su.value)} - -
  • - ), - )} + {this.props.getOptionLabel(su.label, su.value)} + + + ))}
)} {touched && error && {error}} diff --git a/src/forms/controls/input-autocomplete/input-autocomplete.spec.jsx b/src/forms/controls/input-autocomplete/input-autocomplete.spec.jsx index cafe0dad9..c67be10e6 100644 --- a/src/forms/controls/input-autocomplete/input-autocomplete.spec.jsx +++ b/src/forms/controls/input-autocomplete/input-autocomplete.spec.jsx @@ -1,6 +1,8 @@ -import { shallow } from 'enzyme'; import React from 'react'; + +import { shallow } from 'enzyme'; import { beforeEach, describe, expect, test } from 'vitest'; + import { fakeEvent, fakeFieldProps } from '../../../utils/test/test-utils'; import GenericOption from '../generic-option'; import InputAutocomplete from './input-autocomplete'; diff --git a/src/forms/controls/input.jsx b/src/forms/controls/input.jsx index 69d6ec750..9e2f520fb 100644 --- a/src/forms/controls/input.jsx +++ b/src/forms/controls/input.jsx @@ -1,9 +1,10 @@ import React, { Component } from 'react'; + import PropTypes from 'prop-types'; import { fieldInputPropTypes, fieldMetaPropTypes } from 'redux-form'; -import { getControlId } from '../../utils/widget-utils'; import { CONTROL_INPUT } from '../../constants/dom-constants'; +import { getControlId } from '../../utils/widget-utils'; const { COMPONENT_CLASS } = CONTROL_INPUT; @@ -53,9 +54,8 @@ class Input extends Component { required, disabled, input, - reference, + // eslint-disable-next-line no-unused-vars focusOnInit, - onEnter, meta: { touched, error }, ...otherProps } = this.props; @@ -75,10 +75,10 @@ class Input extends Component { id={id} placeholder={placeholder !== '' || label} disabled={disabled} - ref={node => { + ref={(node) => { this.input = node; }} - onKeyPress={event => { + onKeyPress={(event) => { if (event.charCode === 13 && this.props.onEnter) { this.props.onEnter(event); } diff --git a/src/forms/controls/input.spec.jsx b/src/forms/controls/input.spec.jsx index fa765eda4..4129e217f 100644 --- a/src/forms/controls/input.spec.jsx +++ b/src/forms/controls/input.spec.jsx @@ -1,6 +1,8 @@ -import { shallow } from 'enzyme'; import React from 'react'; + +import { shallow } from 'enzyme'; import { beforeEach, describe, expect, test } from 'vitest'; + import { fakeFieldProps } from '../../utils/test/test-utils'; import Input from './input'; diff --git a/src/forms/controls/list-checkboxes.jsx b/src/forms/controls/list-checkboxes.jsx index b9d844a04..2d9f7ab91 100644 --- a/src/forms/controls/list-checkboxes.jsx +++ b/src/forms/controls/list-checkboxes.jsx @@ -1,16 +1,16 @@ import React, { Component } from 'react'; + import PropTypes from 'prop-types'; +import ClassSet from 'react-classset'; import { fieldInputPropTypes, fieldMetaPropTypes } from 'redux-form'; +import { CONTROL_LIST_CHECKBOXES } from '../../constants/dom-constants'; import { getControlId, getValuesFromGenericOptions, toggleValueInList, } from '../../utils/widget-utils'; -import { CONTROL_LIST_CHECKBOXES } from '../../constants/dom-constants'; -import ClassSet from 'react-classset'; - const { COMPONENT_CLASS, INLINE_MODE } = CONTROL_LIST_CHECKBOXES; // PropTypes and defaultProps @@ -62,7 +62,6 @@ class ListCheckboxes extends Component { UNSAFE_componentWillUpdate(nextProps) { const values = nextProps.input.value; if (this.props.input.value !== values) { - // eslint-disable-next-line react/no-will-update-set-state this.setState({ listCheckValues: values !== '' && values.length > 0 ? values.split(',') : [], @@ -110,8 +109,7 @@ class ListCheckboxes extends Component {
)} - {values.map(val => { - // eslint-disable-next-line no-shadow + {values.map((val) => { const { label, value, ...otherProps } = val; const id = getControlId('checkbox', input.name, value); diff --git a/src/forms/controls/list-checkboxes.spec.jsx b/src/forms/controls/list-checkboxes.spec.jsx index fc487c37a..69cb7b91e 100644 --- a/src/forms/controls/list-checkboxes.spec.jsx +++ b/src/forms/controls/list-checkboxes.spec.jsx @@ -1,6 +1,8 @@ -import { shallow } from 'enzyme'; import React from 'react'; + +import { shallow } from 'enzyme'; import { beforeEach, describe, expect, test, vi } from 'vitest'; + import { fakeEvent, fakeFieldProps } from '../../utils/test/test-utils'; import GenericOption from './generic-option'; import ListCheckboxes from './list-checkboxes'; diff --git a/src/forms/controls/list-radios.jsx b/src/forms/controls/list-radios.jsx index 3d7aaf5a5..eb009318a 100644 --- a/src/forms/controls/list-radios.jsx +++ b/src/forms/controls/list-radios.jsx @@ -1,11 +1,13 @@ import React from 'react'; + import PropTypes from 'prop-types'; import { fieldInputPropTypes, fieldMetaPropTypes } from 'redux-form'; + +import { CONTROL_LIST_RADIOS } from '../../constants/dom-constants'; import { getControlId, getValuesFromGenericOptions, } from '../../utils/widget-utils'; -import { CONTROL_LIST_RADIOS } from '../../constants/dom-constants'; const { COMPONENT_CLASS } = CONTROL_LIST_RADIOS; @@ -34,7 +36,7 @@ function ListRadios({ )} - {values.map(val => { + {values.map((val) => { const { label: radioLabel, value, ...otherProps } = val; const id = getControlId('radios', input.name, value); diff --git a/src/forms/controls/rich-textarea/decorators/rich-textarea-condition.jsx b/src/forms/controls/rich-textarea/decorators/rich-textarea-condition.jsx index 2b27ce975..6e9f4f108 100644 --- a/src/forms/controls/rich-textarea/decorators/rich-textarea-condition.jsx +++ b/src/forms/controls/rich-textarea/decorators/rich-textarea-condition.jsx @@ -1,4 +1,5 @@ import React from 'react'; + import PropTypes from 'prop-types'; // PropTypes and defaultProps diff --git a/src/forms/controls/rich-textarea/decorators/rich-textarea-decorators.jsx b/src/forms/controls/rich-textarea/decorators/rich-textarea-decorators.jsx index b303f371f..176d29632 100644 --- a/src/forms/controls/rich-textarea/decorators/rich-textarea-decorators.jsx +++ b/src/forms/controls/rich-textarea/decorators/rich-textarea-decorators.jsx @@ -1,4 +1,5 @@ import { CompositeDecorator } from 'draft-js'; + import RichTextareaCondition from './rich-textarea-condition'; import RichTextareaLink from './rich-textarea-link'; @@ -6,7 +7,7 @@ import RichTextareaLink from './rich-textarea-link'; export function findEntities(type) { return function findEntitiesCurried(contentBlock, callback, contentState) { - contentBlock.findEntityRanges(character => { + contentBlock.findEntityRanges((character) => { const entityKey = character.getEntity(); if (entityKey != null) { const entity = contentState ? contentState.getEntity(entityKey) : null; diff --git a/src/forms/controls/rich-textarea/decorators/rich-textarea-link.jsx b/src/forms/controls/rich-textarea/decorators/rich-textarea-link.jsx index 7967dff2c..c97f61dbc 100644 --- a/src/forms/controls/rich-textarea/decorators/rich-textarea-link.jsx +++ b/src/forms/controls/rich-textarea/decorators/rich-textarea-link.jsx @@ -1,4 +1,5 @@ import React from 'react'; + import PropTypes from 'prop-types'; // PropTypes and defaultProps diff --git a/src/forms/controls/rich-textarea/lib/markdown-vtl-parser.jsx b/src/forms/controls/rich-textarea/lib/markdown-vtl-parser.jsx index 5f5b561b9..826c4ee51 100644 --- a/src/forms/controls/rich-textarea/lib/markdown-vtl-parser.jsx +++ b/src/forms/controls/rich-textarea/lib/markdown-vtl-parser.jsx @@ -1,15 +1,3 @@ -/* eslint-disable block-scoped-var */ -/* eslint-disable no-var */ -/* eslint-disable vars-on-top */ -/* eslint-disable default-case */ -/* eslint-disable consistent-return */ -/* eslint-disable no-return-assign */ -/* eslint-disable no-bitwise */ -/* eslint-disable no-continue */ -/* eslint-disable no-cond-assign */ -/* eslint-disable prefer-object-spread */ -/* eslint-disable no-restricted-syntax */ -/* eslint-disable prefer-rest-params */ /** * Ported from: * https://github.com/chjj/marked/blob/49b7eaca/lib/marked.js @@ -17,12 +5,11 @@ * Use ES6 classes * Add flow annotations */ - import { - TextNode, ElementNode, FragmentNode, SELF_CLOSING, + TextNode, } from 'synthetic-dom'; const hasOwnProperty = Object.prototype.hasOwnProperty; @@ -105,7 +92,7 @@ block.normal = assign({}, block); */ block.gfm = assign({}, block.normal, { - fences: /^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]+?)\s*\1 *(?:\n+|$)/, + fences: /^ *(`{3,}|~{3,})[ .]*(\S+)? *\n([\s\S]+?)\s*\1 *(?:\n+|$)/, paragraph: /^/, heading: /^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/, }); @@ -386,21 +373,21 @@ Lexer.prototype.token = function (src, top, bq) { */ const inline = { - escape: /^\\([\\`*{}\[\]()#+\-.!_>])/, + escape: /^\\([\\`*{}[\]()#+\-.!_>])/, link: /^!?\[(inside)\]\(href\)/, condition: /^##{"label": "(inside)", "conditions": (inside)}.+#end/, reflink: /^!?\[(inside)\]\s*\[([^\]]*)\]/, - nolink: /^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/, + nolink: /^!?\[((?:\[[^\]]*\]|[^[\]])*)\]/, strong: /^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/, em: /^\b_((?:__|[\s\S])+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/, code: /^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/, br: /^ {2,}\n(?!\s*$)/, del: noop, ins: noop, - text: /^[\s\S]+?(?=[\\?(?:\s+['"]([\s\S]*?)['"])?\s*/; inline._conditions = /\s*?(?:\s+['"]([\s\S]*?)['"])?\s*/; @@ -875,7 +862,7 @@ function replace(regex, options) { return new RegExp(regex, options); } val = val.source || val; - val = val.replace(/(^|[^\[])\^/g, '$1'); + val = val.replace(/(^|[^[])\^/g, '$1'); regex = regex.replace(name, val); return self; }; diff --git a/src/forms/controls/rich-textarea/lib/state-from-markdown-vtl.jsx b/src/forms/controls/rich-textarea/lib/state-from-markdown-vtl.jsx index c00352fa0..1a4ad7348 100644 --- a/src/forms/controls/rich-textarea/lib/state-from-markdown-vtl.jsx +++ b/src/forms/controls/rich-textarea/lib/state-from-markdown-vtl.jsx @@ -1,6 +1,7 @@ -import MarkdownParser from './markdown-vtl-parser'; import { stateFromElement } from 'draft-js-import-element'; +import MarkdownParser from './markdown-vtl-parser'; + export default function stateFromMarkdown(markdown) { const elementMarkdown = MarkdownParser.parse(markdown, { getAST: true }); diff --git a/src/forms/controls/rich-textarea/lib/state-to-markdown-vtl.jsx b/src/forms/controls/rich-textarea/lib/state-to-markdown-vtl.jsx index 1a23309cd..dac68b298 100644 --- a/src/forms/controls/rich-textarea/lib/state-to-markdown-vtl.jsx +++ b/src/forms/controls/rich-textarea/lib/state-to-markdown-vtl.jsx @@ -1,8 +1,8 @@ import { - getEntityRanges, BLOCK_TYPE, ENTITY_TYPE, INLINE_STYLE, + getEntityRanges, } from 'draft-js-utils'; const { BOLD, CODE, ITALIC, STRIKETHROUGH, UNDERLINE } = INLINE_STYLE; diff --git a/src/forms/controls/rich-textarea/utils/rich-textarea-utils.jsx b/src/forms/controls/rich-textarea/utils/rich-textarea-utils.jsx index 1682b9d42..de7963146 100644 --- a/src/forms/controls/rich-textarea/utils/rich-textarea-utils.jsx +++ b/src/forms/controls/rich-textarea/utils/rich-textarea-utils.jsx @@ -1,7 +1,7 @@ -import EditorValue from 'gillespie59-react-rte/lib/lib/EditorValue'; import { EditorState } from 'draft-js'; -import decorators from '../decorators/rich-textarea-decorators'; +import EditorValue from 'gillespie59-react-rte/lib/lib/EditorValue'; +import decorators from '../decorators/rich-textarea-decorators'; import stateFromMarkdownVtl from '../lib/state-from-markdown-vtl'; import stateToMarkdownVtl from '../lib/state-to-markdown-vtl'; diff --git a/src/forms/controls/select.jsx b/src/forms/controls/select.jsx index 761bd3766..715710ff0 100644 --- a/src/forms/controls/select.jsx +++ b/src/forms/controls/select.jsx @@ -1,12 +1,13 @@ import React, { Component } from 'react'; + import PropTypes from 'prop-types'; import { fieldInputPropTypes, fieldMetaPropTypes } from 'redux-form'; +import { CONTROL_SELECT } from '../../constants/dom-constants'; import { getControlId, getValuesFromGenericOptions, } from '../../utils/widget-utils'; -import { CONTROL_SELECT } from '../../constants/dom-constants'; const { COMPONENT_CLASS } = CONTROL_SELECT; @@ -71,13 +72,12 @@ class Select extends Component { placeholder={label} disabled={disabled} multiple={multiple} - ref={node => { + ref={(node) => { this.input = node; }} > {emptyOption && } - {values.map(val => { - // eslint-disable-next-line no-shadow + {values.map((val) => { const { label, value, ...otherProps } = val; return (