From 7bff2a15ae4ae36b8e60e843e0c7dc29a640d6ae Mon Sep 17 00:00:00 2001 From: Francesco Trotta Date: Sat, 18 May 2024 22:50:14 +0200 Subject: [PATCH] Update build --- .github/workflows/ci.yml | 7 +++++-- gulpfile.js | 6 +++--- package.json | 3 ++- src/polytype-esm.js | 2 +- ...plugin-tstest.js => eslint-plugin-tstest.mjs} | 16 ++++------------ test/serve.mjs | 13 +++++++------ 6 files changed, 22 insertions(+), 25 deletions(-) rename test/{eslint-plugin-tstest.js => eslint-plugin-tstest.mjs} (88%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5e91c7c..6e973a8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,6 +6,9 @@ jobs: build: + env: + TSESTREE_SINGLE_RUN: 'false' + name: Build runs-on: ubuntu-latest @@ -14,7 +17,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: ^20.8 + node-version: '22' - run: | npm install gulp make-ts-defs @@ -35,7 +38,7 @@ jobs: strategy: matrix: - node-version: ['16.0.0', '16', '18', '20', '21'] + node-version: ['16.0.0', '16', '18', '20', '22'] steps: - uses: actions/checkout@v4 diff --git a/gulpfile.js b/gulpfile.js index f318fb5..e4bb060 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -101,7 +101,7 @@ task { const [ - { default: eslintPluginTSTest }, + { processor: tsTestProcessor }, { createConfig }, { EslintEnvProcessor }, { default: globals }, @@ -188,7 +188,7 @@ task }, { files: ['**/*.tstest'], - plugins: { tstest: eslintPluginTSTest }, + processor: tsTestProcessor, rules: { '@stylistic/spaced-comment': 'off', @@ -196,7 +196,7 @@ task '@typescript-eslint/no-misused-new': 'off', '@typescript-eslint/no-unused-vars': 'off', '@typescript-eslint/no-useless-constructor': 'off', - 'constructor-super': 'off', + 'no-duplicate-imports': 'off', }, }, ); diff --git a/package.json b/package.json index d164032..04bc377 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "ansi-colors": "latest", "c8js": "latest", "chai": "4", + "eslint-formatter-compact": "latest", "eslint-plugin-eslint-env": "latest", "glob": "latest", "gulp": "latest", @@ -101,7 +102,7 @@ "./package.json": "./package.json" }, "imports": { - "#eslint-plugin-tstest": "./test/eslint-plugin-tstest.js" + "#eslint-plugin-tstest": "./test/eslint-plugin-tstest.mjs" }, "types": "lib/polytype-module.d.ts" } diff --git a/src/polytype-esm.js b/src/polytype-esm.js index c65693c..161ba10 100644 --- a/src/polytype-esm.js +++ b/src/polytype-esm.js @@ -115,7 +115,7 @@ const _Function_prototype_hasInstance_call = bindCall(_Function_prototype[_Symb const _Function_prototype_toString_call = bindCall(_Function_prototype.toString); const _Object_prototype_valueOf_call = bindCall(_Object.prototype.valueOf); -bindCall = null; +bindCall = null; // eslint-disable-line no-useless-assignment _Function_prototype_call = null; const checkDuplicateSuperType = diff --git a/test/eslint-plugin-tstest.js b/test/eslint-plugin-tstest.mjs similarity index 88% rename from test/eslint-plugin-tstest.js rename to test/eslint-plugin-tstest.mjs index 233b8e8..c9714a3 100644 --- a/test/eslint-plugin-tstest.js +++ b/test/eslint-plugin-tstest.mjs @@ -1,8 +1,6 @@ /* eslint-env node */ -'use strict'; - -function getImportStatement(polytypeMode) +export function getImportStatement(polytypeMode) { switch (polytypeMode) { @@ -15,7 +13,7 @@ function getImportStatement(polytypeMode) } } -function getTestCase(code) +export function getTestCase(code) { const match = code.match(/(?<=^|\u2028|\u2029)[^\S\r\n\u2028\u2029]?\/\*!TESTDATA\b(?.*?)\*\//msu); @@ -70,7 +68,7 @@ function preprocess(text, filename) return returnValue; } -function processTestCase({ testData, before, after }, importStatement) +export function processTestCase({ testData, before, after }, importStatement) { const processedCode = `${before}${importStatement}/* TESTDATA${testData}*/${after}`; return processedCode; @@ -78,10 +76,4 @@ function processTestCase({ testData, before, after }, importStatement) const fileNameToTestCaseMap = new Map(); -module.exports = -{ - getImportStatement, - getTestCase, - processTestCase, - processors: { '.tstest': { preprocess, postprocess } }, -}; +export const processor = { preprocess, postprocess }; diff --git a/test/serve.mjs b/test/serve.mjs index 74a6e62..1ee3951 100755 --- a/test/serve.mjs +++ b/test/serve.mjs @@ -9,12 +9,13 @@ import { extname, join } from 'node:path'; import { fileURLToPath } from 'node:url'; import ansiColors from 'ansi-colors'; -const pathDir = fileURLToPath(new URL('..', import.meta.url)); +const baseDir = fileURLToPath(new URL('..', import.meta.url)); const mimeTypes = { '.css': 'text/css', '.html': 'text/html', '.js': 'application/javascript', + '.json': 'application/json', '.mjs': 'application/javascript', }; const port = 8080; @@ -22,16 +23,16 @@ createServer ( ({ url }, response) => { - const requestPath = fileURLToPath(new URL(url, 'file:')); - if (requestPath === '/favicon.ico') + const { pathname } = new URL(url, 'file:'); + if (pathname === '/favicon.ico') { const headers = { 'Content-Type': 'image/x-icon' }; response.writeHead(204, headers); response.end(); return; } - const pathname = join(pathDir, requestPath); - const stream = createReadStream(pathname); + const fullPath = join(baseDir, pathname); + const stream = createReadStream(fullPath); stream.on ( 'open', @@ -39,7 +40,7 @@ createServer { const headers = { }; { - const ext = extname(requestPath); + const ext = extname(fullPath); if (mimeTypes.hasOwnProperty(ext)) headers['Content-Type'] = mimeTypes[ext]; }