Sha256: 2d7f4d9153003b8c77728dd43f370a393fc66cea64a6c87254fdcabf4d8c69d9

Contents?: true

Size: 1.01 KB

Versions: 23

Compression:

Stored size: 1.01 KB

Contents

'use strict';
// Try to get file ignorer from '.stylelintignore'

const fs = require('fs');
const path = require('path');
const { default: ignore } = require('ignore');

const DEFAULT_IGNORE_FILENAME = '.stylelintignore';
const FILE_NOT_FOUND_ERROR_CODE = 'ENOENT';

/** @typedef {import('stylelint').StylelintStandaloneOptions} StylelintOptions */

/**
 * @param {StylelintOptions} options
 * @return {import('ignore').Ignore}
 */
module.exports = function (options) {
	const ignoreFilePath = options.ignorePath || DEFAULT_IGNORE_FILENAME;
	const absoluteIgnoreFilePath = path.isAbsolute(ignoreFilePath)
		? 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;
};

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
trusty-cms-5.0.7 node_modules/stylelint/lib/utils/getFileIgnorer.js
trusty-cms-5.0.6 node_modules/stylelint/lib/utils/getFileIgnorer.js
trusty-cms-5.0.5 node_modules/stylelint/lib/utils/getFileIgnorer.js
trusty-cms-5.0.4 node_modules/stylelint/lib/utils/getFileIgnorer.js
trusty-cms-5.0.3 node_modules/stylelint/lib/utils/getFileIgnorer.js
trusty-cms-5.0.2 node_modules/stylelint/lib/utils/getFileIgnorer.js
trusty-cms-5.0.1 node_modules/stylelint/lib/utils/getFileIgnorer.js
trusty-cms-4.3.5 node_modules/stylelint/lib/utils/getFileIgnorer.js
trusty-cms-5.0.0 node_modules/stylelint/lib/utils/getFileIgnorer.js
trusty-cms-4.3.4 node_modules/stylelint/lib/utils/getFileIgnorer.js
trusty-cms-4.3.3 node_modules/stylelint/lib/utils/getFileIgnorer.js
trusty-cms-4.3.2 node_modules/stylelint/lib/utils/getFileIgnorer.js
trusty-cms-4.3.1 node_modules/stylelint/lib/utils/getFileIgnorer.js
trusty-cms-4.3 node_modules/stylelint/lib/utils/getFileIgnorer.js
trusty-cms-4.2.3 node_modules/stylelint/lib/utils/getFileIgnorer.js
trusty-cms-4.2.2 node_modules/stylelint/lib/utils/getFileIgnorer.js
trusty-cms-4.2.1 node_modules/stylelint/lib/utils/getFileIgnorer.js
trusty-cms-4.2 node_modules/stylelint/lib/utils/getFileIgnorer.js
trusty-cms-4.1.9 node_modules/stylelint/lib/utils/getFileIgnorer.js
trusty-cms-4.1.8 node_modules/stylelint/lib/utils/getFileIgnorer.js