diff --git a/eslint.config.mjs b/eslint.config.mjs index 58689e1..47d9ec1 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -5,6 +5,18 @@ export default [ { rules: { '@typescript-eslint/restrict-template-expressions': ['error', { allowNumber: true }], + '@typescript-eslint/no-unused-vars': [ + 'error', + { + args: 'all', + argsIgnorePattern: '^_', + caughtErrors: 'all', + caughtErrorsIgnorePattern: '^_', + destructuredArrayIgnorePattern: '^_', + varsIgnorePattern: '^_', + ignoreRestSiblings: true, + }, + ], }, }, ]; diff --git a/src/templates/init.ts b/src/templates/init.ts index 5640ee3..2860bea 100644 --- a/src/templates/init.ts +++ b/src/templates/init.ts @@ -40,20 +40,11 @@ export const getBoatsRc = (): string => { return ( JSON.stringify( { - nunjucksOptions: { - // this empty object just needs to exist, otherwise boats explodes - tags: {}, - }, picomatchOptions: { bash: true, }, - permissionConfig: { - globalPrefix: true, - }, - paths: { - '@shared/': '../shared/', - }, fancyPluralization: true, + paths: {}, }, null, 2, diff --git a/test/boats.ts b/test/boats.ts index eb588d6..0c493c5 100644 --- a/test/boats.ts +++ b/test/boats.ts @@ -1,8 +1,10 @@ import { default as template } from 'boats/build/src/Template'; import { default as bundlerSwaggerParse } from 'boats/build/src/bundlerSwaggerParse'; import { BoatsRC } from 'boats/build/src/interfaces/BoatsRc'; +import { access, readFile } from 'fs/promises'; import { dirname } from 'path'; import pj from '../package.json'; +import { getBoatsRc } from '../src/templates/init'; export type ErrorWithLogs = Error & { code: string; logs: unknown[] }; @@ -12,14 +14,6 @@ type ConsoleMock = { unmock: () => void; }; -export const defaultBoats: BoatsRC = { - nunjucksOptions: { tags: {} }, - picomatchOptions: { bash: true }, - permissionConfig: { globalPrefix: true }, - paths: {}, - fancyPluralization: true, -}; - const mockConsoleLog = (): ConsoleMock => { /* eslint-disable no-console */ const olog = console.log; @@ -74,19 +68,31 @@ const overridePackageJsonReader = (): void => { }; }; +const defaultBoatsRc = JSON.parse(getBoatsRc()) as BoatsRC; + export const boats = async (inFile: string, outFile: string, validate = true): Promise => { const trim = dirname(inFile) + '/paths/'; + const customBoatsRcPath = dirname(dirname(inFile)) + '/.boatsrc'; + let boatsRc = defaultBoatsRc; + try { + const hasBoatsRc = await access(customBoatsRcPath) + .then(() => true) + .catch(() => false); + if (hasBoatsRc) { + boatsRc = JSON.parse(await readFile(customBoatsRcPath, { encoding: 'utf8' })) as BoatsRC; + } + } catch (_e: unknown) {} overridePackageJsonReader(); // overwrite console during testing - no debug output needed const con = mockConsoleLog(); try { - const indexFile = template.directoryParse(inFile, outFile, null as unknown as number, trim, [], [], defaultBoats, false); + const indexFile = template.directoryParse(inFile, outFile, null as unknown as number, trim, [], [], boatsRc, false); const outApiFile = await bundlerSwaggerParse({ inputFile: indexFile, outputFile: outFile, - boatsRc: defaultBoats, + boatsRc, dereference: false, doNotValidate: !validate, excludeVersion: false, diff --git a/test/e2e.spec.ts b/test/e2e.spec.ts index 4eb748a..d18e5fc 100644 --- a/test/e2e.spec.ts +++ b/test/e2e.spec.ts @@ -26,19 +26,11 @@ describe('e2e.spec.ts', async () => { content, trimIndent`\ { - "nunjucksOptions": { - "tags": {} - }, "picomatchOptions": { "bash": true }, - "permissionConfig": { - "globalPrefix": true - }, - "paths": { - "@shared/": "../shared/" - }, - "fancyPluralization": true + "fancyPluralization": true, + "paths": {} } `, ); diff --git a/test/fixtures/e2e/gen1/.boatsrc b/test/fixtures/e2e/gen1/.boatsrc index 4c0a0b1..bee8cf3 100644 --- a/test/fixtures/e2e/gen1/.boatsrc +++ b/test/fixtures/e2e/gen1/.boatsrc @@ -1,15 +1,7 @@ { - "nunjucksOptions": { - "tags": {} - }, "picomatchOptions": { "bash": true }, - "permissionConfig": { - "globalPrefix": true - }, - "paths": { - "@shared/": "../shared/" - }, - "fancyPluralization": true + "fancyPluralization": true, + "paths": {} } diff --git a/test/fixtures/e2e/gen2/.boatsrc b/test/fixtures/e2e/gen2/.boatsrc index 4c0a0b1..bee8cf3 100644 --- a/test/fixtures/e2e/gen2/.boatsrc +++ b/test/fixtures/e2e/gen2/.boatsrc @@ -1,15 +1,7 @@ { - "nunjucksOptions": { - "tags": {} - }, "picomatchOptions": { "bash": true }, - "permissionConfig": { - "globalPrefix": true - }, - "paths": { - "@shared/": "../shared/" - }, - "fancyPluralization": true + "fancyPluralization": true, + "paths": {} } diff --git a/test/model.spec.ts b/test/model.spec.ts index 1ad6054..a139ae0 100644 --- a/test/model.spec.ts +++ b/test/model.spec.ts @@ -60,19 +60,11 @@ describe('model.spec.ts', async () => { await getFile('test/output/model/.boatsrc'), trimIndent`\ { - "nunjucksOptions": { - "tags": {} - }, "picomatchOptions": { "bash": true }, - "permissionConfig": { - "globalPrefix": true - }, - "paths": { - "@shared/": "../shared/" - }, - "fancyPluralization": true + "fancyPluralization": true, + "paths": {} } `, ); diff --git a/test/path.spec.ts b/test/path.spec.ts index 2dc6405..192b852 100644 --- a/test/path.spec.ts +++ b/test/path.spec.ts @@ -70,19 +70,11 @@ describe('path.spec.ts', async () => { await getFile('test/output/path/.boatsrc'), trimIndent`\ { - "nunjucksOptions": { - "tags": {} - }, "picomatchOptions": { "bash": true }, - "permissionConfig": { - "globalPrefix": true - }, - "paths": { - "@shared/": "../shared/" - }, - "fancyPluralization": true + "fancyPluralization": true, + "paths": {} } `, ); diff --git a/tsconfig.json b/tsconfig.json index 84a23cd..badeae7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,5 +16,5 @@ "strictNullChecks": true }, "include": ["src", "test"], - "exclude": ["node_modules"] + "exclude": ["node_modules", "test/output"] }