forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[APM] Script static checkers + precommit (elastic#77900)
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
- Loading branch information
1 parent
64ddd61
commit 1e322d0
Showing
6 changed files
with
134 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
//eslint-disable-next-line import/no-extraneous-dependencies | ||
const { CLIEngine } = require('eslint'); | ||
const { resolve } = require('path'); | ||
//eslint-disable-next-line import/no-extraneous-dependencies | ||
const { argv } = require('yargs'); | ||
|
||
async function run() { | ||
const fix = !!argv.fix; | ||
|
||
const engine = new CLIEngine({ | ||
fix, | ||
cache: true, | ||
extensions: ['.js', '.jsx', '.ts', '.tsx'], | ||
}); | ||
|
||
const report = engine.executeOnFiles(resolve(__dirname, '..')); | ||
|
||
const formatter = engine.getFormatter(); | ||
|
||
return formatter(report.results); | ||
} | ||
|
||
run() | ||
.then((text) => { | ||
//eslint-disable-next-line no-console | ||
console.log(text); | ||
process.exit(0); | ||
}) | ||
.catch((err) => { | ||
console.error(err); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
require('@babel/register')({ | ||
extensions: ['.js'], | ||
plugins: [], | ||
presets: [ | ||
'@babel/typescript', | ||
['@babel/preset-env', { targets: { node: 'current' } }], | ||
], | ||
}); | ||
|
||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
const { run } = require('jest'); | ||
|
||
process.env.NODE_ENV = process.env.NODE_ENV || 'test'; | ||
|
||
const config = require('../jest.config.js'); | ||
|
||
const argv = [...process.argv.slice(2), '--config', JSON.stringify(config)]; | ||
|
||
run(argv); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
/* eslint-disable no-console*/ | ||
/* eslint-disable import/no-extraneous-dependencies*/ | ||
|
||
const execa = require('execa'); | ||
const Listr = require('listr'); | ||
const { resolve } = require('path'); | ||
|
||
const cwd = resolve(__dirname, '../../../..'); | ||
|
||
const execaOpts = { cwd, stderr: 'pipe' }; | ||
|
||
const tasks = new Listr( | ||
[ | ||
{ | ||
title: 'Jest', | ||
task: () => | ||
execa( | ||
'node', | ||
[ | ||
resolve(__dirname, './jest.js'), | ||
'--reporters', | ||
resolve(__dirname, './node_modules/jest-silent-reporter'), | ||
'--collect-coverage', | ||
'false', | ||
], | ||
execaOpts | ||
), | ||
}, | ||
{ | ||
title: 'Typescript', | ||
task: () => | ||
execa('node', [resolve(__dirname, 'optimize-tsconfig.js')]).then(() => | ||
execa( | ||
require.resolve('typescript/bin/tsc'), | ||
[ | ||
'--project', | ||
resolve(__dirname, '../../../tsconfig.json'), | ||
'--pretty', | ||
'--noEmit', | ||
'--skipLibCheck', | ||
], | ||
execaOpts | ||
) | ||
), | ||
}, | ||
{ | ||
title: 'Lint', | ||
task: () => execa('node', [resolve(__dirname, 'eslint.js')], execaOpts), | ||
}, | ||
], | ||
{ exitOnError: false, concurrent: true } | ||
); | ||
|
||
tasks.run().catch((error) => { | ||
// from src/dev/typescript/exec_in_projects.ts | ||
process.exitCode = 1; | ||
|
||
const errors = error.errors || [error]; | ||
|
||
for (const e of errors) { | ||
process.stderr.write(e.stdout); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters