Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = () => {
if (!zeroignore) {
zeroignore = nodeignore();
// add default ignores
zeroignore.add(DEFAULTIGNORES);
// read .zeroignore file if present
var zeroignorePath = path.join(process.env.PROJECTPATH, ".zeroignore");
if (fs.existsSync(zeroignorePath)) {
zeroignore.add(fs.readFileSync(zeroignorePath, "utf8"));
}
}
return zeroignore;
};
return diff.split("\n");
}
exports.getStagedFiles = getStagedFiles;
/**
* @param {string} file
* @return {boolean}
*/
function isStaged(file) {
return getStagedFiles().indexOf(file) !== -1;
}
exports.isStaged = isStaged;
const gitignore = ignore().add(
fs.readFileSync(require.resolve("../../.gitignore"), "utf8")
);
/**
* @param {string} file
* @return {boolean}
*/
function isIgnored(file) {
return gitignore.ignores(file);
}
exports.isIgnored = isIgnored;
? ignoreFilePath
: path.resolve(process.cwd(), ignoreFilePath);
let ignoreText = '';
try {
ignoreText = fs.readFileSync(absoluteIgnoreFilePath, 'utf8');
} catch (readError) {
if (readError.code !== FILE_NOT_FOUND_ERROR_CODE) throw readError;
}
/**
* TODO TYPES
* @type {any}
*/
const ignorePattern = options.ignorePattern || [];
const ignorer = ignore()
.add(ignoreText)
.add(ignorePattern);
return ignorer;
};
? ignoreFilePath
: path.resolve(process.cwd(), ignoreFilePath);
let ignoreText = '';
try {
ignoreText = fs.readFileSync(absoluteIgnoreFilePath, 'utf8');
} catch (readError) {
if (readError.code !== FILE_NOT_FOUND_ERROR_CODE) throw readError;
}
/**
* TODO TYPES
* @type {any}
*/
const ignorePattern = options.ignorePattern || [];
const ignorer = ignore()
.add(ignoreText)
.add(ignorePattern);
const isValidCode = typeof code === 'string';
if ((!files && !isValidCode) || (files && (code || isValidCode))) {
throw new Error('You must pass stylelint a `files` glob or a `code` string, though not both');
}
/** @type {Function} */
let formatterFunction;
if (typeof formatter === 'string') {
formatterFunction = formatters[formatter];
if (formatterFunction === undefined) {
Object.entries(config.rules).forEach(([label, pattern]) => {
if (ignore_1.default()
.add(pattern)
.ignores(file)) {
acc.push(label);
}
});
return acc;