Skip to content

Commit

Permalink
feat: lint JavaScript in Markdown files (#364)
Browse files Browse the repository at this point in the history
  • Loading branch information
greatislander authored Aug 16, 2023
1 parent c34409b commit cb9527c
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 13 deletions.
11 changes: 9 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
module.exports = {
extends: [
"fluid",
"plugin:yml/standard"
"plugin:yml/standard",
"plugin:markdown/recommended"
],
ignorePatterns: ["_site/", "src/_locales/messages.js", "!.*.cjs", "!.*.js", "!.github/"],
env: {
Expand All @@ -14,5 +15,11 @@ module.exports = {
},
parserOptions: {
ecmaVersion: 2020
}
},
overrides: [
{
files: ["**/*.md"],
processor: "markdown/markdown"
}
]
};
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,16 +250,16 @@ internationalization for a specific collection, you can do so in one of two ways
// Custom collections
const livePosts = post => post.date <= now && !post.data.draft;
siteConfig.locales.forEach(locale => {
eleventyConfig.addCollection(`posts_${locale}`, collection => {
return collection.getFilteredByGlob(`./src/collections/posts/${locale}/*.md`).filter(livePosts);
});
eleventyConfig.addCollection(`posts_${locale}`, collection => {
return collection.getFilteredByGlob(`./src/collections/posts/${locale}/*.md`).filter(livePosts);
});

// The following collection is used to create a collection of posts for the RSS feed.
eleventyConfig.addCollection(`postFeed_${locale}`, collection => {
return collection.getFilteredByGlob(`./src/collections/posts/${locale}/*.md`).filter(livePosts)
.reverse()
.slice(0, siteConfig.maxPostsInFeed);
});
// The following collection is used to create a collection of posts for the RSS feed.
eleventyConfig.addCollection(`postFeed_${locale}`, collection => {
return collection.getFilteredByGlob(`./src/collections/posts/${locale}/*.md`).filter(livePosts)
.reverse()
.slice(0, siteConfig.maxPostsInFeed);
});
});
```

Expand Down
25 changes: 25 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"dev": "cross-env NODE_ENV=development eleventy --serve",
"lint": "run-s -l lint:*",
"lint:css": "stylelint \"**/*.css\"",
"lint:js": "eslint \"**/*.js\"",
"lint:js": "eslint \"**/*.{js,md}\"",
"lint:markdown": "markdownlint-cli2 \"**/*.md\"",
"lint:yml": "eslint \"**/*.yml\"",
"start": "npm-run-all -l clean -p start:*",
Expand Down Expand Up @@ -47,6 +47,7 @@
"eslint": "8.47.0",
"eslint-config-fluid": "2.1.1",
"eslint-plugin-jsdoc": "46.4.6",
"eslint-plugin-markdown": "3.0.1",
"eslint-plugin-yml": "1.8.0",
"husky": "8.0.3",
"image-size": "1.0.2",
Expand All @@ -64,6 +65,9 @@
"lint-staged": {
"*.css": "stylelint --fix",
"*.{js,yml}": "eslint --fix",
"*.md": "markdownlint-cli2 --fix"
"*.md": [
"markdownlint-cli2 --fix",
"eslint --fix"
]
}
}

0 comments on commit cb9527c

Please sign in to comment.