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.
Merge branch 'elastic:main' into main
- Loading branch information
Showing
770 changed files
with
23,149 additions
and
18,160 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
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
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
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
49 changes: 49 additions & 0 deletions
49
packages/kbn-eslint-plugin-eslint/helpers/find_kibana_root.js
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,49 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
const path = require('path'); | ||
const fs = require('fs'); | ||
|
||
function isKibanaRoot(maybeKibanaRoot) { | ||
try { | ||
const packageJsonPath = path.join(maybeKibanaRoot, 'package.json'); | ||
fs.accessSync(packageJsonPath, fs.constants.R_OK); | ||
const packageJsonContent = fs.readFileSync(packageJsonPath); | ||
return JSON.parse(packageJsonContent).name === 'kibana'; | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
|
||
module.exports = function findKibanaRoot() { | ||
let maybeKibanaRoot = path.resolve(__dirname, '../../..'); | ||
|
||
// when using syslinks, __dirname reports outside of the repo | ||
// if that's the case, the path will contain .cache/bazel | ||
if (!maybeKibanaRoot.includes('.cache/bazel')) { | ||
return maybeKibanaRoot; | ||
} | ||
|
||
// process.argv[1] would be the eslint binary, a correctly-set editor | ||
// will use a local eslint inside the repo node_modules and its value | ||
// should be `ACTUAL_KIBANA_ROOT/node_modules/.bin/eslint` | ||
maybeKibanaRoot = path.resolve(process.argv[1], '../../../'); | ||
if (isKibanaRoot(maybeKibanaRoot)) { | ||
return maybeKibanaRoot; | ||
} | ||
|
||
// eslint should run on the repo root level | ||
// try to use process.cwd as the kibana root | ||
maybeKibanaRoot = process.cwd(); | ||
if (isKibanaRoot(maybeKibanaRoot)) { | ||
return maybeKibanaRoot; | ||
} | ||
|
||
// fallback to the first predicted path (original script) | ||
return maybeKibanaRoot; | ||
}; |
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
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
Oops, something went wrong.