Skip to content

Commit

Permalink
skip lint on build dir by means of .eslintignore generation
Browse files Browse the repository at this point in the history
solves google#483

solves google#520
  • Loading branch information
Naseem committed Jun 3, 2020
1 parent d25e25e commit 6424eba
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -227,6 +229,10 @@ async function generateESLintConfig(options: Options): Promise<void> {
);
}

async function generateESLintIgnore(options: Options): Promise<void> {
return generateConfigFile(options, './.eslintignore', ESLINT_IGNORE);
}

async function generateTsConfig(options: Options): Promise<void> {
const config = formatJson({
extends: './node_modules/gts/tsconfig-google.json',
Expand Down Expand Up @@ -308,6 +314,7 @@ export async function init(options: Options): Promise<boolean> {
}
await generateTsConfig(options);
await generateESLintConfig(options);
await generateESLintIgnore(options);
await generatePrettierConfig(options);
await installDefaultTemplate(options);

Expand Down
6 changes: 6 additions & 0 deletions test/kitchen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 () => {
Expand Down

0 comments on commit 6424eba

Please sign in to comment.