1
0
mirror of https://github.com/simple-icons/simple-icons.git synced 2025-07-12 22:21:23 +02:00

Add XO linter (#10643)

This commit is contained in:
LitoMore
2024-03-25 01:38:18 +08:00
committed by GitHub
parent d66bdb1380
commit bf69b6dee0
30 changed files with 633 additions and 493 deletions

View File

@ -1,17 +1,17 @@
import path from 'node:path';
import fs from 'node:fs/promises';
import { getDirnameFromImportMeta, getIconDataPath } from '../sdk.mjs';
import path from 'node:path';
import {getDirnameFromImportMeta, getIconDataPath} from '../sdk.mjs';
const __dirname = getDirnameFromImportMeta(import.meta.url);
/**
* Get JSON schema data.
* @param {String} rootDir Path to the root directory of the project.
* @param {String} rootDirectory Path to the root directory of the project.
*/
export const getJsonSchemaData = async (
rootDir = path.resolve(__dirname, '..'),
rootDirectory = path.resolve(__dirname, '..'),
) => {
const jsonSchemaPath = path.resolve(rootDir, '.jsonschema.json');
const jsonSchemaPath = path.resolve(rootDirectory, '.jsonschema.json');
const jsonSchemaString = await fs.readFile(jsonSchemaPath, 'utf8');
return JSON.parse(jsonSchemaString);
};
@ -19,14 +19,14 @@ export const getJsonSchemaData = async (
/**
* Write icons data to _data/simple-icons.json.
* @param {Object} iconsData Icons data object.
* @param {String} rootDir Path to the root directory of the project.
* @param {String} rootDirectory Path to the root directory of the project.
*/
export const writeIconsData = async (
iconsData,
rootDir = path.resolve(__dirname, '..'),
rootDirectory = path.resolve(__dirname, '..'),
) => {
await fs.writeFile(
getIconDataPath(rootDir),
getIconDataPath(rootDirectory),
`${JSON.stringify(iconsData, null, 4)}\n`,
'utf8',
);