Skip to content

Commit

Permalink
Add core/defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
pradeepgangwar committed Jan 23, 2019
1 parent 9cbd753 commit 5d6465c
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 21 deletions.
49 changes: 49 additions & 0 deletions src/core/defaults.js
Original file line number Diff line number Diff line change
@@ -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 });
}
25 changes: 4 additions & 21 deletions src/w3c/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -43,18 +25,19 @@ const w3cDefaults = {
url: "https://www.w3.org/",
},
],
addSectionLinks: true,
};

export function run(conf) {
if (conf.specStatus === "unofficial") return;
// assign the defaults
Object.assign(conf, {
...w3cDefaults,
...coreDefaults,
...conf,
});
Object.assign(conf.lint, {
...w3cDefaults.lint,
...coreDefaults.lint,
...conf.lint,
});

Expand Down

0 comments on commit 5d6465c

Please sign in to comment.