Prettier: Upgrade to 2 (#30387)

* Updated package json but not updated source files

* Update eslint plugin

* updated files
This commit is contained in:
Torkel Ödegaard
2021-01-20 07:59:48 +01:00
committed by GitHub
parent f27450ed94
commit 1d689888b0
1069 changed files with 4370 additions and 5260 deletions
+22 -22
View File
@@ -25,14 +25,14 @@ import { nodeVersionCheckerTask } from './tasks/nodeVersionChecker';
export const run = (includeInternalScripts = false) => {
if (includeInternalScripts) {
program.option('-d, --depreciate <scripts>', 'Inform about npm script deprecation', v => v.split(','));
program.option('-d, --depreciate <scripts>', 'Inform about npm script deprecation', (v) => v.split(','));
program
.command('core:start')
.option('-h, --hot', 'Run front-end with HRM enabled')
.option('-T, --noTsCheck', 'Run bundler without TS type checking')
.option('-t, --watchTheme', 'Watch for theme changes and regenerate variables.scss files')
.description('Starts Grafana front-end in development mode with watch enabled')
.action(async cmd => {
.action(async (cmd) => {
await execTask(startTask)({
watchThemes: cmd.watchTheme,
noTsCheck: cmd.noTsCheck,
@@ -44,7 +44,7 @@ export const run = (includeInternalScripts = false) => {
.command('package:build')
.option('-s, --scope <packages>', 'packages=[data|runtime|ui|toolkit|e2e|e2e-selectors]')
.description('Builds @grafana/* package to packages/grafana-*/dist')
.action(async cmd => {
.action(async (cmd) => {
await execTask(buildPackageTask)({
scope: cmd.scope,
});
@@ -54,7 +54,7 @@ export const run = (includeInternalScripts = false) => {
.command('changelog')
.option('-m, --milestone <milestone>', 'Specify milestone')
.description('Builds changelog markdown')
.action(async cmd => {
.action(async (cmd) => {
if (!cmd.milestone) {
console.log('Please specify milestone, example: -m <milestone id from github milestone URL>');
return;
@@ -70,28 +70,28 @@ export const run = (includeInternalScripts = false) => {
.command('cherrypick')
.option('-e, --enterprise', 'Run task for grafana-enterprise')
.description('Helps find commits to cherry pick')
.action(async cmd => {
.action(async (cmd) => {
await execTask(cherryPickTask)({ enterprise: !!cmd.enterprise });
});
program
.command('node-version-check')
.description('Verify node version')
.action(async cmd => {
.action(async (cmd) => {
await execTask(nodeVersionCheckerTask)({});
});
program
.command('debug:template')
.description('Just testing')
.action(async cmd => {
.action(async (cmd) => {
await execTask(templateTask)({});
});
program
.command('toolkit:build')
.description('Prepares grafana/toolkit dist package')
.action(async cmd => {
.action(async (cmd) => {
await execTask(toolkitBuildTask)({});
});
@@ -99,7 +99,7 @@ export const run = (includeInternalScripts = false) => {
.command('searchTestData')
.option('-c, --count <number_of_dashboards>', 'Specify number of dashboards')
.description('Setup test data for search')
.action(async cmd => {
.action(async (cmd) => {
await execTask(searchTestDataSetupTask)({ count: cmd.count });
});
@@ -108,7 +108,7 @@ export const run = (includeInternalScripts = false) => {
.option('-m, --milestone <milestone>', 'Specify milestone')
.option('--dryRun', 'Only simulate actions')
.description('Helps ends a milestone by removing the cherry-pick label and closing it')
.action(async cmd => {
.action(async (cmd) => {
if (!cmd.milestone) {
console.log('Please specify milestone, example: -m <milestone id from github milestone URL>');
return;
@@ -140,7 +140,7 @@ export const run = (includeInternalScripts = false) => {
program
.command('plugin:create [name]')
.description('Creates plugin from template')
.action(async cmd => {
.action(async (cmd) => {
await execTask(pluginCreateTask)({ name: cmd, silent: true });
});
@@ -150,7 +150,7 @@ export const run = (includeInternalScripts = false) => {
.option('--coverage', 'Run code coverage', false)
.option('--preserveConsole', 'Preserves console calls', false)
.description('Prepares plugin dist package')
.action(async cmd => {
.action(async (cmd) => {
await execTask(pluginBuildTask)({
coverage: cmd.coverage,
silent: true,
@@ -164,7 +164,7 @@ export const run = (includeInternalScripts = false) => {
.option('-w, --watch', 'Run plugin development mode with watch enabled')
.option('--yarnlink', 'symlink this project to the local grafana/toolkit')
.description('Starts plugin dev mode')
.action(async cmd => {
.action(async (cmd) => {
await execTask(pluginDevTask)({
watch: !!cmd.watch,
yarnlink: !!cmd.yarnlink,
@@ -181,7 +181,7 @@ export const run = (includeInternalScripts = false) => {
.option('--testNamePattern <regex>', 'Run only tests with a name that matches the regex')
.option('--maxWorkers <num>|<string>', 'Limit number of workers spawned')
.description('Executes plugin tests')
.action(async cmd => {
.action(async (cmd) => {
await execTask(pluginTestTask)({
updateSnapshot: !!cmd.updateSnapshot,
coverage: !!cmd.coverage,
@@ -198,7 +198,7 @@ export const run = (includeInternalScripts = false) => {
.option('--signatureType <type>', 'Signature Type')
.option('--rootUrls <urls...>', 'Root URLs')
.description('Create a plugin signature')
.action(async cmd => {
.action(async (cmd) => {
await execTask(pluginSignTask)({
signatureType: cmd.signatureType,
rootUrls: cmd.rootUrls,
@@ -211,7 +211,7 @@ export const run = (includeInternalScripts = false) => {
.option('--finish', 'move all results to the jobs folder', false)
.option('--maxJestWorkers <num>|<string>', 'Limit number of Jest workers spawned')
.description('Build the plugin, leaving results in /dist and /coverage')
.action(async cmd => {
.action(async (cmd) => {
await execTask(ciBuildPluginTask)({
finish: cmd.finish,
maxJestWorkers: cmd.maxJestWorkers,
@@ -221,7 +221,7 @@ export const run = (includeInternalScripts = false) => {
program
.command('plugin:ci-docs')
.description('Build the HTML docs')
.action(async cmd => {
.action(async (cmd) => {
await execTask(ciBuildPluginDocsTask)({});
});
@@ -231,7 +231,7 @@ export const run = (includeInternalScripts = false) => {
.option('--rootUrls <urls...>', 'Root URLs')
.option('--signing-admin', 'Use the admin API endpoint for signing the manifest. (deprecated)', false)
.description('Create a zip packages for the plugin')
.action(async cmd => {
.action(async (cmd) => {
await execTask(ciPackagePluginTask)({
signatureType: cmd.signatureType,
rootUrls: cmd.rootUrls,
@@ -242,7 +242,7 @@ export const run = (includeInternalScripts = false) => {
.command('plugin:ci-report')
.description('Build a report for this whole process')
.option('--upload', 'upload packages also')
.action(async cmd => {
.action(async (cmd) => {
await execTask(ciPluginReportTask)({
upload: cmd.upload,
});
@@ -251,7 +251,7 @@ export const run = (includeInternalScripts = false) => {
program
.command('plugin:bundle-managed')
.description('Builds managed plugins')
.action(async cmd => {
.action(async (cmd) => {
await execTask(bundleManagedTask)({});
});
@@ -261,7 +261,7 @@ export const run = (includeInternalScripts = false) => {
.option('--verbose', 'Print verbose', false)
.option('--commitHash <hashKey>', 'Specify the commit hash')
.description('Publish to github')
.action(async cmd => {
.action(async (cmd) => {
await execTask(githubPublishTask)({
dryrun: cmd.dryrun,
verbose: cmd.verbose,
@@ -272,7 +272,7 @@ export const run = (includeInternalScripts = false) => {
program
.command('plugin:update-circleci')
.description('Update plugin')
.action(async cmd => {
.action(async (cmd) => {
await execTask(pluginUpdateTask)({});
});
@@ -9,7 +9,7 @@ interface CherryPickOptions {
const pagingParser = (linkStr: string): { prev?: string; next?: string; last?: string; first?: string } => {
return linkStr
.split(',')
.map(rel => {
.map((rel) => {
//@ts-ignore
return rel.split(';').map((curr, idx) => {
if (idx === 0) {
@@ -22,7 +22,7 @@ const pagingParser = (linkStr: string): { prev?: string; next?: string; last?: s
}
});
})
.reduce(function(obj, curr, i) {
.reduce(function (obj, curr, i) {
//@ts-ignore
obj[curr[1]] = curr[0];
return obj;
@@ -28,7 +28,7 @@ const startTaskRunner: TaskRunner<StartTaskOptions> = async ({ watchThemes, noTs
try {
await concurrently(
jobs.filter(job => !!job),
jobs.filter((job) => !!job),
{
killOthers: ['failure', 'failure'],
raw: true,
@@ -46,7 +46,7 @@ const moveFiles = (fromPath: string, toPath: string) => {
const files = ['README.md', 'CHANGELOG.md', 'index.js'];
return useSpinner(`Moving ${files.join(', ')} files`, () => {
const promises = files.map(file => fs.copyFile(`${fromPath}/${file}`, `${toPath}/${file}`));
const promises = files.map((file) => fs.copyFile(`${fromPath}/${file}`, `${toPath}/${file}`));
return Promise.all(promises);
});
};
@@ -57,7 +57,7 @@ const moveStaticFiles = async (packageRoot: string, pkg: any) => {
const staticFiles = await globby(`${packageRoot}/src/**/*.{png,svg,gif,jpg}`);
const pathSearch = new RegExp(`^${packageRoot}/src`);
const pathReplace = `${packageRoot}/compiled`;
const promises = staticFiles.map(file => fs.copyFile(file, file.replace(pathSearch, pathReplace)));
const promises = staticFiles.map((file) => fs.copyFile(file, file.replace(pathSearch, pathReplace)));
await Promise.all(promises);
});
}
@@ -72,7 +72,7 @@ const buildTaskRunner: TaskRunner<PackageBuildOptions> = async ({ scope }) => {
throw new Error('Provide packages with -s, --scope <packages>');
}
const scopes = scope.split(',').map(async s => {
const scopes = scope.split(',').map(async (s) => {
const packageRoot = path.resolve(__dirname, `../../../../grafana-${s}`);
const packageDist = `${packageRoot}/dist`;
const pkg = require(`${packageRoot}/package.json`);
@@ -32,7 +32,7 @@ const clean = () => useSpinner('Cleaning', () => rimraf(`${process.cwd()}/dist`)
const copyIfNonExistent = (srcPath: string, destPath: string) =>
copyFile(srcPath, destPath, COPYFILE_EXCL)
.then(() => console.log(`Created: ${destPath}`))
.catch(error => {
.catch((error) => {
if (error.code !== 'EEXIST') {
throw error;
}
@@ -90,7 +90,7 @@ export const lintPlugin = ({ fix }: Fixable = {}) =>
// @todo should remove this because the config file could be in a parent dir or within package.json
const configFile = await globby(resolvePath(process.cwd(), '.eslintrc?(.cjs|.js|.json|.yaml|.yml)')).then(
filePaths => {
(filePaths) => {
if (filePaths.length > 0) {
return filePaths[0];
} else {
@@ -113,7 +113,7 @@ const packagePluginRunner: TaskRunner<PluginCIOptions> = async ({ signatureType,
const docsDir = path.resolve(ciDir, 'docs');
const jobsDir = path.resolve(ciDir, 'jobs');
fs.exists(jobsDir, jobsDirExists => {
fs.exists(jobsDir, (jobsDirExists) => {
if (!jobsDirExists) {
throw new Error('You must run plugin:ci-build prior to running plugin:ci-package');
}
@@ -31,7 +31,7 @@ const yarnlink = () =>
console.log('Added dependencies required by local @grafana/toolkit. Do not checkin this package.json!');
});
const pluginDevRunner: TaskRunner<PluginBundleOptions> = async options => {
const pluginDevRunner: TaskRunner<PluginBundleOptions> = async (options) => {
if (options.yarnlink) {
return yarnlink();
}
@@ -1,7 +1,7 @@
import { Task, TaskRunner } from './task';
import { testPlugin, PluginTestOptions } from './plugin/tests';
const pluginTestRunner: TaskRunner<PluginTestOptions> = async options => {
const pluginTestRunner: TaskRunner<PluginTestOptions> = async (options) => {
await testPlugin(options);
};
@@ -9,7 +9,7 @@ const MANAGED_PLUGINS_SCOPES = ['internal', 'external'];
const bundleManagedPluginsRunner: TaskRunner<BundeManagedOptions> = async () => {
await Promise.all(
MANAGED_PLUGINS_SCOPES.map(async scope => {
MANAGED_PLUGINS_SCOPES.map(async (scope) => {
try {
const plugins = await fs.readdir(`${MANAGED_PLUGINS_PATH}/${scope}`);
if (plugins.length > 0) {
@@ -42,16 +42,16 @@ export const bundlePlugin = async ({ watch, production, preserveConsole }: Plugi
if (output.errors.length) {
console.log('Compilation failed!');
output.errors.forEach(e => console.log(e));
output.errors.forEach((e) => console.log(e));
if (output.warnings.length) {
console.log('Warnings:');
output.warnings.forEach(w => console.log(w));
output.warnings.forEach((w) => console.log(w));
}
}
if (output.errors.length === 0 && output.warnings.length) {
console.log('Compiled with warnings!');
output.warnings.forEach(w => console.log(w));
output.warnings.forEach((w) => console.log(w));
}
});
} else {
@@ -62,7 +62,7 @@ export const bundlePlugin = async ({ watch, production, preserveConsole }: Plugi
return;
}
if (stats.hasErrors()) {
stats.compilation.errors.forEach(e => {
stats.compilation.errors.forEach((e) => {
console.log(e.message);
});
@@ -49,8 +49,8 @@ export const getPluginId = (pluginDetails: PluginDetails) =>
export const getPluginKeywords = (pluginDetails: PluginDetails) =>
pluginDetails.keywords
.split(',')
.map(k => k.trim())
.filter(k => k !== '');
.map((k) => k.trim())
.filter((k) => k !== '');
export const verifyGitExists = async () => {
return new Promise((resolve, reject) => {
@@ -23,7 +23,7 @@ const compile = () =>
const savePackage = ({ path, pkg }: { path: string; pkg: {} }) =>
useSpinner('Updating package.json', async () => {
new Promise<void>((resolve, reject) => {
fs.writeFile(path, JSON.stringify(pkg, null, 2), err => {
fs.writeFile(path, JSON.stringify(pkg, null, 2), (err) => {
if (err) {
reject(err);
return;
@@ -60,13 +60,13 @@ const copyFiles = () => {
];
return useSpinner(`Moving ${files.join(', ')} files`, async () => {
const promises = files.map(file => {
const promises = files.map((file) => {
return new Promise<void>((resolve, reject) => {
const basedir = path.dirname(`${distDir}/${file}`);
if (!fs.existsSync(basedir)) {
fs.mkdirSync(basedir, { recursive: true });
}
fs.copyFile(`${cwd}/${file}`, `${distDir}/${file}`, err => {
fs.copyFile(`${cwd}/${file}`, `${distDir}/${file}`, (err) => {
if (err) {
reject(err);
return;
@@ -84,10 +84,10 @@ const copySassFiles = () => {
const files = ['_variables.generated.scss', '_variables.dark.generated.scss', '_variables.light.generated.scss'];
return useSpinner(`Copy scss files ${files.join(', ')} files`, async () => {
const sassDir = path.resolve(cwd, '../../public/sass/');
const promises = files.map(file => {
const promises = files.map((file) => {
return new Promise<void>((resolve, reject) => {
const name = file.replace('.generated', '');
fs.copyFile(`${sassDir}/${file}`, `${distDir}/sass/${name}`, err => {
fs.copyFile(`${sassDir}/${file}`, `${distDir}/sass/${name}`, (err) => {
if (err) {
reject(err);
return;
@@ -10,7 +10,7 @@ export const rmdir = (dirPath: string) => {
return;
}
fs.readdirSync(dirPath).forEach(entry => {
fs.readdirSync(dirPath).forEach((entry) => {
const entryPath = path.join(dirPath, entry);
if (fs.lstatSync(entryPath).isDirectory()) {
rmdir(entryPath);