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 ccb8bd9
Show file tree
Hide file tree
Showing 9 changed files with 148 additions and 105 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
224 changes: 128 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,142 @@ 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',
{ createConfig },
{ EslintEnvProcessor },
{ default: eslintPluginTSTest },
{ default: globals },
{ default: gulpESLintNew },
] =
await Promise.all
(
[
import('@origin-1/eslint-config'),
import('eslint-plugin-eslint-env'),
import('eslint-plugin-tstest'),
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
(
{
'arrays': 'always-multiline',
'objects': 'always-multiline',
'imports': 'always-multiline',
'exports': 'always-multiline',
'functions': 'only-multiline',
processor:
new EslintEnvProcessor({ disabledRules: { '@stylistic/max-len': 'overlap' } }),
},
],
'no-unused-vars':
[
'error',
{
args: 'none',
caughtErrors: 'all',
ignoreRestSiblings: true,
vars: 'local',
varsIgnorePattern: '^(?:Green|WhiteUnit)Circle$',
files: ['**/*.js'],
ignores: ['src/**/*.js'],
jsVersion: 2022,
languageOptions: { sourceType: 'commonjs' },
},
],
'@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: ['src/**/*.js'],
jsVersion: 2020,
},
},
);
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: ['**/*.mjs'],
jsVersion: 2022,
},
),
)
.pipe(gulpESLintNew.format('compact'))
.pipe(gulpESLintNew.failAfterError());
return stream;
},
{
files: ['**/*.ts', '**/*.tstest'],
tsVersion: '4.7.0',
languageOptions:
{
parserOptions:
{ extraFileExtensions: ['.tstest'], project: 'tsconfig.json' },
},
},
{
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
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
"@origin-1/eslint-config": "latest",
"ansi-colors": "latest",
"c8js": "latest",
"chai": "latest",
"chai": "4",
"eslint-plugin-eslint-env": "latest",
"eslint-plugin-tstest": "file:test/eslint-plugin-tstest",
"glob": "latest",
"gulp": "latest",
Expand All @@ -54,14 +55,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
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
1 change: 1 addition & 0 deletions test/spec/ts-defs.spec.mjs
Original file line number Diff line number Diff line change
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 ccb8bd9

Please sign in to comment.