From a6dfc16b9cd6ebf56da14b532ccca728550cb0d8 Mon Sep 17 00:00:00 2001 From: Maciej Barelkowski Date: Fri, 11 Oct 2024 15:22:39 +0200 Subject: [PATCH] WIP: migrate to eslint@9 --- .eslintignore | 3 -- eslint.config.mjs | 43 +++++++++++++++++++ package-lock.json | 18 +++++--- package.json | 2 +- .../editor/components/InputCell.js | 2 +- .../editor/components/OutputCell.js | 2 +- .../src/features/simple-date-edit/Utils.js | 4 +- .../features/simple-date-time-edit/Utils.js | 6 +-- .../ContextMenuCloseBehaviorSpec.js | 2 +- .../context-menu/ContextMenuKeyboardSpec.js | 2 +- .../features/context-menu/ContextMenuSpec.js | 2 +- .../features/drag-and-drop/DragAndDropSpec.js | 2 +- .../simple-date-edit/SimpleDateEditSpec.js | 6 +-- .../features/simple-date-edit/UtilsSpec.js | 2 +- .../SimpleDateTimeEditSpec.js | 2 +- .../simple-time-edit/SimpleTimeEditSpec.js | 6 +-- .../features/simple-time-edit/UtilsSpec.js | 2 +- .../src/components/ContentEditable.js | 6 +-- .../dmn-js-shared/src/components/Input.js | 2 +- .../src/components/InputSelect.js | 4 +- .../src/components/ValidatedInput.js | 2 +- .../test/spec/base/ManagerSpec.js | 2 +- .../spec/components/ValidatedInputSpec.js | 2 +- .../spec/features/data-types/DataTypesSpec.js | 4 +- .../ExpressionLanguagesSpec.js | 16 +++---- 25 files changed, 94 insertions(+), 50 deletions(-) delete mode 100644 .eslintignore create mode 100644 eslint.config.mjs diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 66503ef25..000000000 --- a/.eslintignore +++ /dev/null @@ -1,3 +0,0 @@ -lib -dist -node_modules \ No newline at end of file diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 000000000..ccdb1c04c --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,43 @@ +import bpmnIoPlugin from 'eslint-plugin-bpmn-io'; + +export default [ + { + ignores: [ + '**/lib', + '**/dist' + ] + }, + ...bpmnIoPlugin.configs.browser.map(config => { + return { + ...config, + files: [ + '**/src/**/*.js' + ] + }; + }), + ...bpmnIoPlugin.configs.jsx.map(config => { + return { + ...config, + files: [ + '**/src/**/*.js', + '**/test/**/*.js' + ] + }; + }), + ...bpmnIoPlugin.configs.mocha.map(config => { + return { + ...config, + files: [ + '**/test/**/*.js' + ] + }; + }), + { + rules: { + 'max-len': [ 2, { 'code': 90 } ], + 'no-restricted-imports': [ 2, { + 'patterns': [ 'dmn-js/src', 'dmn-js-*/src' ] + } ] + } + } +]; diff --git a/package-lock.json b/package-lock.json index a973dc9b8..5609b351f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,7 +22,7 @@ "cross-env": "^7.0.3", "del-cli": "^6.0.0", "eslint": "^9.0.0", - "eslint-plugin-bpmn-io": "^2.0.0", + "eslint-plugin-bpmn-io": "^2.0.2", "karma": "^6.4.4", "karma-chrome-launcher": "^3.2.0", "karma-coverage": "^2.2.1", @@ -8465,10 +8465,14 @@ } }, "node_modules/eslint-plugin-bpmn-io": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-bpmn-io/-/eslint-plugin-bpmn-io-2.0.0.tgz", - "integrity": "sha512-BJ1SWzjW3hDRbtDEgyLH4npyksNEuwBpYZZ2HGVI4SZr0miklzAVbGvVeQK0lOyD3Yt+WT6yRpkw8PsJrOMZRA==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-bpmn-io/-/eslint-plugin-bpmn-io-2.0.2.tgz", + "integrity": "sha512-DiRhVFg+uPDn2WNC0pc2/BV8AtCPFz46SXetnLwLsFr+PbPQ70Py57kT8zAY/mbuAh39AXpABUz7J4hkq6N0WQ==", "dev": true, + "license": "MIT", + "workspaces": [ + "test" + ], "dependencies": { "eslint-plugin-mocha": "^10.5.0", "eslint-plugin-react": "^7.35.0", @@ -25780,9 +25784,9 @@ } }, "eslint-plugin-bpmn-io": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-bpmn-io/-/eslint-plugin-bpmn-io-2.0.0.tgz", - "integrity": "sha512-BJ1SWzjW3hDRbtDEgyLH4npyksNEuwBpYZZ2HGVI4SZr0miklzAVbGvVeQK0lOyD3Yt+WT6yRpkw8PsJrOMZRA==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-bpmn-io/-/eslint-plugin-bpmn-io-2.0.2.tgz", + "integrity": "sha512-DiRhVFg+uPDn2WNC0pc2/BV8AtCPFz46SXetnLwLsFr+PbPQ70Py57kT8zAY/mbuAh39AXpABUz7J4hkq6N0WQ==", "dev": true, "requires": { "eslint-plugin-mocha": "^10.5.0", diff --git a/package.json b/package.json index 5221adcb1..8f12f7b26 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "cross-env": "^7.0.3", "del-cli": "^6.0.0", "eslint": "^9.0.0", - "eslint-plugin-bpmn-io": "^2.0.0", + "eslint-plugin-bpmn-io": "^2.0.2", "karma": "^6.4.4", "karma-chrome-launcher": "^3.2.0", "karma-coverage": "^2.2.1", diff --git a/packages/dmn-js-decision-table/src/features/decision-table-head/editor/components/InputCell.js b/packages/dmn-js-decision-table/src/features/decision-table-head/editor/components/InputCell.js index 7a40d7e51..fc00c7f31 100644 --- a/packages/dmn-js-decision-table/src/features/decision-table-head/editor/components/InputCell.js +++ b/packages/dmn-js-decision-table/src/features/decision-table-head/editor/components/InputCell.js @@ -86,7 +86,7 @@ export default class InputCell extends Component { diff --git a/packages/dmn-js-decision-table/src/features/decision-table-head/editor/components/OutputCell.js b/packages/dmn-js-decision-table/src/features/decision-table-head/editor/components/OutputCell.js index 824971793..be7b10794 100644 --- a/packages/dmn-js-decision-table/src/features/decision-table-head/editor/components/OutputCell.js +++ b/packages/dmn-js-decision-table/src/features/decision-table-head/editor/components/OutputCell.js @@ -79,7 +79,7 @@ export default class OutputCell extends Component { diff --git a/packages/dmn-js-decision-table/src/features/simple-date-edit/Utils.js b/packages/dmn-js-decision-table/src/features/simple-date-edit/Utils.js index 75cd81f6d..9ef725123 100644 --- a/packages/dmn-js-decision-table/src/features/simple-date-edit/Utils.js +++ b/packages/dmn-js-decision-table/src/features/simple-date-edit/Utils.js @@ -1,9 +1,9 @@ const ISO_DATE_REGEX = /^\d{4}(?:-\d\d){2}$/; -// eslint-disable-next-line + const BETWEEN_DATE_REGEX = /^\[date\("([^"]*)"\)..date\("([^"]*)"\)\]$/; -// eslint-disable-next-line + const BEFORE_AFTER_DATE_REGEX = /^(<|>)\s*date\("([^"]*)"\)$/; const EXACT_DATE_REGEX = /^date\("([^"]*)"\)$/; diff --git a/packages/dmn-js-decision-table/src/features/simple-date-time-edit/Utils.js b/packages/dmn-js-decision-table/src/features/simple-date-time-edit/Utils.js index 7f886a4ad..2ef722ca0 100644 --- a/packages/dmn-js-decision-table/src/features/simple-date-time-edit/Utils.js +++ b/packages/dmn-js-decision-table/src/features/simple-date-time-edit/Utils.js @@ -1,12 +1,12 @@ const ISO_DATE_REGEX = /^\d{4}(?:-\d\d){2}T(?:\d\d:){2}\d\d(?:Z|(?:[@+-][^")]+))?$/; -// eslint-disable-next-line + const BETWEEN_DATE_REGEX = /^\[date and time\("([^"]*)"\)..date and time\("([^"]*)"\)\]$/; -// eslint-disable-next-line + const BEFORE_AFTER_DATE_REGEX = /^(<|>)\s*date and time\("([^"]*)"\)$/; -// eslint-disable-next-line + const EXACT_DATE_REGEX = /^date and time\("([^"]*)"\)$/; const EXACT = 'exact', diff --git a/packages/dmn-js-decision-table/test/spec/features/context-menu/ContextMenuCloseBehaviorSpec.js b/packages/dmn-js-decision-table/test/spec/features/context-menu/ContextMenuCloseBehaviorSpec.js index 8ce8374bb..450b984a6 100644 --- a/packages/dmn-js-decision-table/test/spec/features/context-menu/ContextMenuCloseBehaviorSpec.js +++ b/packages/dmn-js-decision-table/test/spec/features/context-menu/ContextMenuCloseBehaviorSpec.js @@ -1,4 +1,4 @@ -// eslint-disable-next-line + import Inferno from 'inferno'; import { bootstrapModeler, inject } from 'test/helper'; diff --git a/packages/dmn-js-decision-table/test/spec/features/context-menu/ContextMenuKeyboardSpec.js b/packages/dmn-js-decision-table/test/spec/features/context-menu/ContextMenuKeyboardSpec.js index d441a44da..8408697c1 100644 --- a/packages/dmn-js-decision-table/test/spec/features/context-menu/ContextMenuKeyboardSpec.js +++ b/packages/dmn-js-decision-table/test/spec/features/context-menu/ContextMenuKeyboardSpec.js @@ -1,4 +1,4 @@ -// eslint-disable-next-line + import Inferno from 'inferno'; import { bootstrapModeler, inject } from 'test/helper'; diff --git a/packages/dmn-js-decision-table/test/spec/features/context-menu/ContextMenuSpec.js b/packages/dmn-js-decision-table/test/spec/features/context-menu/ContextMenuSpec.js index 5a32f6daf..f80b5d3f1 100644 --- a/packages/dmn-js-decision-table/test/spec/features/context-menu/ContextMenuSpec.js +++ b/packages/dmn-js-decision-table/test/spec/features/context-menu/ContextMenuSpec.js @@ -1,4 +1,4 @@ -// eslint-disable-next-line + import Inferno from 'inferno'; import { bootstrapModeler, inject } from 'test/helper'; diff --git a/packages/dmn-js-decision-table/test/spec/features/drag-and-drop/DragAndDropSpec.js b/packages/dmn-js-decision-table/test/spec/features/drag-and-drop/DragAndDropSpec.js index 29860fc9d..8820b13d5 100644 --- a/packages/dmn-js-decision-table/test/spec/features/drag-and-drop/DragAndDropSpec.js +++ b/packages/dmn-js-decision-table/test/spec/features/drag-and-drop/DragAndDropSpec.js @@ -1,4 +1,4 @@ -// eslint-disable-next-line + import Inferno from 'inferno'; /* global sinon */ diff --git a/packages/dmn-js-decision-table/test/spec/features/simple-date-edit/SimpleDateEditSpec.js b/packages/dmn-js-decision-table/test/spec/features/simple-date-edit/SimpleDateEditSpec.js index b902c5142..7187a9836 100644 --- a/packages/dmn-js-decision-table/test/spec/features/simple-date-edit/SimpleDateEditSpec.js +++ b/packages/dmn-js-decision-table/test/spec/features/simple-date-edit/SimpleDateEditSpec.js @@ -155,7 +155,7 @@ describe('simple date edit', function() { // then expect(inputEntry7.businessObject.text).to - // eslint-disable-next-line + .equal('[date("2018-01-25")..date("2000-01-01")]'); })); @@ -175,7 +175,7 @@ describe('simple date edit', function() { // then expect(inputEntry7.businessObject.text).to - // eslint-disable-next-line + .equal('[date("2018-01-25")..date("foo")]'); })); @@ -195,7 +195,7 @@ describe('simple date edit', function() { // then expect(inputEntry7.businessObject.text).to - // eslint-disable-next-line + .equal(`[date("2018-01-25")..date("${ getSampleDate() }")]`); })); }); diff --git a/packages/dmn-js-decision-table/test/spec/features/simple-date-edit/UtilsSpec.js b/packages/dmn-js-decision-table/test/spec/features/simple-date-edit/UtilsSpec.js index 3f5ea3941..283308308 100644 --- a/packages/dmn-js-decision-table/test/spec/features/simple-date-edit/UtilsSpec.js +++ b/packages/dmn-js-decision-table/test/spec/features/simple-date-edit/UtilsSpec.js @@ -96,7 +96,7 @@ describe('simple date edit - utils', function() { date: '2000-01-01' })); - // eslint-disable-next-line + it('between', expectParsed('[date("2000-01-01")..date("2000-01-02")]', { type: 'between', dates: [ '2000-01-01', '2000-01-02' ] diff --git a/packages/dmn-js-decision-table/test/spec/features/simple-date-time-edit/SimpleDateTimeEditSpec.js b/packages/dmn-js-decision-table/test/spec/features/simple-date-time-edit/SimpleDateTimeEditSpec.js index e90347230..6f2029e23 100644 --- a/packages/dmn-js-decision-table/test/spec/features/simple-date-time-edit/SimpleDateTimeEditSpec.js +++ b/packages/dmn-js-decision-table/test/spec/features/simple-date-time-edit/SimpleDateTimeEditSpec.js @@ -175,7 +175,7 @@ describe('simple date time edit', function() { // then expect(inputEntry7.businessObject.text).to - // eslint-disable-next-line + .equal('[date and time("2018-01-25T00:00:00Z")..date and time("foo")]'); })); diff --git a/packages/dmn-js-decision-table/test/spec/features/simple-time-edit/SimpleTimeEditSpec.js b/packages/dmn-js-decision-table/test/spec/features/simple-time-edit/SimpleTimeEditSpec.js index bf57c4624..ad8b9ad30 100644 --- a/packages/dmn-js-decision-table/test/spec/features/simple-time-edit/SimpleTimeEditSpec.js +++ b/packages/dmn-js-decision-table/test/spec/features/simple-time-edit/SimpleTimeEditSpec.js @@ -155,7 +155,7 @@ describe('simple time edit', function() { // then expect(inputEntry7.businessObject.text).to - // eslint-disable-next-line + .equal('[time("08:00:00Z")..time("18:00:00Z")]'); })); @@ -175,7 +175,7 @@ describe('simple time edit', function() { // then expect(inputEntry7.businessObject.text).to - // eslint-disable-next-line + .equal('[time("08:00:00Z")..time("foo")]'); })); @@ -195,7 +195,7 @@ describe('simple time edit', function() { // then expect(inputEntry7.businessObject.text).to - // eslint-disable-next-line + .equal(`[time("08:00:00Z")..time("${ getSampleTime() }")]`); })); }); diff --git a/packages/dmn-js-decision-table/test/spec/features/simple-time-edit/UtilsSpec.js b/packages/dmn-js-decision-table/test/spec/features/simple-time-edit/UtilsSpec.js index c35aae984..52d8c3d2b 100644 --- a/packages/dmn-js-decision-table/test/spec/features/simple-time-edit/UtilsSpec.js +++ b/packages/dmn-js-decision-table/test/spec/features/simple-time-edit/UtilsSpec.js @@ -124,7 +124,7 @@ describe('simple time edit - utils', function() { time: '08:00:00Z' })); - // eslint-disable-next-line + it('between', expectParsed('[time("08:00:00Z")..time("08:00:00Z")]', { type: 'between', times: [ '08:00:00Z', '08:00:00Z' ] diff --git a/packages/dmn-js-shared/src/components/ContentEditable.js b/packages/dmn-js-shared/src/components/ContentEditable.js index d07ff3872..43fb511e8 100644 --- a/packages/dmn-js-shared/src/components/ContentEditable.js +++ b/packages/dmn-js-shared/src/components/ContentEditable.js @@ -240,14 +240,14 @@ export default class ContentEditable extends Component { tabIndex="0" className={ this.getClassName() } contentEditable="true" - spellcheck="false" + spellCheck="false" data-placeholder={ placeholder || '' } onInput={ this.onInput } - onKeypress={ this.onKeypress } + onKeyPress={ this.onKeypress } onPaste={ this.onPaste } onFocus={ this.onFocus } onBlur={ this.onBlur } - onKeydown={ this.onKeydown } + onKeyDown={ this.onKeydown } ref={ node => this.node = node } dangerouslySetInnerHTML={ { __html: value } }> ); diff --git a/packages/dmn-js-shared/src/components/Input.js b/packages/dmn-js-shared/src/components/Input.js index 38d445631..ee588147d 100644 --- a/packages/dmn-js-shared/src/components/Input.js +++ b/packages/dmn-js-shared/src/components/Input.js @@ -87,7 +87,7 @@ export default class Input extends Component { onInput={ this.onInput } onKeyDown={ this.onKeyDown } onKeyUp={ this.onKeyUp } - spellcheck="false" + spellCheck="false" type={ type || 'text' } value={ value } id={ id } /> diff --git a/packages/dmn-js-shared/src/components/InputSelect.js b/packages/dmn-js-shared/src/components/InputSelect.js index 45d1a1523..9d7acc311 100644 --- a/packages/dmn-js-shared/src/components/InputSelect.js +++ b/packages/dmn-js-shared/src/components/InputSelect.js @@ -344,7 +344,7 @@ export default class InputSelect extends Component {
this.inputNode = node } >{ label }
@@ -354,7 +354,7 @@ export default class InputSelect extends Component { className="dms-input" onInput={ this.onInput } onKeyDown={ this.onKeyDown } - spellcheck="false" + spellCheck="false" ref={ node => this.inputNode = node } type="text" value={ value } diff --git a/packages/dmn-js-shared/src/components/ValidatedInput.js b/packages/dmn-js-shared/src/components/ValidatedInput.js index 589118bdd..19d20eeed 100644 --- a/packages/dmn-js-shared/src/components/ValidatedInput.js +++ b/packages/dmn-js-shared/src/components/ValidatedInput.js @@ -1,6 +1,6 @@ import { Component } from 'inferno'; -// eslint-disable-next-line + import Input from './Input'; /** diff --git a/packages/dmn-js-shared/test/spec/base/ManagerSpec.js b/packages/dmn-js-shared/test/spec/base/ManagerSpec.js index 3c1097e13..6692385b1 100644 --- a/packages/dmn-js-shared/test/spec/base/ManagerSpec.js +++ b/packages/dmn-js-shared/test/spec/base/ManagerSpec.js @@ -593,7 +593,7 @@ describe('Manager', function() { }); - it('should emit when diagram clear fails', async () => { + it('should emit when diagram clear fails', async function() { // given class ClearErrorView extends TestView { diff --git a/packages/dmn-js-shared/test/spec/components/ValidatedInputSpec.js b/packages/dmn-js-shared/test/spec/components/ValidatedInputSpec.js index 4ed621d43..c012dddb7 100644 --- a/packages/dmn-js-shared/test/spec/components/ValidatedInputSpec.js +++ b/packages/dmn-js-shared/test/spec/components/ValidatedInputSpec.js @@ -10,7 +10,7 @@ import { import { triggerInputEvent } from 'test/util/EventUtil'; -// eslint-disable-next-line + import ValidatedInput from 'src/components/ValidatedInput'; diff --git a/packages/dmn-js-shared/test/spec/features/data-types/DataTypesSpec.js b/packages/dmn-js-shared/test/spec/features/data-types/DataTypesSpec.js index e6ce2018e..139b0ff1b 100644 --- a/packages/dmn-js-shared/test/spec/features/data-types/DataTypesSpec.js +++ b/packages/dmn-js-shared/test/spec/features/data-types/DataTypesSpec.js @@ -18,7 +18,7 @@ const DEFAULT_DATA_TYPES = [ describe('DataTypes', function() { - it('should set default data types', () => { + it('should set default data types', function() { // given const dataTypes = createDataTypes(); @@ -31,7 +31,7 @@ describe('DataTypes', function() { }); - it('should read data types from config', () => { + it('should read data types from config', function() { // given const dataTypes = createDataTypes({ diff --git a/packages/dmn-js-shared/test/spec/features/expression-languages/ExpressionLanguagesSpec.js b/packages/dmn-js-shared/test/spec/features/expression-languages/ExpressionLanguagesSpec.js index 2d340c9d9..4fc3cb955 100644 --- a/packages/dmn-js-shared/test/spec/features/expression-languages/ExpressionLanguagesSpec.js +++ b/packages/dmn-js-shared/test/spec/features/expression-languages/ExpressionLanguagesSpec.js @@ -31,9 +31,9 @@ const CUSTOM_OPTIONS = [ { describe('ExpressionLanguages', function() { - describe('defaults', () => { + describe('defaults', function() { - it('should set default editor expression language to FEEL', () => { + it('should set default editor expression language to FEEL', function() { // given const expressionLanguages = createExpressionLanguages(); @@ -49,7 +49,7 @@ describe('ExpressionLanguages', function() { }); - it('should set default input cell expression language to FEEL', () => { + it('should set default input cell expression language to FEEL', function() { // given const expressionLanguages = createExpressionLanguages(); @@ -65,7 +65,7 @@ describe('ExpressionLanguages', function() { }); - it('should use user provided defaults', () => { + it('should use user provided defaults', function() { // given const expressionLanguages = createExpressionLanguages({ @@ -94,7 +94,7 @@ describe('ExpressionLanguages', function() { }); - it('should support legacy defaults', () => { + it('should support legacy defaults', function() { // given const expressionLanguages = createExpressionLanguages({ @@ -122,9 +122,9 @@ describe('ExpressionLanguages', function() { }); - describe('options', () => { + describe('options', function() { - it('should correctly set default options', () => { + it('should correctly set default options', function() { // given const expressionLanguages = createExpressionLanguages(); @@ -137,7 +137,7 @@ describe('ExpressionLanguages', function() { }); - it('should use provided options', () => { + it('should use provided options', function() { // given const expressionLanguages = createExpressionLanguages({