Skip to content

Commit

Permalink
Update build
Browse files Browse the repository at this point in the history
  • Loading branch information
fasttime committed Mar 17, 2024
1 parent bae7f74 commit 5da360c
Show file tree
Hide file tree
Showing 12 changed files with 150 additions and 109 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
gulp make-ts-defs
gulp lint
gulp bundle:cjs bundle:esm bundle:global
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: lib
path: lib
Expand All @@ -43,7 +43,7 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: lib
path: lib
Expand Down Expand Up @@ -71,7 +71,7 @@ jobs:
- uses: denoland/setup-deno@v1
with:
deno-version: ${{ matrix.deno-version }}
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: lib
path: lib
Expand Down
221 changes: 125 additions & 96 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

'use strict';

const { parallel, series, src, task } = require('gulp');
const { parallel, series, src, task } = require('gulp');
const syncReadable = require('sync-readable');

async function bundle(inputPath, format, outputPath, outputPathMin)
{
Expand Down Expand Up @@ -94,111 +95,139 @@ task
task
(
'lint',
() =>
{
const { createConfig } = require('@origin-1/eslint-config');
const gulpESLintNew = require('gulp-eslint-new');

const JS_EXAMPLE_RULES =
syncReadable
(
async () =>
{
'@stylistic/comma-dangle':
const
[
'error',
{ default: eslintPluginTSTest },
{ createConfig },
{ EslintEnvProcessor },
{ default: globals },
{ default: gulpESLintNew },
] =
await Promise.all
(
[
import('#eslint-plugin-tstest'),
import('@origin-1/eslint-config'),
import('eslint-plugin-eslint-env'),
import('globals'),
import('gulp-eslint-new'),
],
);
const JS_EXAMPLE_RULES =
{
'@stylistic/comma-dangle':
[
'error',
{
'arrays': 'always-multiline',
'objects': 'always-multiline',
'imports': 'always-multiline',
'exports': 'always-multiline',
'functions': 'only-multiline',
},
],
'no-unused-vars':
[
'error',
{
args: 'none',
caughtErrors: 'all',
ignoreRestSiblings: true,
vars: 'local',
varsIgnorePattern: '^(?:Green|WhiteUnit)Circle$',
},
],
'@stylistic/quotes': ['error', 'double'],
};
const { 'no-unused-vars': noUnusedVars, ...TS_EXAMPLE_RULES } = JS_EXAMPLE_RULES;
TS_EXAMPLE_RULES['@typescript-eslint/no-unused-vars'] = noUnusedVars;
const overrideConfig =
await createConfig
(
{ processor: new EslintEnvProcessor() },
{
'arrays': 'always-multiline',
'objects': 'always-multiline',
'imports': 'always-multiline',
'exports': 'always-multiline',
'functions': 'only-multiline',
files: ['**/*.js'],
ignores: ['src/**/*.js'],
jsVersion: 2022,
languageOptions: { sourceType: 'commonjs' },
},
],
'no-unused-vars':
[
'error',
{
args: 'none',
caughtErrors: 'all',
ignoreRestSiblings: true,
vars: 'local',
varsIgnorePattern: '^(?:Green|WhiteUnit)Circle$',
files: ['src/**/*.js'],
jsVersion: 2020,
},
],
'@stylistic/quotes': ['error', 'double'],
};
const { 'no-unused-vars': noUnusedVars, ...TS_EXAMPLE_RULES } = JS_EXAMPLE_RULES;
TS_EXAMPLE_RULES['@typescript-eslint/no-unused-vars'] = noUnusedVars;
const overrideConfig =
createConfig
(
{
files: ['*.js', '*.mjs'],
jsVersion: 2022,
},
{
files: ['*.ts', '*.tstest'],
tsVersion: '4.7.0',
parserOptions: { extraFileExtensions: ['.tstest'], project: 'tsconfig.json' },
},
{
files: ['*.mjs', 'src/**/*.js'],
parserOptions: { sourceType: 'module' },
rules: { 'logical-assignment-operators': 'off' },
},
{
files: 'example/**/*.js',
env: { 'node': 'readOnly' },
rules: JS_EXAMPLE_RULES,
},
{
files: 'example/**/*.ts',
env: { 'node': 'readOnly' },
rules: TS_EXAMPLE_RULES,
},
{
files: 'lib/**/*.d.ts',
rules: { '@stylistic/max-len': 'off' },
},
{
files: '*.tstest',
plugins: ['tstest'],
rules:
{
'@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',
'spaced-comment': 'off',
files: ['**/*.mjs'],
jsVersion: 2022,
},
},
);
const stream =
src
(
[
'*.js',
'example/**/*.{js,ts}',
'lib/**/*.d.ts',
'src/**/*.js',
'test/**/*.{js,mjs,tstest}',
],
)
.pipe
(
gulpESLintNew
(
{
overrideConfig,
reportUnusedDisableDirectives: 'error',
useEslintrc: false,
warnIgnored: true,
files: ['**/*.ts', '**/*.tstest'],
tsVersion: '4.7.0',
languageOptions:
{
parserOptions:
{ extraFileExtensions: ['.tstest'], project: 'tsconfig.json' },
},
},
),
)
.pipe(gulpESLintNew.format('compact'))
.pipe(gulpESLintNew.failAfterError());
return stream;
},
{
files: ['example/**/*.js'],
languageOptions: { globals: { ...globals.node } },
rules: JS_EXAMPLE_RULES,
},
{
files: ['example/**/*.ts'],
languageOptions: { globals: { ...globals.node } },
rules: TS_EXAMPLE_RULES,
},
{
files: ['lib/**/*.d.ts'],
rules: { '@stylistic/max-len': 'off' },
},
{
files: ['**/*.tstest'],
plugins: { tstest: eslintPluginTSTest },
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',
},
},
);
const stream =
src
(
[
'*.js',
'example/**/*.{js,ts}',
'lib/**/*.d.ts',
'src/**/*.js',
'test/**/*.{js,mjs,tstest}',
],
)
.pipe
(
gulpESLintNew
(
{
configType: 'flat',
overrideConfig,
overrideConfigFile: true,
warnIgnored: true,
},
),
)
.pipe(gulpESLintNew.format('compact'))
.pipe(gulpESLintNew.failAfterError());
return stream;
},
),
);

