Skip to content

Commit

Permalink
#1231 followup: tslint to prettier: apply formatting changes, remove …
Browse files Browse the repository at this point in the history
…tslint:disable comments (#1251)

* results of lint-fix

* Remove tslint:disable comments

* re-run lint-fix after removing tslint:disable comments
  • Loading branch information
cspotcode authored Feb 27, 2021
1 parent 45a9c63 commit 9d05cb6
Show file tree
Hide file tree
Showing 88 changed files with 2,852 additions and 2,339 deletions.
14 changes: 9 additions & 5 deletions esm.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import {fileURLToPath} from 'url'
import {createRequire} from 'module'
const require = createRequire(fileURLToPath(import.meta.url))
import { fileURLToPath } from 'url';
import { createRequire } from 'module';
const require = createRequire(fileURLToPath(import.meta.url));

/** @type {import('./dist/esm')} */
const esm = require('./dist/esm')
export const {resolve, getFormat, transformSource} = esm.registerAndCreateEsmHooks()
const esm = require('./dist/esm');
export const {
resolve,
getFormat,
transformSource,
} = esm.registerAndCreateEsmHooks();
14 changes: 9 additions & 5 deletions esm/transpile-only.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import {fileURLToPath} from 'url'
import {createRequire} from 'module'
const require = createRequire(fileURLToPath(import.meta.url))
import { fileURLToPath } from 'url';
import { createRequire } from 'module';
const require = createRequire(fileURLToPath(import.meta.url));

/** @type {import('../dist/esm')} */
const esm = require('../dist/esm')
export const {resolve, getFormat, transformSource} = esm.registerAndCreateEsmHooks({transpileOnly: true})
const esm = require('../dist/esm');
export const {
resolve,
getFormat,
transformSource,
} = esm.registerAndCreateEsmHooks({ transpileOnly: true });
11 changes: 3 additions & 8 deletions nyc.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
module.exports = {
all: true,
include: [
'tests/node_modules/ts-node/**',
],
exclude: [
'**/*.d.ts',
'tests/node_modules/ts-node/node_modules/**',
],
include: ['tests/node_modules/ts-node/**'],
exclude: ['**/*.d.ts', 'tests/node_modules/ts-node/node_modules/**'],
excludeNodeModules: false,
excludeAfterRemap: false
excludeAfterRemap: false,
};
4 changes: 2 additions & 2 deletions register/files.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
require('../dist').register({
files: true
})
files: true,
});
2 changes: 1 addition & 1 deletion register/index.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require('../').register()
require('../').register();
4 changes: 2 additions & 2 deletions register/transpile-only.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
require('../').register({
transpileOnly: true
})
transpileOnly: true,
});
4 changes: 2 additions & 2 deletions register/type-check.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
require('../').register({
typeCheck: true
})
typeCheck: true,
});
41 changes: 26 additions & 15 deletions scripts/build-pack.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@
// Written in JS to support Windows
// Would otherwise be written as inline bash in package.json script

const { exec } = require('child_process')
const { mkdtempSync, writeFileSync, readFileSync, unlinkSync, rmdirSync, readdirSync } = require('fs')
const { join } = require('path')
const { exec } = require('child_process');
const {
mkdtempSync,
writeFileSync,
readFileSync,
unlinkSync,
rmdirSync,
readdirSync,
} = require('fs');
const { join } = require('path');

