Skip to content

Commit

Permalink
Tiny improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
hudochenkov committed Sep 16, 2021
1 parent 25dd99e commit 3d821e2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
14 changes: 7 additions & 7 deletions lib/createStylelint.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = function createStylelint(options = {}) {
stylelint._extendExplorer = cosmiconfig(null, {
transform: augmentConfig.augmentConfigExtended.bind(
null,
/** @type{StylelintInternalApi} */ (stylelint),
/** @type {StylelintInternalApi} */ (stylelint),
),
stopDir: STOP_DIR,
});
Expand All @@ -38,22 +38,22 @@ module.exports = function createStylelint(options = {}) {
stylelint._postcssResultCache = new Map();
stylelint._createStylelintResult = createStylelintResult.bind(
null,
/** @type{StylelintInternalApi} */ (stylelint),
/** @type {StylelintInternalApi} */ (stylelint),
);
stylelint._getPostcssResult = getPostcssResult.bind(
null,
/** @type{StylelintInternalApi} */ (stylelint),
/** @type {StylelintInternalApi} */ (stylelint),
);
stylelint._lintSource = lintSource.bind(null, /** @type{StylelintInternalApi} */ (stylelint));
stylelint._lintSource = lintSource.bind(null, /** @type {StylelintInternalApi} */ (stylelint));

stylelint.getConfigForFile = getConfigForFile.bind(
null,
/** @type{StylelintInternalApi} */ (stylelint),
/** @type {StylelintInternalApi} */ (stylelint),
);
stylelint.isPathIgnored = isPathIgnored.bind(
null,
/** @type{StylelintInternalApi} */ (stylelint),
/** @type {StylelintInternalApi} */ (stylelint),
);

return /** @type{StylelintInternalApi} */ (stylelint);
return /** @type {StylelintInternalApi} */ (stylelint);
};
10 changes: 5 additions & 5 deletions lib/normalizeAllRuleSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ const rules = require('./rules');
* @return {StylelintConfig}
*/
function normalizeAllRuleSettings(config) {
if (!config.rules) return config;

/** @type {StylelintConfigRules} */
const normalizedRules = {};

if (!config.rules) return config;

for (const [ruleName, rawRuleSettings] of Object.entries(config.rules)) {
const rule = rules[ruleName] || (config.pluginFunctions && config.pluginFunctions[ruleName]);

if (!rule) {
normalizedRules[ruleName] = [];
} else {
if (rule) {
normalizedRules[ruleName] = normalizeRuleSettings(
rawRuleSettings,
ruleName,
rule.primaryOptionArray,
);
} else {
normalizedRules[ruleName] = [];
}
}

Expand Down
16 changes: 8 additions & 8 deletions lib/printConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ const path = require('path');
* @param {import('stylelint').StylelintStandaloneOptions} options
* @returns {Promise<StylelintConfig | null>}
*/
module.exports = function printConfig(options) {
const code = options.code;
const config = options.config;
const configBasedir = options.configBasedir;
const configFile = options.configFile;
const globbyOptions = options.globbyOptions;
const files = options.files;

module.exports = function printConfig({
code,
config,
configBasedir,
configFile,
globbyOptions,
files,
}) {
const isCodeNotFile = code !== undefined;

if (!files || files.length !== 1 || isCodeNotFile) {
Expand Down

0 comments on commit 3d821e2

Please sign in to comment.