task('bundle:cjs', () => bundle('src/polytype-esm.js', 'cjs', 'lib/polytype.cjs'));
Expand Down
11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
"@origin-1/eslint-config": "latest",
"ansi-colors": "latest",
"c8js": "latest",
"chai": "latest",
"eslint-plugin-tstest": "file:test/eslint-plugin-tstest",
"chai": "4",
"eslint-plugin-eslint-env": "latest",
"glob": "latest",
"gulp": "latest",
"gulp-eslint-new": "latest",
Expand All @@ -54,14 +54,16 @@
"rollup": "latest",
"rollup-plugin-cleanup": "latest",
"rollup-plugin-terser": "latest",
"sync-readable": "latest",
"typescript": "latest",
"typescript_4.7": "npm:[email protected]",
"typescript_4.8": "npm:[email protected]",
"typescript_4.9": "npm:[email protected]",
"typescript_5.0": "npm:[email protected]",
"typescript_5.1": "npm:[email protected]",
"typescript_5.2": "npm:[email protected]",
"typescript_5.3": "npm:[email protected]"
"typescript_5.3": "npm:[email protected]",
"typescript_5.4": "npm:[email protected]"
},
"engines": {
"node": ">=16.0.0"
Expand Down Expand Up @@ -98,5 +100,8 @@
},
"./package.json": "./package.json"
},
"imports": {
"#eslint-plugin-tstest": "./test/eslint-plugin-tstest.js"
},
"types": "lib/polytype-module.d.ts"
}
2 changes: 1 addition & 1 deletion test/deno-spec-runner.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ deno run --allow-env --allow-read test/deno-spec-runner.mjs

import { expandGlob } from 'https://deno.land/std/fs/expand_glob.ts';
import { dirname, fromFileUrl, toFileUrl } from 'https://deno.land/std/path/mod.ts';
import chai from 'https://esm.sh/chai';
import * as chai from 'https://esm.sh/chai';
import 'https://esm.sh/mocha/mocha.js';

globalThis.chai = chai;
Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion test/eslint-plugin-tstest/package.json

This file was deleted.

3 changes: 2 additions & 1 deletion test/serve.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ createServer
'error',
() =>
{
response.writeHead(404);
if (!response.headersSent)
response.writeHead(404);
response.end();
},
);
Expand Down
2 changes: 1 addition & 1 deletion test/spec-helper.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint no-alert: off */
/* eslint-env mocha, shared-node-browser */
/* global Deno alert chai document location process require */
/* global Deno alert chai document location process */

'use strict';

Expand Down
8 changes: 8 additions & 0 deletions test/spec/common/function-prototype-bind.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,16 @@ describe
(
() => Function.prototype.bind.call({ }),
[
// V8
'Bind must be called on a function',

// Firefox 112 or later
'Function.prototype.bind called on incompatible Object',

// Firefox 111 or earlier
'Function.prototype.bind called on incompatible target',

// Safari
'|this| is not a function inside Function.prototype.bind',
],
),
Expand Down
3 changes: 2 additions & 1 deletion test/spec/ts-defs.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { readFile } from 'node:fs/promis
import { createRequire } from 'node:module';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { getImportStatement, getTestCase, processTestCase } from 'eslint-plugin-tstest';
import { getImportStatement, getTestCase, processTestCase } from '#eslint-plugin-tstest';
import { glob } from 'glob';

function defineTests(typescriptPkgName)
Expand Down Expand Up @@ -204,5 +204,6 @@ describe
describe('TypeScript 5.1', () => defineTests('typescript_5.1'));
describe('TypeScript 5.2', () => defineTests('typescript_5.2'));
describe('TypeScript 5.3', () => defineTests('typescript_5.3'));
describe('TypeScript 5.4', () => defineTests('typescript_5.4'));
},
);
1 change: 0 additions & 1 deletion test/spec/ts-defs/010.tstest
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@
}
*/

// eslint-disable-next-line no-duplicate-imports
import { SuperConstructorInvokeInfo } from 'polytype';
1 change: 0 additions & 1 deletion test/spec/ts-defs/020.tstest
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@
}
*/

// eslint-disable-next-line no-duplicate-imports
import { SuperConstructorInvokeInfo } from 'polytype/global';

0 comments on commit 5da360c

Please sign in to comment.