From f71de90e35b9853e95706ff05c55b624c1951d6a Mon Sep 17 00:00:00 2001 From: Nico Rehwaldt Date: Wed, 16 Oct 2024 09:16:00 +0200 Subject: [PATCH] chore: improve eslint@9 config (#908) style: whitelist constant expression style: adjust code style (apply eslint --fix) chore: refactor eslint config Ensures we properly lint _all_ assets, following the proposed structure: ``` build -> lib -> test ``` * chore: lint all files --- eslint.config.mjs | 67 ++++++++++++++----- package.json | 2 +- .../test/spec/ViewerSpec.js | 1 + .../ContextMenuCloseBehaviorSpec.js | 3 - .../context-menu/ContextMenuKeyboardSpec.js | 3 - .../features/context-menu/ContextMenuSpec.js | 3 - .../features/drag-and-drop/DragAndDropSpec.js | 3 - .../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 +- .../spec/components/ValidatedInputSpec.js | 2 +- 13 files changed, 61 insertions(+), 41 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index 474b4f069..d6aed4b4d 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -1,35 +1,49 @@ import bpmnIoPlugin from 'eslint-plugin-bpmn-io'; +const files = { + build: [ + '*.mjs', + '*.js', + 'packages/*/*.mjs', + 'packages/*/*.mjs', + 'packages/*/*.js', + 'tasks/*.mjs', + 'packages/*/tasks/*.mjs', + 'packages/dmn-js/test/distro/karma.conf.js' + ], + test: [ + '**/test/**/*.js' + ], + ignored: [ + '**/lib', + '**/dist' + ] +}; + export default [ { - ignores: [ - '**/lib', - '**/dist' - ] + ignores: files.ignored }, - ...bpmnIoPlugin.configs.browser.map(config => { + + // build + ...bpmnIoPlugin.configs.node.map(config => { return { ...config, - files: [ - '**/src/**/*.js' - ] + files: files.build }; }), - ...bpmnIoPlugin.configs.jsx.map(config => { + + // lib + test + ...bpmnIoPlugin.configs.browser.map(config => { return { ...config, - files: [ - '**/src/**/*.js', - '**/test/**/*.js' - ] + ignores: files.build }; }), - ...bpmnIoPlugin.configs.mocha.map(config => { + ...bpmnIoPlugin.configs.jsx.map(config => { return { ...config, - files: [ - '**/test/**/*.js' - ] + ignores: files.build }; }), { @@ -42,6 +56,23 @@ export default [ 'react/no-deprecated': 'off', 'react/jsx-key': 'off', // TODO(@barmac): reenable and fix problems 'react/no-unknown-property': 'off', - } + }, + ignores: files.build + }, + + // test + ...bpmnIoPlugin.configs.mocha.map(config => { + return { + ...config, + files: files.test + }; + }), + { + languageOptions: { + globals: { + require: true + } + }, + files: files.test } ]; diff --git a/package.json b/package.json index 8f12f7b26..c31b08645 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "build": "lerna run build --parallel --stream", "lerna-publish": "lerna publish -m \"chore(project): publish %s\"", "lint": "run-s lint:*", - "lint:js": "eslint packages", + "lint:js": "eslint .", "lint:style": "stylelint \"packages/**/*.css\"", "reinstall": "npm ci", "release": "run-s distro test \"lerna-publish -- {@}\" --", diff --git a/packages/dmn-js-decision-table/test/spec/ViewerSpec.js b/packages/dmn-js-decision-table/test/spec/ViewerSpec.js index a91620818..8106a0d50 100644 --- a/packages/dmn-js-decision-table/test/spec/ViewerSpec.js +++ b/packages/dmn-js-decision-table/test/spec/ViewerSpec.js @@ -30,6 +30,7 @@ describe('DecisionTable', function() { let dmnJS; + // eslint-disable-next-line no-constant-binary-expression false && afterEach(function() { if (dmnJS) { dmnJS.destroy(); 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 450b984a6..c4b846553 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,6 +1,3 @@ - -import Inferno from 'inferno'; - import { bootstrapModeler, inject } from 'test/helper'; import { 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 8408697c1..aa39fec37 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,6 +1,3 @@ - -import Inferno from 'inferno'; - import { bootstrapModeler, inject } from 'test/helper'; import { 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 f80b5d3f1..8e1117c34 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,6 +1,3 @@ - -import Inferno from 'inferno'; - import { bootstrapModeler, inject } from 'test/helper'; import { 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 8820b13d5..154b24f18 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,6 +1,3 @@ - -import Inferno from 'inferno'; - /* global sinon */ import { bootstrapModeler, inject } from 'test/helper'; 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 7187a9836..a8358795f 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 - + .equal('[date("2018-01-25")..date("2000-01-01")]'); })); @@ -175,7 +175,7 @@ describe('simple date edit', function() { // then expect(inputEntry7.businessObject.text).to - + .equal('[date("2018-01-25")..date("foo")]'); })); @@ -195,7 +195,7 @@ describe('simple date edit', function() { // then expect(inputEntry7.businessObject.text).to - + .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 283308308..e6192432f 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' })); - + 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 6f2029e23..ecec65dc6 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 - + .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 ad8b9ad30..7eef47ad2 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 - + .equal('[time("08:00:00Z")..time("18:00:00Z")]'); })); @@ -175,7 +175,7 @@ describe('simple time edit', function() { // then expect(inputEntry7.businessObject.text).to - + .equal('[time("08:00:00Z")..time("foo")]'); })); @@ -195,7 +195,7 @@ describe('simple time edit', function() { // then expect(inputEntry7.businessObject.text).to - + .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 52d8c3d2b..804bd3d24 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' })); - + 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/test/spec/components/ValidatedInputSpec.js b/packages/dmn-js-shared/test/spec/components/ValidatedInputSpec.js index c012dddb7..f1c03a37d 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'; - + import ValidatedInput from 'src/components/ValidatedInput';