Download next.js/packages/next/src/lib/eslint/hasEslintConfiguration.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.07 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/packages/next/src/lib/eslint/hasEslintConfiguration.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/packages/next/src/lib/eslint/hasEslintConfiguration.ts
-
curl -L -o hasEslintConfiguration.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/packages/next/src/lib/eslint/hasEslintConfiguration.ts
1.07 kB
| import { promises as fs } from 'fs' | |
| export type ConfigAvailable = { | |
| exists: boolean | |
| emptyEslintrc?: boolean | |
| emptyPkgJsonConfig?: boolean | |
| firstTimeSetup?: true | |
| } | |
| export async function hasEslintConfiguration( | |
| eslintrcFile: string | null, | |
| packageJsonConfig: { eslintConfig: any } | null | |
| ): Promise<ConfigAvailable> { | |
| const configObject = { | |
| exists: false, | |
| emptyEslintrc: false, | |
| emptyPkgJsonConfig: false, | |
| } | |
| if (eslintrcFile) { | |
| const content = await fs.readFile(eslintrcFile, { encoding: 'utf8' }).then( | |
| (txt) => txt.trim().replace(/\n/g, ''), | |
| () => null | |
| ) | |
| if ( | |
| content === '' || | |
| content === '{}' || | |
| content === '---' || | |
| content === 'module.exports = {}' | |
| ) { | |
| configObject.emptyEslintrc = true | |
| } else { | |
| configObject.exists = true | |
| } | |
| } else if (packageJsonConfig?.eslintConfig) { | |
| if (Object.keys(packageJsonConfig.eslintConfig).length) { | |
| configObject.exists = true | |
| } else { | |
| configObject.emptyPkgJsonConfig = true | |
| } | |
| } | |
| return configObject | |
| } | |