diff --git a/src/core/defaults.js b/src/core/defaults.js new file mode 100644 index 0000000000..299aacd4a9 --- /dev/null +++ b/src/core/defaults.js @@ -0,0 +1,49 @@ +/** + * Sets the core defaults + */ +export const name = "core/defaults"; +import { rule as checkInternalSlots } from "./core/linter-rules/check-internal-slots"; +import { rule as checkPunctuation } from "./core/linter-rules/check-punctuation"; +import { definitionMap } from "./core/dfn-map"; +import linter from "./core/linter"; +import { rule as localRefsExist } from "./core/linter-rules/local-refs-exist"; +import { rule as noHeadinglessSectionsRule } from "./core/linter-rules/no-headingless-sections"; +import { rule as noHttpPropsRule } from "./core/linter-rules/no-http-props"; + +linter.register( + noHttpPropsRule, + noHeadinglessSectionsRule, + checkPunctuation, + localRefsExist, + checkInternalSlots +); + +const coreDefaults = { + lint: { + "no-headingless-sections": true, + "no-http-props": true, + "check-punctuation": false, + "local-refs-exist": true, + "check-internal-slots": false, + }, + pluralize: true, + highlightVars: true, + license: "CC-BY", + addSectionLinks: true, +}; + +export default coreDefaults; + +export function run(conf) { + // assign the defaults + Object.assign(conf, { + ...coreDefaults, + ...conf, + }); + Object.assign(conf.lint, { + ...coreDefaults.lint, + ...conf.lint, + }); + + Object.assign(conf, { definitionMap }); +} diff --git a/src/w3c/defaults.js b/src/w3c/defaults.js index 75655e2988..8e6f498b2e 100644 --- a/src/w3c/defaults.js +++ b/src/w3c/defaults.js @@ -2,35 +2,17 @@ * Sets the defaults for W3C specs */ export const name = "w3c/defaults"; -import { rule as checkInternalSlots } from "../core/linter-rules/check-internal-slots"; -import { rule as checkPunctuation } from "../core/linter-rules/check-punctuation"; +import coreDefaults from "../core/defaults"; import { definitionMap } from "../core/dfn-map"; import linter from "../core/linter"; -import { rule as localRefsExist } from "../core/linter-rules/local-refs-exist"; -import { rule as noHeadinglessSectionsRule } from "../core/linter-rules/no-headingless-sections"; -import { rule as noHttpPropsRule } from "../core/linter-rules/no-http-props"; import { rule as privsecSectionRule } from "./linter-rules/privsec-section"; -linter.register( - noHttpPropsRule, - privsecSectionRule, - noHeadinglessSectionsRule, - checkPunctuation, - localRefsExist, - checkInternalSlots -); +linter.register(privsecSectionRule); const w3cDefaults = { lint: { - "no-headingless-sections": true, "privsec-section": true, - "no-http-props": true, - "check-punctuation": false, - "local-refs-exist": true, - "check-internal-slots": false, }, - pluralize: true, - highlightVars: true, doJsonLd: false, license: "w3c-software-doc", specStatus: "base", @@ -43,7 +25,6 @@ const w3cDefaults = { url: "https://www.w3.org/", }, ], - addSectionLinks: true, }; export function run(conf) { @@ -51,10 +32,12 @@ export function run(conf) { // assign the defaults Object.assign(conf, { ...w3cDefaults, + ...coreDefaults, ...conf, }); Object.assign(conf.lint, { ...w3cDefaults.lint, + ...coreDefaults.lint, ...conf.lint, });