Skip to content

Commit

Permalink
FLUID-6205: Enabled further linting checks and fixed problems reported.
Browse files Browse the repository at this point in the history
  • Loading branch information
the-t-in-rtf committed Oct 17, 2017
1 parent 65decf7 commit ae8f3ea
Show file tree
Hide file tree
Showing 12 changed files with 98 additions and 69 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/static/lib/infusion
9 changes: 9 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "eslint-config-fluid",
"env": {
"browser": true
},
"plugins": [
"markdown"
]
}
31 changes: 19 additions & 12 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
/* eslint-env node */
/*
Copyright 2013-2014 OCAD University
Copyright 2017 Raising the Floor, International
Licensed under the Educational Community License (ECL), Version 2.0 or the New
BSD license. You may not use this file except in compliance with one these
Licenses.
Licensed under the Educational Community License (ECL), Version 2.0 or the New
BSD license. You may not use this file except in compliance with one these
Licenses.
You may obtain a copy of the ECL 2.0 License and BSD License at
https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
*/
You may obtain a copy of the ECL 2.0 License and BSD License at
https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
*/
"use strict";
module.exports = function (grunt) {

grunt.initConfig({
eslint: {
src: ["./src/**/*.js", "./tests/**/*.js", "./*.js"]
js: {
src: [ "./src/**/*.js", "./tests/**/*.js","./*.js" ]
},
md: {
src: [ "./*.md","./src/documents/**/*.md" ]
}
},
jsonlint: {
src: ["./src/**/*.json", "tests/**/*.json", "./*.json"]
Expand All @@ -29,21 +35,22 @@ module.exports = function (grunt) {
"no-duplicate-header": false, // We use duplicate nested headers, as in section 1 and 2 both have the same sub-section name.
"no-trailing-punctuation": false, // This catches headings that are questions, which seems wrong.
"first-header-h1": false,
"header-style": { style: "consistent"}, // This seemed the most reasonable balance, as we often have 3 heading styles in the same file.
"header-style": {style: "consistent"}, // This seemed the most reasonable balance, as we often have 3 heading styles in the same file.
"no-inline-html": false, // Obviously we need HTML
"line-length": false,
"ol-prefix": { style: "ordered" } // 1. 2. 3. etc
"ol-prefix": {style: "ordered"} // 1. 2. 3. etc
}
},
src: ["./*.md", "src/documents/**/*.md"]
}
}
},
mdlint: ["./*.md", "src/documents/**/*.md"]
});

grunt.loadNpmTasks("grunt-jsonlint");
grunt.loadNpmTasks("fluid-grunt-json5lint");
grunt.loadNpmTasks("fluid-grunt-eslint");
grunt.loadNpmTasks("grunt-markdownlint");

grunt.registerTask("lint", "Apply eslint, jsonlint, json5lint, and markdownlint", ["eslint", "jsonlint", "json5lint", "markdownlint"]);
grunt.registerTask("lint", "Apply eslint, jsonlint, json5lint, and markdownlint", ["eslint:js", "jsonlint", "json5lint", "markdownlint"]);
};
26 changes: 14 additions & 12 deletions docpad.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
/* eslint-env node */
/*
Copyright 2014 OCAD University
Copyright 2014 OCAD University
Copyright 2017 Raising the Floor, International
Licensed under the Educational Community License (ECL), Version 2.0 or the New
BSD license. You may not use this file except in compliance with one these
Licenses.
Licensed under the Educational Community License (ECL), Version 2.0 or the New
BSD license. You may not use this file except in compliance with one these
Licenses.
You may obtain a copy of the ECL 2.0 License and BSD License at
https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
You may obtain a copy of the ECL 2.0 License and BSD License at
https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
*/

var URI = require("URIjs");
"use strict";
var uri = require("urijs");
var path = require("path");
var fs = require("fs-extra");
var fs = require("fs-extra");

var docsVersion = "development";

