Automation: enforce noImplicitAny for the type-checked javascript

Change-type: patch
This commit is contained in:
Pagan Gazzard 2022-01-04 14:50:54 +00:00
parent 7ca4d2d720
commit c4e317a290
5 changed files with 33 additions and 4 deletions

View File

@ -6,6 +6,8 @@
*
* We don't `require('semver')` to allow this script to be run as a npm
* 'preinstall' hook, at which point no dependencies have been installed.
*
* @param {string} version
*/
function parseSemver(version) {
const match = /v?(\d+)\.(\d+).(\d+)/.exec(version);
@ -16,6 +18,10 @@ function parseSemver(version) {
return [parseInt(major, 10), parseInt(minor, 10), parseInt(patch, 10)];
}
/**
* @param {string} v1
* @param {string} v2
*/
function semverGte(v1, v2) {
let v1Array = parseSemver(v1);
let v2Array = parseSemver(v2);

View File

@ -21,7 +21,6 @@ import type { Chalk } from 'chalk';
import type * as visuals from 'resin-cli-visuals';
import type * as CliForm from 'resin-cli-form';
import type { ux } from 'cli-ux';
import type { stripIndent as StripIndent } from 'common-tags';
// Equivalent of _.once but avoiding the need to import lodash for lazy deps
const once = <T>(fn: () => T) => {
@ -63,4 +62,4 @@ export const getCliUx = once(() => require('cli-ux').ux as typeof ux);
// Directly export stripIndent as we always use it immediately, but importing just `stripIndent` reduces startup time
export const stripIndent =
// tslint:disable-next-line:no-var-requires
require('common-tags/lib/stripIndent') as typeof StripIndent;
require('common-tags/lib/stripIndent') as typeof import('common-tags/lib/stripIndent');

View File

@ -24,7 +24,10 @@ const { promisify } = require('util');
const execFileAsync = promisify(execFile);
const patchesDir = 'patches';
/** Run the patch-package tool in a child process and wait for it to finish */
/**
* Run the patch-package tool in a child process and wait for it to finish
* @param {string} patchDir
*/
async function patchPackage(patchDir) {
// Equivalent to: `npx patch-package --patch-dir $patchDir`
const result = await execFileAsync('node', [

View File

@ -2,7 +2,6 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"allowJs": true,
"noImplicitAny": false,
"checkJs": true
},
"include": [

22
typings/common-tags/index.d.ts vendored Normal file
View File

@ -0,0 +1,22 @@
/**
* @license
* Copyright 2022 Balena Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
declare module 'common-tags/lib/stripIndent' {
import { stripIndent } from 'common-tags';
export = stripIndent;
}