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

feat(root): remove dts file for unicorn & perfectionist eslint plugin wd-270 #691

Merged
merged 2 commits into from
Jul 28, 2024
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
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
#!
import ffmpegInstaller from '@ffmpeg-installer/ffmpeg'
import ffprobeInstaller from '@ffprobe-installer/ffprobe'
import { ProcessExitCode, getShuffledItems } from '@whatislove.dev/shared'
import { getShuffledItems, ProcessExitCode } from '@whatislove.dev/shared'
import ffmpeg from 'fluent-ffmpeg'
import { existsSync } from 'node:fs'
import { readdir } from 'node:fs/promises'
import { join } from 'node:path'
import { exit } from 'node:process'
import path from 'node:path'
import process from 'node:process'

let PROCESS_PIECE_FILE_EXT = /** @type {const} */ (`.mp4`)

let processPiecesPath = join(import.meta.dirname, `./process-pieces`)
let processFilePath = join(
let processPiecesPath = path.join(import.meta.dirname, `./process-pieces`)
let processFilePath = path.join(
import.meta.dirname,
`../../public/videos`,
`process.mp4`,
Expand Down Expand Up @@ -39,7 +40,7 @@ let createProcessVideo = async () => {
let hasProcessFile = existsSync(processFilePath)

if (hasProcessFile) {
exit(ProcessExitCode.SUCCESS)
process.exit(ProcessExitCode.SUCCESS)
}

await createProcessVideo()
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LitElement, html } from 'lit'
import { html, LitElement } from 'lit'

import {
defineCustomElement,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LitElement, html } from 'lit'
import { html, LitElement } from 'lit'

import {
defineCustomElement,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { ControlType, getFormValues } from 'form-payload'
import { LitElement, html } from 'lit'
import { html, LitElement } from 'lit'

import {
defineCustomElement,
parseRawStyleSheet,
} from '~/libs/helpers/helpers.js'
import { TableNames, database } from '~/libs/modules/database/database.js'
import { database, TableNames } from '~/libs/modules/database/database.js'
import { notify } from '~/libs/modules/notify/notify.js'

import { Scene } from '../../enums/enums.js'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LitElement, html } from 'lit'
import { html, LitElement } from 'lit'

import {
defineCustomElement,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LitElement, html, nothing } from 'lit'
import { html, LitElement, nothing } from 'lit'
import { property } from 'lit/decorators.js'
import { createRef, ref } from 'lit/directives/ref.js'

Expand Down
2 changes: 1 addition & 1 deletion apps/careers-whatislove-dev/src/pages/root/root.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LitElement, html } from 'lit'
import { html, LitElement } from 'lit'
import { property } from 'lit/decorators.js'

import {
Expand Down
4 changes: 2 additions & 2 deletions apps/careers-whatislove-dev/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { join } from 'node:path'
import path from 'node:path'
import { defineConfig } from 'vite'
import babel from 'vite-plugin-babel'

Expand Down Expand Up @@ -29,7 +29,7 @@ let config = defineConfig({
alias: [
{
find: `~`,
replacement: join(import.meta.dirname, `src`),
replacement: path.join(import.meta.dirname, `src`),
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ export { App } from './app/app.jsx'
export {
Document,
G as PDFG,
PDFViewer,
Page,
Path as PDFPath,
PDFViewer,
Svg as PDFSvg,
Text,
View,
Expand Down
4 changes: 2 additions & 2 deletions apps/certifications-whatislove-dev/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import reactPlugin from '@vitejs/plugin-react'
import { join } from 'node:path'
import path from 'node:path'
import { defineConfig } from 'vite'

/** @type {import('vite').UserConfig} */
Expand All @@ -16,7 +16,7 @@ let config = defineConfig({
alias: [
{
find: `~`,
replacement: join(import.meta.dirname, `src`),
replacement: path.join(import.meta.dirname, `src`),
},
],
},
Expand Down
43 changes: 23 additions & 20 deletions apps/whatislove-dev/eleventy.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import htmlMin from 'html-minifier-terser'
import * as lightningcss from 'lightningcss'
import { parseHTML } from 'linkedom'
import markdownIt from 'markdown-it'
import { existsSync, readFileSync } from 'node:fs'
import { mkdir, readFile, writeFile } from 'node:fs/promises'
import { basename, extname, join } from 'node:path'
import fsSync from 'node:fs'
import fs from 'node:fs/promises'
import path from 'node:path'
import svgo from 'svgo'

import { default as environment } from './src/data/environment.js'
Expand Down Expand Up @@ -59,7 +59,7 @@ let CollectionPath = /** @type {const} */ ({
PAGES: `src/pages/!(404)/index.njk`,
})

let rawPackageJson = await readFile(new URL(`package.json`, import.meta.url))
let rawPackageJson = await fs.readFile(new URL(`package.json`, import.meta.url))
let packageJson = /** @type {(text: string) => PackageJson} */ (JSON.parse)(
rawPackageJson.toString(),
)
Expand Down Expand Up @@ -124,7 +124,7 @@ let init = (config) => {
outputFileSlug: (ogImage) => ogImage.data.page.fileSlug,
satoriOptions: {
fonts: [400, 700].map((weight) => ({
data: readFileSync(
data: fsSync.readFileSync(
new URL(
`src/fonts/red-hat-display-${weight.toString()}.woff`,
import.meta.url,
Expand Down Expand Up @@ -161,13 +161,13 @@ let init = (config) => {
config.addNunjucksAsyncShortcode(
`inlineImage`,
/**
* @param {string} path
* @param {string} url
* @returns {Promise<string>}
*/
async (path) => {
let extension = extname(path).slice(1)
let imgPath = join(config.dir.input, path)
let base64Image = await readFile(imgPath, `base64`)
async (url) => {
let extension = path.extname(url).slice(1)
let imgPath = path.join(config.dir.input, url)
let base64Image = await fs.readFile(imgPath, `base64`)

if (extension === `svg`) {
extension = `svg+xml`
Expand Down Expand Up @@ -195,15 +195,15 @@ let init = (config) => {
return
}

let rawDatabase = await readFile(Path.DB)
let rawDatabase = await fs.readFile(Path.DB)
let database = /** @type {(text: string) => Database} */ (
JSON.parse
)(rawDatabase.toString())

let isFolderExists = existsSync(`build/api`)
let isFolderExists = fsSync.existsSync(`build/api`)

if (!isFolderExists) {
await mkdir(`build/api`)
await fs.mkdir(`build/api`)
}

await Promise.all(
Expand All @@ -212,16 +212,19 @@ let init = (config) => {
database[/** @type {keyof Database} */ (databaseKey)],
)

return writeFile(`build/api/${databaseKey}.json`, payload)
return fs.writeFile(
`build/api/${databaseKey}.json`,
payload,
)
}),
)
},
outputFileExtension: `json`,
})

// html
config.addTransform(`html-minify`, async (content, path) => {
if (path.endsWith(`.html`)) {
config.addTransform(`html-minify`, async (content, url) => {
if (url.endsWith(`.html`)) {
return await htmlMin.minify(content, {
collapseBooleanAttributes: true,
collapseWhitespace: true,
Expand All @@ -232,8 +235,8 @@ let init = (config) => {
return content
})

config.addTransform(`html-transform`, (content, path) => {
if (path.endsWith(`.html`)) {
config.addTransform(`html-transform`, (content, url) => {
if (url.endsWith(`.html`)) {
let window = parseHTML(content)

for (let transform of TRANSFORMS) {
Expand Down Expand Up @@ -336,8 +339,8 @@ let init = (config) => {
* @returns {string}
*/
filenameFormat: (_id, source, width, format) => {
let extension = extname(source)
let name = basename(source, extension)
let extension = path.extname(source)
let name = path.basename(source, extension)

return `${name}-${width.toString()}w.${format.toString()}`
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ class WhatisloveMath {
MENTEE: `mentee`,
})

static NOTHING_TODO_VALUE = /** @type {const} */ (10)

static boostEntityToProfessionalValue = /** @type {const} */ ({
[WhatisloveMath.BoostEntity.BOOK]: 1,
[WhatisloveMath.BoostEntity.COURSE]: 3,
[WhatisloveMath.BoostEntity.MENTEE]: 10,
})

static NOTHING_TODO_VALUE = /** @type {const} */ (10)

/**
* @param {number} initialValue
* @param {ValuesOf<WhatisloveMath.BoostEntity>[]} boostEntities
Expand All @@ -24,8 +24,8 @@ class WhatisloveMath {
static calculateProfessionalLevel(initialValue = 0, ...boostEntities) {
let {
BoostEntity,
NOTHING_TODO_VALUE,
boostEntityToProfessionalValue,
NOTHING_TODO_VALUE,
} = WhatisloveMath

let hasBoostEntities = boostEntities.length > 0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Loader } from '~/libs/components/components.js'
import { checkIsBeforeElement } from '~/libs/helpers/helpers.js'
import {
Timeline as TTimeline,
TimelineApi,
TimelineFilter,
Timeline as TTimeline,
} from '~/modules/timeline/timeline.js'

import { TimelineForm, TimelineList } from './libs/components/components.js'
Expand Down
8 changes: 6 additions & 2 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,13 @@ let unicornConfig = {
/** @type {FlatConfig} */
let perfectionistConfig = {
plugins: {
perfectionist,
perfectionist: /** @type {Plugin} */ (
/** @type {unknown} */ (perfectionist)
),
},
rules: perfectionist.configs[`recommended-natural`].rules,
rules: /** @type {RulesRecord} */ (
perfectionist.configs[`recommended-natural`].rules
),
}

/** @type {FlatConfig} */
Expand Down
Loading
Loading