From a26563ba29efb65f6bc9545e551102f03a155f4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ari=20Perkki=C3=B6?= Date: Sun, 12 Jun 2022 11:41:39 +0000 Subject: [PATCH] feat!: never create configuration files BREAKING CHANGE: Previously a default configuration file was created when given configuration file was not found. Removed configuration file creation completely. It was completely useless. --- lib/config/config-templates.ts | 97 ---------------------------------- lib/config/config.ts | 19 ------- 2 files changed, 116 deletions(-) delete mode 100644 lib/config/config-templates.ts diff --git a/lib/config/config-templates.ts b/lib/config/config-templates.ts deleted file mode 100644 index baf1f6fb..00000000 --- a/lib/config/config-templates.ts +++ /dev/null @@ -1,97 +0,0 @@ -// prettier-ignore -export const CONFIGURATION_FILE_TEMPLATE = -`module.exports = { - /** Repositories to scan */ - repositories: ['reactjs/reactjs.org'], - - /** Extensions of files under scanning */ - extensions: ['.js'], - - /** Optional pattern used to exclude paths */ - pathIgnorePattern: \`(\${[ - 'node_modules', - '\\\\/\\\\.', // Any file or directory starting with dot, e.g. ".git" - 'test-results', - 'tests', - 'docs', - ].join('|')})\`, - - /** Optional max file size (bytes) used to exclude bigger files. Defaults to 2 megabytes. */ - maxFileSizeBytes: 2000000, - - /** Optional array of rules used to filter out results. Use undefined or empty array when ESLint crashes are the only interest */ - rulesUnderTesting: ['react/no-direct-mutation-state'], - - /** Optional syntax for the result parser. Valid values are plaintext, markdown. Defaults to markdown on CLI, plaintext on CI */ - resultParser: 'markdown', - - /** Maximum amount of tasks ran concurrently */ - concurrentTasks: 5, - - /** ESLint configuration */ - eslintrc: { - root: true, - env: { - es6: true, - }, - parserOptions: { - ecmaVersion: 2020, - sourceType: 'module', - ecmaFeatures: { - jsx: true, - }, - }, - settings: { - react: { - version: '16.13.1', - }, - }, - plugins: ['react'], - rules: { - 'react/no-direct-mutation-state': ['error'], - }, - }, - - /** Optional boolean flag used to set CI mode. process.env.CI is used when not set. */ - CI: false, - - /** Optional setting for log level. Valid values are verbose, info, warn, error. Defaults to verbose. */ - logLevel: 'verbose', - - /** Optional boolean flag used to enable caching of cloned repositories. For CIs it's ideal to disable caching. Defaults to true. */ - cache: true, - - /** Optional time limit in seconds for the scan. Scan is interrupted after reaching the limit. Defaults to 5 hours 30 minutes. */ - timeLimit: 5.5 * 60 * 60, // 5 hours 30 minutes - - /** Optional boolean flag used to enable result comparison. Defaults to false. */ - compare: false, - - /** Optional boolean flag used to enable result comparison reference updating. Used only when compare is enable. Defaults to true. */ - updateComparisonReference: true, - - /** - * Optional callback invoked once scan is complete. - * - * @param {{ - * repository: string, - * repositoryOwner: string, - * rule: string, - * message: string, - * path: string, - * link: string, - * extension: string, - * source: string, - * error: (string|undefined), - * }[]} results Results of the scan, if any - * - * @param {{ - * added: {}[], - * removed: {}[] - * }} comparisonResults Comparison results of the scan, if any - * @returns {Promise|void} - */ - onComplete: async function onComplete(results, comparisonResults) { - // Extend the process with custom features, e.g. send results to email, create issues to Github... - }, -}`; diff --git a/lib/config/config.ts b/lib/config/config.ts index 170b6717..bbc1bc3a 100644 --- a/lib/config/config.ts +++ b/lib/config/config.ts @@ -4,7 +4,6 @@ import chalk from 'chalk'; import { workerData, isMainThread } from 'worker_threads'; import { getConfigWithDefaults } from './validator'; -import { CONFIGURATION_FILE_TEMPLATE } from './config-templates'; import { loadConfig } from './load'; import { WorkerData } from '@engine/types'; @@ -45,25 +44,7 @@ export function resolveConfigurationLocation(): string { const CONFIGURATION_FILE = resolveConfigurationLocation(); if (!fs.existsSync(CONFIGURATION_FILE)) { - let defaultCreated = false; - - if (CONFIGURATION_FILE === DEFAULT_CONFIGURATION_FILE_JS) { - fs.writeFileSync( - CONFIGURATION_FILE, - CONFIGURATION_FILE_TEMPLATE, - 'utf8' - ); - defaultCreated = true; - } - console.log(chalk.red(`Missing configuration file ${CONFIGURATION_FILE}.`)); - if (defaultCreated) { - console.log( - chalk.green( - `Default configuration file created: ${DEFAULT_CONFIGURATION_FILE_JS}` - ) - ); - } process.exit(); }