diff --git a/.stylelintrc.js b/.stylelintrc.js index 916067c..11567f2 100644 --- a/.stylelintrc.js +++ b/.stylelintrc.js @@ -1,5 +1,5 @@ module.exports = { extends: [ - './build/configurations/scss-warn-autofixable.js', + './build/configurations/scss.js', ], }; diff --git a/configurations/css/index.js b/configurations/css/index.js index faba1ed..0afe320 100644 --- a/configurations/css/index.js +++ b/configurations/css/index.js @@ -1,4 +1,4 @@ const { processExports } = require('../../utils/helpers.js'); const { parts } = require('./_settings.js'); -module.exports = (autofixable) => processExports({ autofixable, parts }); +module.exports = (mode) => processExports({ mode, parts }); diff --git a/configurations/scss/index.js b/configurations/scss/index.js index e49298f..492402f 100644 --- a/configurations/scss/index.js +++ b/configurations/scss/index.js @@ -1,4 +1,4 @@ const { processExports } = require('../../utils/helpers.js'); const { parts, base } = require('./_settings.js'); -module.exports = (autofixable) => processExports({ autofixable, parts, base }); +module.exports = (mode) => processExports({ mode, parts, base }); diff --git a/package.json b/package.json index 2871b46..0ca3019 100644 --- a/package.json +++ b/package.json @@ -33,11 +33,11 @@ "exports": { ".": "./build/configurations/scss.js", "./css": "./build/configurations/css.js", - "./css/warn-autofixable": "./build/configurations/css-warn-autofixable.js", - "./css/off-autofixable": "./build/configurations/css-off-autofixable.js", + "./css/strict": "./build/configurations/css-strict.js", + "./css/quiet": "./build/configurations/css-quiet.js", "./scss": "./build/configurations/scss.js", - "./scss/warn-autofixable": "./build/configurations/scss-warn-autofixable.js", - "./scss/off-autofixable": "./build/configurations/scss-off-autofixable.js" + "./scss/strict": "./build/configurations/scss-strict.js", + "./scss/quiet": "./build/configurations/scss-quiet.js" }, "main": "./build/configurations/scss.js", "scripts": { diff --git a/utils/build.js b/utils/build.js index dd7dd9f..e602fed 100644 --- a/utils/build.js +++ b/utils/build.js @@ -31,28 +31,23 @@ const toExports = (source) => `module.exports = ${util.inspect(source, { maxArrayLength: 9999, depth: 999 })}` .replace(/["'](require\(.*\))["']/g, '$1'); // unwrap require call -const getNames = ({ name }, autofixable) => { - const filename = (autofixable === 'bypass') - ? `${name}.js` - : `${name}-${autofixable}-autofixable.js`; - - const exportsName = (autofixable === 'bypass') - ? `./${name}` - : `./${name}/${autofixable}-autofixable`; +const getNames = ({ name }, mode) => { + const filename = (mode === 'default') ? `${name}.js` : `${name}-${mode}.js`; + const exportsName = (mode === 'default') ? `./${name}` : `./${name}/${mode}`; return { filename, exportsName }; }; (async () => { await configurations.forEach(async (config) => { - await ['bypass', 'warn', 'off'].forEach(async (autofixable) => { + await ['default', 'strict', 'quiet'].forEach(async (mode) => { const extend = config.extend - ? `./${getNames({ name: config.extend }, autofixable).filename}` + ? `./${getNames({ name: config.extend }, mode).filename}` : null; - let configSource = makeConfig([{ ...config, extend, autofixable }]); + let configSource = makeConfig([{ ...config, extend, mode }]); configSource = toExports(configSource); - const { filename, exportsName } = getNames(config, autofixable); + const { filename, exportsName } = getNames(config, mode); exportsField[exportsName] = `${CONFIGS_DIR_REL}${filename}`; fs.writeFileSync(`${CONFIGS_DIR}/${filename}`, configSource); diff --git a/utils/helpers.js b/utils/helpers.js index 5e4e460..92fb664 100644 --- a/utils/helpers.js +++ b/utils/helpers.js @@ -20,19 +20,19 @@ const autofixableRulesToOff = (rules, autofixableList) => Object.fromEntries( .map(([rule, value]) => [rule, autofixableList.includes(rule) ? null : value]), ); -const getProcessedRules = ({ autofixable, base, rules }) => { - if (autofixable === 'bypass') return rules; +const getProcessedRules = ({ mode, base, rules }) => { + if (mode === 'strict') return rules; const autofixableRules = Object.entries(base.rules) .filter(([key]) => key.startsWith('+')) .map(([key]) => key.slice(1)); - return autofixable === 'warn' + return mode === 'default' ? autofixableRulesToWarn(rules, autofixableRules) - : autofixableRulesToOff(rules, autofixableRules); + : autofixableRulesToOff(rules, autofixableRules); // assume `quiet` }; -const processExports = ({ autofixable, base, parts }) => { +const processExports = ({ mode, base, parts }) => { const mergedParts = _mergeWith( {}, { ...base }, @@ -54,7 +54,7 @@ const processExports = ({ autofixable, base, parts }) => { }, []), ); - const processedRules = getProcessedRules({ autofixable, base: mergedParts, rules }); + const processedRules = getProcessedRules({ mode, base: mergedParts, rules }); return _mergeWith( { ...mergedParts, rules: processedRules }, diff --git a/utils/tools.js b/utils/tools.js index d1fcdd0..4f824d4 100644 --- a/utils/tools.js +++ b/utils/tools.js @@ -15,9 +15,9 @@ const makeConfig = (_configs) => { let result = {}; - configs.forEach(({ name, autofixable, overrides, extend }) => { + configs.forEach(({ name, mode, overrides, extend }) => { const configFactory = require(resolve(CONFIGS_PATH, name)); - let processed = configFactory(autofixable); + let processed = configFactory(mode); if (extend) { processed = {