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

wd-173: add jsdoc support #192

Merged
merged 2 commits into from
Nov 17, 2023
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
22 changes: 22 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ extends:
- plugin:sonarjs/recommended
- plugin:unicorn/recommended
- plugin:perfectionist/recommended-natural
- plugin:jsdoc/recommended-typescript-flavor-error

plugins:
- simple-import-sort
Expand All @@ -17,6 +18,8 @@ parserOptions:
sourceType: module

settings:
jsdoc:
mode: typescript
import/resolver:
alias:
extensions:
Expand Down Expand Up @@ -111,6 +114,25 @@ rules:
import/extensions:
- error
- ignorePackages
jsdoc/require-jsdoc:
- error
- checkConstructors: false
checkGetters: true
checkSetters: true
contexts:
- ArrowFunctionExpression
- ClassProperty
- FunctionDeclaration
- FunctionExpression
- MethodDefinition
jsdoc/valid-types:
- off
jsdoc/require-returns-description:
- off
jsdoc/require-param-description:
- off
jsdoc/require-property-description:
- off

overrides:
- files:
Expand Down
4 changes: 2 additions & 2 deletions .lintstagedrc.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'*.{json,md}': prettier --write
'*.{json,yml,css,js,cjs,d.ts}': prettier --write
'*': make lint_editorconfig lint_fs
'*.css': make lint_css
'*.js': make lint_js
'*.js': make lint_js lint_type
2 changes: 2 additions & 0 deletions .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
plugins:
- 'prettier-plugin-jsdoc'
printWidth: 80
tabWidth: 2
useTabs: false
Expand Down
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ build: clean
# Prettify

prettify:
npx prettier --write "**/*.{json,yml,css,js,cjs}"
npx prettier --write "**/*.{json,yml,css,js,cjs,d.ts}"

# Lint

Expand All @@ -23,11 +23,13 @@ lint_fs:
lint_editorconfig:
npx editorconfig-checker
lint_prettify:
npx prettier --check "**/*.{json,yml,css,js,cjs}"
npx prettier --check "**/*.{json,yml,css,js,cjs,d.ts}"
lint_html:
npx node-w3c-validator -i build/*.html -f lint -evH
lint_css:
npx stylelint "source/styles/**/*.css"
lint_js:
npx eslint --ext .js "**/*.{js,cjs}"
lint: lint_fs lint_editorconfig lint_prettify lint_html lint_css lint_js
lint_type:
npx tsc --noEmit
lint: lint_fs lint_editorconfig lint_prettify lint_html lint_css lint_js lint_type
14 changes: 12 additions & 2 deletions eleventy.config.cjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
let fs = require(`node:fs/promises`)
let process = require(`node:process`)
let esbuild = require(`esbuild`)
let lightningcss = require(`lightningcss`)
let htmlMin = require(`html-minifier-terser`)
Expand All @@ -8,7 +10,6 @@ let packageJson = require(`./package.json`)
let Image = require(`@11ty/eleventy-img`)
let svgo = require(`svgo`)
let path = require(`node:path`)
let fs = require(`node:fs/promises`)

let isDevelopment = process.env.NODE_ENV === `development`

Expand All @@ -28,7 +29,10 @@ let Path = {
},
}

/** @param {import("@11ty/eleventy").UserConfig} config */
/**
* @param {import('@11ty/eleventy').UserConfig} config
* @returns {ReturnType<typeof import('@11ty/eleventy/src/defaultConfig')>}
*/
let init = (config) => {
// ignores
if (!isDevelopment) {
Expand All @@ -44,6 +48,7 @@ let init = (config) => {
config.addTemplateFormats(`json`)

config.addExtension(`json`, {
/** @type {import('@11ty/eleventy/src/Engines/TemplateEngine')['compile']} */
compile: async (_content, url) => {
if (url !== Path.DB) {
return
Expand Down Expand Up @@ -84,6 +89,7 @@ let init = (config) => {
config.addTemplateFormats(`css`)

config.addExtension(`css`, {
/** @type {import('@11ty/eleventy/src/Engines/TemplateEngine')['compile']} */
compile: async (_content, url) => {
if (url !== Path.CSS) {
return
Expand Down Expand Up @@ -114,6 +120,7 @@ let init = (config) => {
config.addTemplateFormats(`js`)

config.addExtension(`js`, {
/** @type {import('@11ty/eleventy/src/Engines/TemplateEngine')['compile']} */
compile: async (_content, url) => {
if (url !== Path.JS.MAIN) {
return
Expand Down Expand Up @@ -162,6 +169,7 @@ let init = (config) => {
config.addTemplateFormats(`png`)

config.addExtension(`png`, {
/** @type {import('@11ty/eleventy/src/Engines/TemplateEngine')['compile']} */
compile: async (_content, url) => {
return async () => {
let {
Expand All @@ -173,6 +181,7 @@ let init = (config) => {

if (url.includes(`.photo.`)) {
await Image(url, {
/** @type {import('@11ty/eleventy-img').BaseImageOptions['filenameFormat']} */
filenameFormat: (_id, source, _width, format) => {
let extension = path.extname(source)
let name = path.basename(source, extension)
Expand All @@ -194,6 +203,7 @@ let init = (config) => {
config.addTemplateFormats(`svg`)

config.addExtension(`svg`, {
/** @type {import('@11ty/eleventy/src/Engines/TemplateEngine')['compile']} */
compile: (content, url) => {
return () => {
if (url === `./source/images/icons/icon.svg`) {
Expand Down
10 changes: 0 additions & 10 deletions jsconfig.json

This file was deleted.

Loading
Loading