Comparing version 2.5.0 to 2.6.0
{ | ||
"name": "svglint", | ||
"version": "2.5.0", | ||
"version": "2.6.0", | ||
"description": "Linter for SVGs", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -51,3 +51,3 @@ # SVGLint | ||
In order to specify what should be linted SVGLint must be given a configuration object. | ||
If you are using the CLI, this configuration object is read from the file specified by `--config`. This defaults to `.svglintrc.js`, which will be searched for up through the directory tree - this is similar to tools such as ESLint. | ||
If you are using the CLI, this configuration object is read from the file specified by `--config`. This defaults to `.svglintrc.js`, which will be searched for up through the directory tree, or in the user's home directory (e.g. `~/.svglintrc.js` on Unix-like systems) - this is similar to tools such as ESLint. | ||
@@ -54,0 +54,0 @@ This configuration file should export a single object, of the format: |
import path from "path"; | ||
import fs from "fs"; | ||
import os from "os"; | ||
import process from "process"; | ||
import Logger from "../lib/logger.js"; | ||
const logger = Logger(""); | ||
/** | ||
@@ -79,2 +83,17 @@ * Check if a file exists | ||
/** | ||
* Get the configuration file to use from the home directory. | ||
* @returns {Promise<String,Boolean>} The path to the configuration file, or false | ||
*/ | ||
async function getConfigurationInHomedir() { | ||
let filepath; | ||
const homedirFile = path.join(os.homedir(), ".svglintrc.js"); | ||
if (await fileExists(homedirFile)) { | ||
filepath = homedirFile; | ||
} | ||
return filepath; | ||
} | ||
/** | ||
* Get the configuration file to use | ||
@@ -98,3 +117,8 @@ * @param {String} filename The filename to look for | ||
return await getDefaultConfigurationFileTraversingParents(folder); | ||
filepath = await getDefaultConfigurationFileTraversingParents(folder); | ||
if (filepath) { | ||
return filepath; | ||
} | ||
return await getConfigurationInHomedir(); | ||
} | ||
@@ -109,2 +133,3 @@ | ||
const filepath = await getConfigurationFile(filename, folder); | ||
logger.debug("Using configuration file: " + filepath); | ||
if (filepath) { | ||
@@ -111,0 +136,0 @@ const module = await import(`file://${filepath}`); |
152188
3136