diff --git a/src/init.ts b/src/init.ts index 14294410..1eaf5182 100644 --- a/src/init.ts +++ b/src/init.ts @@ -181,6 +181,8 @@ export const ESLINT_CONFIG = { extends: './node_modules/gts/', }; +export const ESLINT_IGNORE = 'build/\n'; + async function generateConfigFile( options: Options, filename: string, @@ -227,6 +229,10 @@ async function generateESLintConfig(options: Options): Promise { ); } +async function generateESLintIgnore(options: Options): Promise { + return generateConfigFile(options, './.eslintignore', ESLINT_IGNORE); +} + async function generateTsConfig(options: Options): Promise { const config = formatJson({ extends: './node_modules/gts/tsconfig-google.json', @@ -308,6 +314,7 @@ export async function init(options: Options): Promise { } await generateTsConfig(options); await generateESLintConfig(options); + await generateESLintIgnore(options); await generatePrettierConfig(options); await installDefaultTemplate(options); diff --git a/test/kitchen.ts b/test/kitchen.ts index 12abb492..c0bdcca9 100644 --- a/test/kitchen.ts +++ b/test/kitchen.ts @@ -60,6 +60,7 @@ describe('🚰 kitchen sink', () => { // Ensure config files got generated. fs.accessSync(path.join(kitchenPath, 'tsconfig.json')); fs.accessSync(path.join(kitchenPath, '.eslintrc.json')); + fs.accessSync(path.join(kitchenPath, '.eslintignore')); fs.accessSync(path.join(kitchenPath, '.prettierrc.js')); // Compilation shouldn't have happened. Hence no `build` directory. @@ -122,6 +123,11 @@ describe('🚰 kitchen sink', () => { .readFileSync(path.join(kitchenPath, '.eslintrc.json'), 'utf8') .endsWith('\n') ); + assert.ok( + fs + .readFileSync(path.join(kitchenPath, '.eslintignore'), 'utf8') + .endsWith('\n') + ); }); it('should check before fix', async () => {