diff --git a/.github/workflows/test-javascript.yml b/.github/workflows/test-javascript.yml index 58cdeb6..20b2080 100644 --- a/.github/workflows/test-javascript.yml +++ b/.github/workflows/test-javascript.yml @@ -39,4 +39,7 @@ jobs: working-directory: javascript - run: npm run build + working-directory: javascript + + - run: npm run lint working-directory: javascript \ No newline at end of file diff --git a/javascript/.eslintrc.json b/javascript/.eslintrc.json deleted file mode 100644 index 9e26b5d..0000000 --- a/javascript/.eslintrc.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "env": { - "browser": true, - "node": true - }, - "parser": "@typescript-eslint/parser", - "parserOptions": { - "project": "tsconfig.json", - "sourceType": "module" - }, - "plugins": [ - "import", - "simple-import-sort", - "n", - "@typescript-eslint" - ], - "extends": [ - "eslint:recommended", - "plugin:import/typescript", - "plugin:@typescript-eslint/eslint-recommended", - "plugin:@typescript-eslint/recommended", - "plugin:prettier/recommended" - ], - "rules": { - "import/no-cycle": "error", - "n/no-extraneous-import": "error", - "@typescript-eslint/ban-ts-ignore": "off", - "@typescript-eslint/ban-ts-comment": "off", - "@typescript-eslint/explicit-module-boundary-types": "off", - "@typescript-eslint/explicit-function-return-type": "off", - "@typescript-eslint/no-use-before-define": "off", - "@typescript-eslint/interface-name-prefix": "off", - "@typescript-eslint/member-delimiter-style": "off", - "@typescript-eslint/no-explicit-any": "error", - "@typescript-eslint/no-non-null-assertion": "error", - "simple-import-sort/imports": "error", - "simple-import-sort/exports": "error" - } -} diff --git a/javascript/eslint.config.mjs b/javascript/eslint.config.mjs new file mode 100644 index 0000000..794bf86 --- /dev/null +++ b/javascript/eslint.config.mjs @@ -0,0 +1,72 @@ +import path from 'node:path' +import { fileURLToPath } from 'node:url' + +import { fixupConfigRules, fixupPluginRules } from '@eslint/compat' +import { FlatCompat } from '@eslint/eslintrc' +import js from '@eslint/js' +import typescriptEslint from '@typescript-eslint/eslint-plugin' +import tsParser from '@typescript-eslint/parser' +import { defineConfig } from 'eslint/config' +import _import from 'eslint-plugin-import' +import n from 'eslint-plugin-n' +import simpleImportSort from 'eslint-plugin-simple-import-sort' +import globals from 'globals' + +const __filename = fileURLToPath(import.meta.url) +const __dirname = path.dirname(__filename) +const compat = new FlatCompat({ + baseDirectory: __dirname, + recommendedConfig: js.configs.recommended, + allConfig: js.configs.all, +}) + +export default defineConfig([ + { + extends: fixupConfigRules( + compat.extends( + 'eslint:recommended', + 'plugin:import/typescript', + 'plugin:@typescript-eslint/eslint-recommended', + 'plugin:@typescript-eslint/recommended', + ) + ), + + plugins: { + import: fixupPluginRules(_import), + 'simple-import-sort': simpleImportSort, + n, + '@typescript-eslint': fixupPluginRules(typescriptEslint), + }, + + languageOptions: { + globals: { + ...globals.browser, + ...globals.node, + }, + + parser: tsParser, + ecmaVersion: 5, + sourceType: 'module', + + parserOptions: { + project: 'tsconfig.json', + }, + }, + + rules: { + 'import/no-cycle': 'error', + 'n/no-extraneous-import': 'error', + '@typescript-eslint/ban-ts-ignore': 'off', + '@typescript-eslint/ban-ts-comment': 'off', + '@typescript-eslint/explicit-module-boundary-types': 'off', + '@typescript-eslint/explicit-function-return-type': 'off', + '@typescript-eslint/no-use-before-define': 'off', + '@typescript-eslint/interface-name-prefix': 'off', + '@typescript-eslint/member-delimiter-style': 'off', + '@typescript-eslint/no-explicit-any': 'error', + '@typescript-eslint/no-non-null-assertion': 'error', + 'simple-import-sort/imports': 'error', + 'simple-import-sort/exports': 'error', + }, + }, +]) diff --git a/javascript/package-lock.json b/javascript/package-lock.json index 5e8e222..8b1f248 100644 --- a/javascript/package-lock.json +++ b/javascript/package-lock.json @@ -17,6 +17,9 @@ "devDependencies": { "@cucumber/message-streams": "^4.0.1", "@cucumber/messages": "28.0.0", + "@eslint/compat": "^1.3.1", + "@eslint/eslintrc": "^3.3.1", + "@eslint/js": "^9.31.0", "@types/chai": "^5.0.0", "@types/chai-almost": "^1.0.3", "@types/chai-xml": "^0.3.6", @@ -29,11 +32,10 @@ "chai-almost": "^1.0.1", "chai-xml": "^0.4.1", "eslint": "9.31.0", - "eslint-config-prettier": "10.1.5", "eslint-plugin-import": "2.32.0", "eslint-plugin-n": "17.21.0", - "eslint-plugin-prettier": "5.5.1", "eslint-plugin-simple-import-sort": "12.1.1", + "globals": "^16.3.0", "globby": "^14.0.2", "mocha": "^11.0.0", "prettier": "3.6.2", @@ -121,6 +123,24 @@ "node": "^12.0.0 || ^14.0.0 || >=16.0.0" } }, + "node_modules/@eslint/compat": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@eslint/compat/-/compat-1.3.1.tgz", + "integrity": "sha512-k8MHony59I5EPic6EQTCNOuPoVBnoYXkP+20xvwFjN7t0qI3ImyvyBgg+hIVPwC8JaxVjjUZld+cLfBLFDLucg==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "peerDependencies": { + "eslint": "^8.40 || 9" + }, + "peerDependenciesMeta": { + "eslint": { + "optional": true + } + } + }, "node_modules/@eslint/config-array": { "version": "0.21.0", "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.21.0.tgz", @@ -183,6 +203,19 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/@eslint/eslintrc/node_modules/globals": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", + "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/@eslint/js": { "version": "9.31.0", "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.31.0.tgz", @@ -466,19 +499,6 @@ "node": ">=14" } }, - "node_modules/@pkgr/core": { - "version": "0.2.4", - "resolved": "https://registry.npmjs.org/@pkgr/core/-/core-0.2.4.tgz", - "integrity": "sha512-ROFF39F6ZrnzSUEmQQZUar0Jt4xVoP9WnDRdWwF4NNcXs3xBTLgBUDoOwW141y1jP+S8nahIbdxbFC7IShw9Iw==", - "dev": true, - "license": "MIT", - "engines": { - "node": "^12.20.0 || ^14.18.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/pkgr" - } - }, "node_modules/@rtsao/scc": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@rtsao/scc/-/scc-1.1.0.tgz", @@ -1948,22 +1968,6 @@ "eslint": ">=6.0.0" } }, - "node_modules/eslint-config-prettier": { - "version": "10.1.5", - "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-10.1.5.tgz", - "integrity": "sha512-zc1UmCpNltmVY34vuLRV61r1K27sWuX39E+uyUnY8xS2Bex88VV9cugG+UZbRSRGtGyFboj+D8JODyme1plMpw==", - "dev": true, - "license": "MIT", - "bin": { - "eslint-config-prettier": "bin/cli.js" - }, - "funding": { - "url": "https://opencollective.com/eslint-config-prettier" - }, - "peerDependencies": { - "eslint": ">=7.0.0" - } - }, "node_modules/eslint-import-resolver-node": { "version": "0.3.9", "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.9.tgz", @@ -2156,37 +2160,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/eslint-plugin-prettier": { - "version": "5.5.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-5.5.1.tgz", - "integrity": "sha512-dobTkHT6XaEVOo8IO90Q4DOSxnm3Y151QxPJlM/vKC0bVy+d6cVWQZLlFiuZPP0wS6vZwSKeJgKkcS+KfMBlRw==", - "dev": true, - "license": "MIT", - "dependencies": { - "prettier-linter-helpers": "^1.0.0", - "synckit": "^0.11.7" - }, - "engines": { - "node": "^14.18.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint-plugin-prettier" - }, - "peerDependencies": { - "@types/eslint": ">=8.0.0", - "eslint": ">=8.0.0", - "eslint-config-prettier": ">= 7.0.0 <10.0.0 || >=10.1.0", - "prettier": ">=3.0.0" - }, - "peerDependenciesMeta": { - "@types/eslint": { - "optional": true - }, - "eslint-config-prettier": { - "optional": true - } - } - }, "node_modules/eslint-plugin-simple-import-sort": { "version": "12.1.1", "resolved": "https://registry.npmjs.org/eslint-plugin-simple-import-sort/-/eslint-plugin-simple-import-sort-12.1.1.tgz", @@ -2337,13 +2310,6 @@ "dev": true, "license": "MIT" }, - "node_modules/fast-diff": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.3.0.tgz", - "integrity": "sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==", - "dev": true, - "license": "Apache-2.0" - }, "node_modules/fast-glob": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", @@ -2698,9 +2664,9 @@ } }, "node_modules/globals": { - "version": "14.0.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", - "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", + "version": "16.3.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-16.3.0.tgz", + "integrity": "sha512-bqWEnJ1Nt3neqx2q5SFfGS8r/ahumIakg3HcwtNlrVlwXIeNumWn/c7Pn/wKzGhf6SaW6H6uWXLqC30STCMchQ==", "dev": true, "license": "MIT", "engines": { @@ -4045,19 +4011,6 @@ "url": "https://github.com/prettier/prettier?sponsor=1" } }, - "node_modules/prettier-linter-helpers": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", - "integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==", - "dev": true, - "license": "MIT", - "dependencies": { - "fast-diff": "^1.1.2" - }, - "engines": { - "node": ">=6.0.0" - } - }, "node_modules/punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", @@ -4704,22 +4657,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/synckit": { - "version": "0.11.7", - "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.11.7.tgz", - "integrity": "sha512-/5aUeiRPqmY0CRTJ+iVWfOOMHWTDh8JAIuNF1A6nZ2/RdCNWwKaUrO5Qw5ephLK6dYa7NclYBI0ahdgUECvdhA==", - "dev": true, - "license": "MIT", - "dependencies": { - "@pkgr/core": "^0.2.4" - }, - "engines": { - "node": "^14.18.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/synckit" - } - }, "node_modules/tapable": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz", diff --git a/javascript/package.json b/javascript/package.json index b84f476..325147e 100644 --- a/javascript/package.json +++ b/javascript/package.json @@ -16,8 +16,8 @@ "scripts": { "build": "tsc --build tsconfig.build.json", "clean": "rm -rf dist", - "lint-fix": "eslint --ext ts --max-warnings 0 --fix src && prettier --write src", - "lint": "eslint --ext ts --max-warnings 0 && prettier --check src", + "fix": "eslint --ext ts --max-warnings 0 src --fix src && prettier --write src", + "lint": "eslint --ext ts --max-warnings 0 src && prettier --check src", "test": "mocha 'src/**/*.spec.*'", "prepublishOnly": "tsc --build tsconfig.build.json" }, @@ -33,6 +33,9 @@ "devDependencies": { "@cucumber/message-streams": "^4.0.1", "@cucumber/messages": "28.0.0", + "@eslint/compat": "^1.3.1", + "@eslint/eslintrc": "^3.3.1", + "@eslint/js": "^9.31.0", "@types/chai": "^5.0.0", "@types/chai-almost": "^1.0.3", "@types/chai-xml": "^0.3.6", @@ -45,11 +48,10 @@ "chai-almost": "^1.0.1", "chai-xml": "^0.4.1", "eslint": "9.31.0", - "eslint-config-prettier": "10.1.5", "eslint-plugin-import": "2.32.0", "eslint-plugin-n": "17.21.0", - "eslint-plugin-prettier": "5.5.1", "eslint-plugin-simple-import-sort": "12.1.1", + "globals": "^16.3.0", "globby": "^14.0.2", "mocha": "^11.0.0", "prettier": "3.6.2", diff --git a/javascript/src/index.spec.ts b/javascript/src/index.spec.ts index 74652e1..dd7c2b9 100644 --- a/javascript/src/index.spec.ts +++ b/javascript/src/index.spec.ts @@ -14,7 +14,7 @@ import formatter from './index.js' const asyncPipeline = util.promisify(pipeline) use(chaiXml) -describe('Acceptance Tests', async function() { +describe('Acceptance Tests', async function () { this.timeout(10_000) const ndjsonFiles = globbySync(`*.ndjson`, { @@ -46,7 +46,7 @@ describe('Acceptance Tests', async function() { emit(envelope) callback() }, - }), + }) ) const expectedXml = fs.readFileSync(ndjsonFile.replace('.ndjson', '.xml'), { diff --git a/javascript/src/makeReport.ts b/javascript/src/makeReport.ts index a4e57f2..e23b203 100644 --- a/javascript/src/makeReport.ts +++ b/javascript/src/makeReport.ts @@ -54,7 +54,7 @@ export function makeReport(query: Query): ReportSuite { ), errors: 0, testCases: makeTestCases(query), - timestamp: formatTimestamp(query.findTestRunStarted()) + timestamp: formatTimestamp(query.findTestRunStarted()), } }