const testDir = join(__dirname, '../tests')
const tarballPath = join(testDir, 'ts-node-packed.tgz')
const tempDir = mkdtempSync(join(testDir, 'tmp'))
exec(`npm pack --ignore-scripts "${join(__dirname, '..')}"`, { cwd: tempDir }, (err, stdout) => {
if (err) {
console.error(err)
process.exit(1)
const testDir = join(__dirname, '../tests');
const tarballPath = join(testDir, 'ts-node-packed.tgz');
const tempDir = mkdtempSync(join(testDir, 'tmp'));
exec(
`npm pack --ignore-scripts "${join(__dirname, '..')}"`,
{ cwd: tempDir },
(err, stdout) => {
if (err) {
console.error(err);
process.exit(1);
}
const tempTarballPath = join(tempDir, readdirSync(tempDir)[0]);
writeFileSync(tarballPath, readFileSync(tempTarballPath));
unlinkSync(tempTarballPath);
rmdirSync(tempDir);
}
const tempTarballPath = join(tempDir, readdirSync(tempDir)[0])
writeFileSync(tarballPath, readFileSync(tempTarballPath))
unlinkSync(tempTarballPath)
rmdirSync(tempDir)
})
);
39 changes: 24 additions & 15 deletions scripts/create-merged-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
*/

import axios from 'axios';
import {resolve} from 'path';
import {writeFileSync} from 'fs';
import { resolve } from 'path';
import { writeFileSync } from 'fs';

async function main() {
/** schemastore definition */
Expand All @@ -26,27 +26,34 @@ async function main() {
properties: {
'ts-node': {
...typescriptNodeSchema.definitions.TsConfigOptions,
description: typescriptNodeSchema.definitions.TsConfigSchema.properties['ts-node'].description,
description:
typescriptNodeSchema.definitions.TsConfigSchema.properties[
'ts-node'
].description,
properties: {
...typescriptNodeSchema.definitions.TsConfigOptions.properties,
compilerOptions: {
...typescriptNodeSchema.definitions.TsConfigOptions.properties.compilerOptions,
allOf: [{
$ref: '#/definitions/compilerOptionsDefinition/properties/compilerOptions'
}]
}
}
}
}
...typescriptNodeSchema.definitions.TsConfigOptions.properties
.compilerOptions,
allOf: [
{
$ref:
'#/definitions/compilerOptionsDefinition/properties/compilerOptions',
},
],
},
},
},
},
},
},
allOf: [
// Splice into the allOf array at a spot that looks good. Does not affect
// behavior of the schema, but looks nicer if we want to submit as a PR to schemastore.
...schemastoreSchema.allOf.slice(0, 4),
{ "$ref": "#/definitions/tsNodeDefinition" },
{ $ref: '#/definitions/tsNodeDefinition' },
...schemastoreSchema.allOf.slice(4),
]
],
};
writeFileSync(
resolve(__dirname, '../tsconfig.schemastore-schema.json'),
Expand All @@ -55,9 +62,11 @@ async function main() {
}

export async function getSchemastoreSchema() {
const {data: schemastoreSchema} = await axios.get(
const {
data: schemastoreSchema,
} = await axios.get(
'https://schemastore.azurewebsites.net/schemas/json/tsconfig.json',
{ responseType: "json" }
{ responseType: 'json' }
);
return schemastoreSchema;
}
Expand Down
20 changes: 10 additions & 10 deletions scripts/update-schemastore-schema-with-compiler-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,18 @@
* in the TypeStrong org.
*/

import {} from 'ts-expose-internals'
import * as ts from 'typescript'
import { getSchemastoreSchema } from './create-merged-schema'
import {} from 'ts-expose-internals';
import * as ts from 'typescript';
import { getSchemastoreSchema } from './create-merged-schema';

// Sometimes schemastore becomes out of date with the latest tsconfig options.
// This script

async function main() {
const schemastoreSchema = await getSchemastoreSchema();
const compilerOptions = schemastoreSchema.definitions.compilerOptionsDefinition.properties.compilerOptions.properties;
const compilerOptions =
schemastoreSchema.definitions.compilerOptionsDefinition.properties
.compilerOptions.properties;

// These options are only available via CLI flags, not in a tsconfig file.
const excludedOptions = [
Expand All @@ -48,10 +50,10 @@ async function main() {
'out', // <-- deprecated
];

ts.optionDeclarations.forEach(v => {
if(excludedOptions.includes(v.name)) return;
ts.optionDeclarations.forEach((v) => {
if (excludedOptions.includes(v.name)) return;

if(!compilerOptions[v.name]) {
if (!compilerOptions[v.name]) {
compilerOptions[v.name] = {
description: v.description?.message,
type: v.type,
Expand All @@ -60,9 +62,7 @@ async function main() {
});

// Don't write to a file; this is not part of our build process
console.log(
JSON.stringify(schemastoreSchema, null, 2)
);
console.log(JSON.stringify(schemastoreSchema, null, 2));
}

main();
4 changes: 2 additions & 2 deletions src/bin-cwd.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env node

import { main } from './bin'
import { main } from './bin';

main(undefined, { '--cwd-mode': true })
main(undefined, { '--cwd-mode': true });
6 changes: 3 additions & 3 deletions src/bin-script-deprecated.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/env node

import { main } from './bin'
import { main } from './bin';

console.warn(
'ts-script has been deprecated and will be removed in the next major release.',
'Please use ts-node-script instead'
)
);

main(undefined, { '--script-mode': true })
main(undefined, { '--script-mode': true });
4 changes: 2 additions & 2 deletions src/bin-script.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env node

import { main } from './bin'
import { main } from './bin';

main(undefined, { '--script-mode': true })
main(undefined, { '--script-mode': true });
4 changes: 2 additions & 2 deletions src/bin-transpile.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env node

import { main } from './bin'
import { main } from './bin';

main(undefined, { '--transpile-only': true })
main(undefined, { '--transpile-only': true });
Loading

0 comments on commit 9d05cb6

Please sign in to comment.