| 111 | } |
| 112 | |
| 113 | function formatPluginInit({ eslintrc, patterns }: EslintOptions): string[] { |
| 114 | const useCustomEslintrc = |
| 115 | eslintrc !== '' && !ESLINT_CONFIG_PATTERN.test(eslintrc); |
| 116 | const customPatterns = patterns |
| 117 | .filter(s => s !== '' && s !== DEFAULT_PATTERN) |
| 118 | .map(singleQuote); |
| 119 | |
| 120 | const body = [ |
| 121 | useCustomEslintrc ? `eslintrc: ${singleQuote(eslintrc)}` : '', |
| 122 | customPatterns.length === 1 ? `patterns: ${customPatterns[0]}` : '', |
| 123 | customPatterns.length > 1 ? `patterns: [${customPatterns.join(', ')}]` : '', |
| 124 | ] |
| 125 | .filter(Boolean) |
| 126 | .join(', '); |
| 127 | |
| 128 | return body |
| 129 | ? [`await eslintPlugin({ ${body} }),`] |
| 130 | : ['await eslintPlugin(),']; |
| 131 | } |
| 132 | |
| 133 | async function isRecommended(targetDir: string): Promise<boolean> { |
| 134 | if (await detectEslintConfig(targetDir)) { |