Skip to content

Commit

Permalink
style(lint): resolve errors
Browse files Browse the repository at this point in the history
1. Ignore security/detect-non-literal-fs-filename

#44,#187
  • Loading branch information
gregswindle committed Feb 16, 2018
1 parent 92b0c3d commit 36eaf52
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
34 changes: 19 additions & 15 deletions lib/crc/crc-responsibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,25 @@ const getComments = (crcClass) => {
));
};

const descriptionFromContext = (context) => {
const cxtComments = get(context, "code.ast.comments", []);
const comments =
cxtComments.map((comment) => doctrine.parse(comment.value, {
"recoverable": true,
"sloppy": true,
"unwrap": true
}));

const description =
getPrimaryDescription(comments) || getDescriptionFromTags(comments);

const SINGLE_SPACE = " ";

return replace(description, /\s+/gim, SINGLE_SPACE).trim();
};

const getDescription =
(crcClass) => CrcResponsibility.descriptionFromContext(crcClass.meta.context);
(crcClass) => descriptionFromContext(crcClass.meta.context);

/**
* Assigns a value to CrcClass#description, if one exists in JSDoc comments.
Expand Down Expand Up @@ -87,20 +104,7 @@ class CrcResponsibility {
*/

static descriptionFromContext (context) {
const cxtComments = get(context, "code.ast.comments", []);
const comments =
cxtComments.map((comment) => doctrine.parse(comment.value, {
"recoverable": true,
"sloppy": true,
"unwrap": true
}));

const description =
getPrimaryDescription(comments) || getDescriptionFromTags(comments);

const SINGLE_SPACE = " ";

return replace(description, /\s+/gim, SINGLE_SPACE).trim();
return descriptionFromContext(context);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/crc/source-code-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ const {SourceCode} = require("eslint");
* @ignore
*/

// eslint-disable-next-line security/detect-non-literal-fs-filename
const toSourceString =
// eslint-disable-next-line security/detect-non-literal-fs-filename
(filePath) => fs.readFileSync(path.resolve(filePath)).toString();

/**
Expand Down
2 changes: 2 additions & 0 deletions lib/formatters/md/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const importOpts = {

const getTempate = (templateName, options = {
}) => template(
// eslint-disable-next-line security/detect-non-literal-fs-filename
fs.readFileSync(
path.join(__dirname, templateName),
"utf-8"
Expand Down Expand Up @@ -95,6 +96,7 @@ const createTableOfContents = (crcModels, toc) => {
const decorateBuiltInsWithLinks = (crcModels) => {
const mdnRef = new MdnReference();
crcModels.forEach((model, index, models) => {
// eslint-disable-next-line security/detect-non-literal-fs-filename
const hyperlink = mdnRef.link(model.class.meta.kind);
nth(models, index).class.meta.kind = hyperlink;
});
Expand Down

0 comments on commit 36eaf52

Please sign in to comment.