diff --git a/.lintstagedrc b/.lintstagedrc index 8515759..a8f1d68 100644 --- a/.lintstagedrc +++ b/.lintstagedrc @@ -1,5 +1,5 @@ { "*.ts": [ - "balena-lint --typescript --fix" - ], + "balena-lint -t tsconfig.dev.json --typescript --fix" + ] } diff --git a/.npmrc b/.npmrc index 43c97e7..4fd15ed 100644 --- a/.npmrc +++ b/.npmrc @@ -1 +1,2 @@ package-lock=false +legacy-peer-deps=true diff --git a/lib/blueprint.ts b/lib/blueprint.ts index af93346..6b569cb 100644 --- a/lib/blueprint.ts +++ b/lib/blueprint.ts @@ -20,7 +20,8 @@ import { compare } from 'semver'; import Contract from './contract'; import { parse } from './cardinality'; -import { BLUEPRINT, BlueprintLayout, BlueprintObject } from './types/types'; +import type { BlueprintLayout, BlueprintObject } from './types/types'; +import { BLUEPRINT } from './types/types'; import { cartesianProductWith, flatten as flattenIterator, @@ -180,7 +181,7 @@ export default class Blueprint extends Contract { references.length === 0 ? contract.getChildren({ types: layout.infinite.types, - }) + }) : references; context.addChildren(contracts, { @@ -237,7 +238,7 @@ export default class Blueprint extends Contract { ? false : context.areChildrenSatisfied({ types: layout.types, - }); + }); }; const checked: number[][] = []; @@ -466,7 +467,7 @@ export default class Blueprint extends Contract { references.length === 0 ? contract.getChildren({ types: layout.infinite.types, - }) + }) : references; context.addChildren(contracts, { diff --git a/lib/children-tree.ts b/lib/children-tree.ts index fd4d232..0d0c899 100644 --- a/lib/children-tree.ts +++ b/lib/children-tree.ts @@ -7,8 +7,8 @@ import reduce from 'lodash/reduce'; import set from 'lodash/set'; -import { ContractObject } from '.'; -import Contract from './contract'; +import type { ContractObject } from '.'; +import type Contract from './contract'; import { setFirst } from './utils'; /** @@ -96,7 +96,7 @@ export const build = (contract: Contract): object => { export const getAll = (tree: any): ContractObject[] => reduce( tree, - (accumulator, value, _) => { + (accumulator, value) => { if (!value.slug) { const out = accumulator.concat(getAll(value)); return out; diff --git a/lib/contract.ts b/lib/contract.ts index 2a22910..487e7bd 100644 --- a/lib/contract.ts +++ b/lib/contract.ts @@ -27,7 +27,8 @@ import { compare, satisfies, valid, validRange } from 'semver'; import ObjectSet from './object-set'; import MatcherCache from './matcher-cache'; import { hashObject } from './hash'; -import { ContractObject, MATCHER } from './types/types'; +import type { ContractObject } from './types/types'; +import { MATCHER } from './types/types'; import { compileContract } from './template'; import { build as buildVariants } from './variants'; import { build as buildChildrentree } from './children-tree'; @@ -689,7 +690,7 @@ export default class Contract { * console.log(child) * }) */ - findChildren(matcher: Contract | {}): Contract[] { + findChildren(matcher: Contract | object): Contract[] { if ( !(matcher instanceof Contract) || !matcher.raw || diff --git a/lib/matcher-cache.ts b/lib/matcher-cache.ts index 14c01cf..2cb0a12 100644 --- a/lib/matcher-cache.ts +++ b/lib/matcher-cache.ts @@ -7,7 +7,7 @@ import concat from 'lodash/concat'; import get from 'lodash/get'; import set from 'lodash/set'; -import Contract from './contract'; +import type Contract from './contract'; /** * @summary Get the path of a matcher in the cache diff --git a/lib/partials.ts b/lib/partials.ts index c8b4178..c3a8279 100644 --- a/lib/partials.ts +++ b/lib/partials.ts @@ -27,7 +27,7 @@ import uniq from 'lodash/uniq'; import flow from 'lodash/flow'; import Contract from './contract'; -import { ContractObject } from './types/types'; +import type { ContractObject } from './types/types'; import { cartesianProductWith, stripExtraBlankLines } from './utils'; const hb = asyncHelpers(handlebars); diff --git a/lib/template.ts b/lib/template.ts index b146918..b26939c 100644 --- a/lib/template.ts +++ b/lib/template.ts @@ -11,7 +11,7 @@ import isString from 'lodash/isString'; import map from 'lodash/map'; import mapValues from 'lodash/mapValues'; -import { ContractObject } from './types/types'; +import type { ContractObject } from './types/types'; /** * @module template @@ -55,7 +55,7 @@ const deepMapValues = ( return isPlainObject(value) ? deepMapValues(value, callback, absoluteKey) : callback(value, absoluteKey); - }); + }); /** * @summary Contract template interpolation regex diff --git a/lib/types/cuetypes.ts b/lib/types/cuetypes.ts index 8b0b640..76ea480 100644 --- a/lib/types/cuetypes.ts +++ b/lib/types/cuetypes.ts @@ -1,4 +1,4 @@ -/* tslint:disable:class-name no-empty-interface */ +/* eslint @typescript-eslint/no-empty-interface: 0 */ /** * This file was auto-generated by openapi-typescript. * Do not make direct changes to the file. diff --git a/lib/types/types.ts b/lib/types/types.ts index a1d4596..767c191 100644 --- a/lib/types/types.ts +++ b/lib/types/types.ts @@ -4,7 +4,7 @@ * Proprietary and confidential. */ -import { components } from './cuetypes'; +import type { components } from './cuetypes'; export type ContractObject = components['schemas']['Contract']; export type BlueprintObject = components['schemas']['Blueprint']; diff --git a/lib/variants.ts b/lib/variants.ts index 7717e0d..12ee7cc 100644 --- a/lib/variants.ts +++ b/lib/variants.ts @@ -21,7 +21,7 @@ import mergeWith from 'lodash/mergeWith'; import omit from 'lodash/omit'; import reduce from 'lodash/reduce'; -import { ContractObject } from './types/types'; +import type { ContractObject } from './types/types'; /** * @summary The name of the contract property that contains variants @@ -80,5 +80,5 @@ export const build = (contract: ContractObject): ContractObject[] => { ), ), [] as ContractObject[], - ); + ); }; diff --git a/package.json b/package.json index fcc90bb..7d9ee90 100644 --- a/package.json +++ b/package.json @@ -26,23 +26,17 @@ "build": "npm run clean && npm run buildtypes && tsc", "buildtypes": "ts-node --transpile-only ./scripts/build-types.ts && balena-lint --typescript --fix lib/types", "doc": "typedoc --options ./typedoc.json", - "lint": "balena-lint --typescript lib tests scripts", - "lint-fix": "balena-lint --typescript --fix lib tests scripts", + "lint": "balena-lint -t tsconfig.dev.json --typescript lib tests scripts", + "lint-fix": "balena-lint -t tsconfig.dev.json --typescript --fix lib tests scripts", "test:node": "mocha -r ts-node/register/transpile-only --reporter spec tests/**/*.spec.ts", "test": "npm run build && npm run lint && npm run test:node", "test:fast": "npm run build && npm run test:node", "prepack": "npm run build" }, "dependencies": { - "@types/debug": "^4.1.5", - "@types/js-combinatorics": "^0.5.32", - "@types/lodash": "^4.14.168", - "@types/node": "^15.0.1", - "@types/object-hash": "^2.1.0", - "@types/semver": "^7.3.5", "debug": "^3.2.6", - "handlebars": "^4.7.6", - "handlebars-async-helpers": "^1.0.5", + "handlebars": "^4.7.8", + "handlebars-async-helpers": "^1.0.4", "js-combinatorics": "^0.5.5", "lodash": "^4.17.19", "object-hash": "^1.3.1", @@ -50,16 +44,22 @@ "skhema": "^5.3.2" }, "devDependencies": { - "@balena/lint": "^5.0.4", + "@balena/lint": "^8.0.2", "@types/chai": "^4.2.11", "@types/chai-as-promised": "^7.1.2", - "@types/mocha": "^7.0.2", + "@types/debug": "^4.1.5", + "@types/js-combinatorics": "^0.5.32", + "@types/lodash": "^4.14.168", + "@types/mocha": "^10.0.6", + "@types/node": "^20.12.7", + "@types/object-hash": "^2.1.0", + "@types/semver": "^7.3.5", "chai": "^4.2.0", "chai-as-promised": "^7.1.1", "cuelang-js": "^1.1.1", "husky": "^4.2.5", "lint-staged": "^10.1.7", - "mocha": "^7.2.0", + "mocha": "^10.4.0", "openapi-typescript": "^3.2.4", "rimraf": "^3.0.2", "ts-node": "^8.10.1", @@ -68,7 +68,7 @@ }, "engines": { "node": "^20.0.0", - "npm": "^9.4.1" + "npm": "^10.0.0" }, "versionist": { "publishedAt": "2024-04-30T20:57:37.954Z" diff --git a/scripts/build-types.ts b/scripts/build-types.ts index da4e9c1..5b0fc8c 100644 --- a/scripts/build-types.ts +++ b/scripts/build-types.ts @@ -27,7 +27,7 @@ const main = async () => { const output = typeFile('cuetypes.ts'); await fs.writeFile( output, - `/* tslint:disable:class-name no-empty-interface */\n${ts}`, + `/* eslint @typescript-eslint/no-empty-interface: 0 */\n${ts}`, ); console.log(`Built types to ${output}`); }; diff --git a/tests/blueprint/reproduce/reproduce.spec.ts b/tests/blueprint/reproduce/reproduce.spec.ts index f3c0902..1ae2bb5 100644 --- a/tests/blueprint/reproduce/reproduce.spec.ts +++ b/tests/blueprint/reproduce/reproduce.spec.ts @@ -28,6 +28,7 @@ describe('Blueprint reproduce', () => { 'requirements-simple-2-aliases', ], (testName) => { + // eslint-disable-next-line @typescript-eslint/no-var-requires const testCase = require(`./${testName}.json`); it(testName, () => { diff --git a/tests/blueprint/sequence/sequence.spec.ts b/tests/blueprint/sequence/sequence.spec.ts index 31c8872..93c6a74 100644 --- a/tests/blueprint/sequence/sequence.spec.ts +++ b/tests/blueprint/sequence/sequence.spec.ts @@ -13,6 +13,7 @@ import Blueprint from '../../../lib/blueprint'; describe('Blueprint sequence', () => { _.each(['path_finding'], (testName) => { + // eslint-disable-next-line @typescript-eslint/no-var-requires const testCase = require(`./${testName}.json`); it(testName, () => { diff --git a/tsconfig.dev.json b/tsconfig.dev.json new file mode 100644 index 0000000..d6295ac --- /dev/null +++ b/tsconfig.dev.json @@ -0,0 +1,9 @@ +{ + "extends": "./tsconfig.json", + "include": [ + "lib/**/*.ts", + "typings/**/*.ts", + "tests/**/*.ts", + "scripts/**/*.ts" + ], +} \ No newline at end of file