Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: add eslint-plugin-markdown to lint codeblocks in md files #1124

Merged
merged 2 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,35 @@ module.exports = {
env: {
jest: true
}
},
{
// Add plugin for markdown `*.md` code blocks. Its config is in the new
// "flat" format, so we need to use the legacy config
extends: ['plugin:markdown/recommended-legacy'],
files: ['**/*.md'],
plugins: ['markdown'],
processor: 'markdown/markdown'
},
{
// Check markdown `*.md` contains valid code blocks
// https://www.npmjs.com/package/eslint-plugin-markdown#user-content-advanced-configuration
files: ['**/*.md/*.{cjs,js,mjs}'],
rules: {
quotes: ['error', 'single'],
// Ignore unused example code
'no-new': 'off',
'no-undef': 'off',
'no-unused-expressions': 'off',
'no-unused-vars': 'off',
'no-useless-constructor': 'off',

// Ignore paths to example modules
'import/no-unresolved': 'off',
'n/no-missing-import': 'off'
},
parserOptions: {
ecmaVersion: 'latest'
}
}
],
parserOptions: {
Expand Down
4 changes: 2 additions & 2 deletions docs/production/setting-up-javascript.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ Then import the JavaScript file before the closing `</body>` tag of your HTML pa

If you decide to import using a bundler, use `import` to import jQuery and all of the design systems’s components, then run the `initAll` function to initialise them:

```javascript
import $ from 'jquery'
```mjs
import { initAll } from '@ministryofjustice/frontend'
import $ from 'jquery'

window.$ = $
initAll()
Expand Down
149 changes: 149 additions & 0 deletions package-lock.json

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

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
"test:js": "jest src/",
"test:sass": "sass -q -I . gulp/dist-scss/all.scss >/dev/null && echo 'ok'",
"lint": "npm run lint:prettier && npm run lint:js && npm run lint:scss",
"lint:js": "npm run lint:js:cli -- \"**/*.{cjs,js,mjs}\"",
"lint:js": "npm run lint:js:cli -- \"**/*.{cjs,js,md,mjs}\"",
"lint:js:cli": "eslint --cache --cache-location .cache/eslint --cache-strategy content --color --ignore-path .gitignore --max-warnings 0",
"lint:prettier": "npm run lint:prettier:cli -- \"**/*.{cjs,js,json,md,mjs,scss,yaml,yml}\"",
"lint:prettier:cli": "prettier --cache --cache-location .cache/prettier --cache-strategy content --check",
"lint:scss": "npm run lint:scss:cli -- \"**/*.scss\"",
"lint:scss": "npm run lint:scss:cli -- \"**/*.{md,scss}\"",
"lint:scss:cli": "stylelint --cache --cache-location .cache/stylelint --cache-strategy content --color --ignore-path .gitignore --max-warnings 0",
"watch:11ty": "ENV=dev eleventy --input=./docs --output=public --serve",
"watch:package": "ENV=dev gulp watch:dev"
Expand Down Expand Up @@ -85,6 +85,7 @@
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jsdoc": "^50.4.3",
"eslint-plugin-markdown": "^5.1.0",
"eslint-plugin-n": "^16.6.2",
"eslint-plugin-promise": "^6.6.0",
"gulp": "^4.0.2",
Expand Down