Skip to content

Commit

Permalink
Update build
Browse files Browse the repository at this point in the history
  • Loading branch information
fasttime committed May 18, 2024
1 parent 5da360c commit 7bff2a1
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 25 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ jobs:

build:

env:
TSESTREE_SINGLE_RUN: 'false'

name: Build

runs-on: ubuntu-latest
Expand All @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ task
{
const
[
{ default: eslintPluginTSTest },
{ processor: tsTestProcessor },
{ createConfig },
{ EslintEnvProcessor },
{ default: globals },
Expand Down Expand Up @@ -188,15 +188,15 @@ task
},
{
files: ['**/*.tstest'],
plugins: { tstest: eslintPluginTSTest },
processor: tsTestProcessor,
rules:
{
'@stylistic/spaced-comment': 'off',
'@typescript-eslint/no-extraneous-class': 'off',
'@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',
},
},
);
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"ansi-colors": "latest",
"c8js": "latest",
"chai": "4",
"eslint-formatter-compact": "latest",
"eslint-plugin-eslint-env": "latest",
"glob": "latest",
"gulp": "latest",
Expand Down Expand Up @@ -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"
}
2 changes: 1 addition & 1 deletion src/polytype-esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
16 changes: 4 additions & 12 deletions test/eslint-plugin-tstest.js → test/eslint-plugin-tstest.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/* eslint-env node */

'use strict';

function getImportStatement(polytypeMode)
export function getImportStatement(polytypeMode)
{
switch (polytypeMode)
{
Expand All @@ -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(?<testData>.*?)\*\//msu);
Expand Down Expand Up @@ -70,18 +68,12 @@ 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;
}

const fileNameToTestCaseMap = new Map();

module.exports =
{
getImportStatement,
getTestCase,
processTestCase,
processors: { '.tstest': { preprocess, postprocess } },
};
export const processor = { preprocess, postprocess };
13 changes: 7 additions & 6 deletions test/serve.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,38 @@ 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;
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',
() =>
{
const headers = { };
{
const ext = extname(requestPath);
const ext = extname(fullPath);
if (mimeTypes.hasOwnProperty(ext))
headers['Content-Type'] = mimeTypes[ext];
}
Expand Down

0 comments on commit 7bff2a1

Please sign in to comment.