Expand All @@ -38,14 +40,14 @@ var githubLocation = function () {
// Used for links to static resources such as CSS files. So that the generated
// DocPad output is independent of the URL that it is hosted at.
var relativeUrl = function (forUrl, relativeToUrl) {
return URI(forUrl).relativeTo(relativeToUrl);
return uri(forUrl).relativeTo(relativeToUrl);
};

// Helper function to determine if two values are equal
// Used to determine which table of contents category to display on a particular
// page.
var ifEqual = function (a, b, options) {
if (a == b) {
if (a === b) {
return options.fn(this);
} else {
return options.inverse(this);
Expand Down Expand Up @@ -91,7 +93,7 @@ module.exports = {
}
},
events: {
generateBefore: function (options) {
generateBefore: function () {
// Remove the previous incarnation of index.html since it causes a faulty redirect
fs.removeSync("out/index.html");
},
Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-env node */
/*
A stub to allow others to `fluid.require` this package and reuse its content, as in:
Expand Down
18 changes: 10 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,26 @@
"test": "node tests/all-tests.js"
},
"dependencies": {
"URIjs": "^1.14.1",
"docpad-plugin-ghpages": "2.4.4",
"docpad-plugin-handlebars": "2.3.0",
"docpad-plugin-highlightjs": "2.2.2",
"urijs": "1.19.0",
"docpad-plugin-ghpages": "2.6.1",
"docpad-plugin-handlebars": "2.4.0",
"docpad-plugin-highlightjs": "2.5.0",
"docpad-plugin-markit": "2.4.0",
"fs-extra": "0.18.0",
"fs-extra": "4.0.2",
"markdown-it-anchor": "4.0.0"
},
"devDependencies": {
"gpii-express": "1.0.10",
"infusion": "3.0.0-dev.20170724T165035Z.eee50c1",
"jsdom": "11.3.0",
"eslint": "4.9.0",
"eslint-config-fluid": "1.1.0",
"eslint-plugin-markdown": "1.0.0-beta.6",
"fluid-grunt-eslint": "18.1.2",
"fluid-grunt-json5lint": "1.0.0",
"gpii-express": "1.0.11",
"grunt": "1.0.1",
"grunt-jsonlint": "1.1.0",
"grunt-markdownlint": "1.0.42",
"infusion": "3.0.0-dev.20171006T195039Z.a128358",
"jsdom": "11.3.0",
"kettle": "1.7.0",
"node-jqunit": "1.1.7",
"request": "2.83.0"
Expand Down
4 changes: 2 additions & 2 deletions src/documents/EventInjectionAndBoiling.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ fluid.defaults("examples.boiledListenerComponent", {
simpleEvent: { // In practice it's unlikely that this listener would be written in the same grade as the event,
// since this case there would be little reason for the signature to mismatch. It's more likely
// this configuration would appear in another grade, or supplied as direct options,
// subcomponent options, or distributeOptions
// subcomponent options, or distributeOptions
funcName: "examples.externalListener",
args: ["{that}", "{arguments.0"]
}
Expand All @@ -216,7 +216,7 @@ using a standard upward-matching [IoC Context Selector](Contexts.md). If you nee
fluid.defaults("examples.injectedListenerParent", {
gradeNames: "fluid.component",
events: {
parentEvent: null,
parentEvent: null
},
components: {
child: {
Expand Down
68 changes: 36 additions & 32 deletions src/static/js/infusion-docs.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,42 @@
fluid.registerNamespace("fluid.docs");
/* eslint-env browser:true node:false */
(function ($) {
"use strict";
fluid.registerNamespace("fluid.docs");

fluid.docs.findActivePageToc = function () {
var allPages = $(".infusion-docs-TOC li .infusion-docs-TOC-pageName");
var activePage = allPages.filter(":not(a *)");
return activePage;
};
fluid.docs.findActivePageToc = function () {
var allPages = $(".infusion-docs-TOC li .infusion-docs-TOC-pageName");
var activePage = allPages.filter(":not(a *)");
return activePage;
};

fluid.docs.scrollActivePageTocIntoView = function () {
var active = fluid.docs.findActivePageToc();
if (active.length === 1) {
active[0].scrollIntoView();
}
};
fluid.docs.scrollActivePageTocIntoView = function () {
var active = fluid.docs.findActivePageToc();
if (active.length === 1) {
active[0].scrollIntoView();
}
};

fluid.docs.headerLinkMarkup = "<a class=\"infusion-docs-anchor\" aria-hidden=\"true\" href=\"%href\"><span class=\"octicon octicon-link\"></a>"
fluid.docs.headerLinkMarkup = "<a class=\"infusion-docs-anchor\" aria-hidden=\"true\" href=\"%href\"><span class=\"octicon octicon-link\"></a>";

fluid.docs.fabricateHeaderLinks = function () {
var headers = $(":header");
fluid.each(headers, function (header) {
var id = header.id;
var anchor = $(fluid.stringTemplate(fluid.docs.headerLinkMarkup, {href: "#" + id}));
var jHeader = $(header);
jHeader.prepend(anchor);
var link = $("span", anchor);
jHeader.add(anchor).hover(function () {
link.css("visibility", "visible");
}, function () {
link.css("visibility", "hidden");
fluid.docs.fabricateHeaderLinks = function () {
var headers = $(":header");
fluid.each(headers, function (header) {
var id = header.id;
var anchor = $(fluid.stringTemplate(fluid.docs.headerLinkMarkup, {href: "#" + id}));
var jHeader = $(header);
jHeader.prepend(anchor);
var link = $("span", anchor);
jHeader.add(anchor).hover(function () {
link.css("visibility", "visible");
}, function () {
link.css("visibility", "hidden");
});
link.css("visibility", "hidden"); // We do not apply this in the stylesheet because it does not work, for reasons I cannot explain
});
link.css("visibility", "hidden"); // We do not apply this in the stylesheet because it does not work, for reasons I cannot explain
});
};
};

fluid.docs.onLoad = function () {
fluid.docs.scrollActivePageTocIntoView();
fluid.docs.fabricateHeaderLinks();
};
fluid.docs.onLoad = function () {
fluid.docs.scrollActivePageTocIntoView();
fluid.docs.fabricateHeaderLinks();
};
})(jQuery);
3 changes: 2 additions & 1 deletion tests/all-tests.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-env node */
"use strict";
require("./js/test-docpad-links");
require("./js/test-link-checker");
require("./js/test-link-checker");
4 changes: 2 additions & 2 deletions tests/js/lib/link-checker.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fluid.tests.docs.linkChecker.scanSinglePageOrFinish = function (that) {
fluid.tests.docs.linkChecker.checkPageLinks(that);

var report = fluid.model.transformWithRules(that, that.options.rules.report);
that.events.onResultsAvailable.fire(report)
that.events.onResultsAvailable.fire(report);
}
};

Expand Down Expand Up @@ -163,4 +163,4 @@ fluid.defaults("fluid.tests.docs.linkChecker", {
args: ["{that}"]
}
}
});
});
1 change: 1 addition & 0 deletions tests/js/test-docpad-links.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-env node */
/*
Trawl our generated content and ensure that all links within and between pages on our site are valid.
Expand Down
1 change: 1 addition & 0 deletions tests/js/test-link-checker.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-env node */
/*
Test the link checker to confirm that it correctly identifies a range of broken links, and that it does not
Expand Down

0 comments on commit ae8f3ea

Please sign in to comment.