mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-01 09:47:56 +08:00
This also adds CC-BY-4.0 to the list of accepted licenses. DISABLE_THIRD_PARTY_CHECK=update dependencies Bug: chromium:1083142 Change-Id: I8612de2fba52dae32eeb71af79d5aacfde52142b Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2220097 Reviewed-by: Paul Lewis <aerotwist@chromium.org> Commit-Queue: Mathias Bynens <mathias@chromium.org>
35 lines
998 B
JavaScript
35 lines
998 B
JavaScript
'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;
|
|
}
|
|
|
|
const ignorePattern = options.ignorePattern || [];
|
|
const ignorer = ignore().add(ignoreText).add(ignorePattern);
|
|
|
|
return ignorer;
|
|
};
|