Skip to content

Commit

Permalink
Lint fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
kitschpatrol committed Sep 7, 2024
1 parent 9753ba8 commit c74181e
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"explorer.fileNesting.patterns": {
".env": ".env.*",
"package.json": ".*.cjs, .*.js, .*.json, .*.mjs, .*.toml, .*.ts, .*.yaml, .*.yml, .*ignore, .*rc, *config.cjs, *config.js, *config.json, *config.mjs, *config.toml, *config.ts, *config.yaml, *config.yml, *workspace.cjs, *workspace.js, *workspace.json, *workspace.mjs, *workspace.toml, *workspace.ts, *workspace.yaml, *workspace.yml lerna.json, netlify.toml, package-lock.json, pnpm*, turbo.json, vercel.json, workspace*, wrangler.toml, yarn.lock, yarn*",
"readme.md": "authors*, backers*, changelog*, citation*, code_of_conduct*, codeowners*, contributing*, contributors*, copying*, credits*, governance*, history*, license*, maintainers*, release_notes*, security*, sponsors*"
"readme.md": "authors*, backers*, changelog*, citation*, code_of_conduct*, contributing*, contributors*, copying*, credits*, governance*, history*, license*, maintainers*, release_notes*, security*, sponsors*"
},

"prettier.documentSelectors": [
Expand Down
5 changes: 3 additions & 2 deletions packages/cspell-config/cspell.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,20 @@
"fullstack",
"kp-acronyms",
"kp-brands",
"kp-files",
"kp-misc",
"kp-names",
"kp-tech"
],
"languageSettings": [
{
"languageId": "markdown,mdx",
"languageId": "markdown,mdx,json",
"ignoreRegExpList": [
// TODO does regex really need to be global?
"/^```(?:.|\\s)+?^```/mig", // Code fences
"\\$\\$.*?\\$\\$", // Ignore display MathJax $$...$$
"\\$[^$\\n]*\\$", // Ignore inline MathJax $...$
"[A-Z\\d\\-]{8,}" // Probable IDs or model names, e.g. AK-68ANHUB-S7KA-0004
"[A-Z\\d\\-]{8,}" // Probable IDs or model names, e.g. AK-68-S7KA-0004
]
}
],
Expand Down
2 changes: 2 additions & 0 deletions packages/cspell-config/dictionaries/kp-names.txt
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ joethei
Johan
Jóhann
Jóhannsson
johnsoncodehk
Jojo
Jong
Jonny
Expand Down Expand Up @@ -962,6 +963,7 @@ Udovich
Umar
Urbach
ürich
usernamehw
Vakili
Vanhemert
Vankatesh
Expand Down
2 changes: 2 additions & 0 deletions packages/cspell-config/dictionaries/kp-tech.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ Dyntube
emaculation
Emolex
ereader
errorlens
estree
ette
Excalidraw
Expand Down Expand Up @@ -479,6 +480,7 @@ tsup
Tukul
tweakpane
tweens
unifiedjs
unist
universaljs
unplugin
Expand Down
3 changes: 2 additions & 1 deletion packages/cspell-config/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,10 @@ It also includes a number of _custom_ dictionaries distributed with this package

- `kp-acronyms` Contains acronyms
- `kp-brands` Contains proper nouns like brand names
- `kp-files` File extensions and types
- `kp-misc` Contains general and miscellaneous words
- `kp-tech` Tech-specific terminology, some ambiguity vs. "brands"
- `kp-names` Human names and usernames
- `kp-tech` Tech-specific terminology, some ambiguity vs. "brands"

In your project's root `.cspell.json`, you can disable any combination of these dictionaries by adding them to the `dictionaries` array with a `!` prefix.

Expand Down
6 changes: 4 additions & 2 deletions packages/eslint-config/eslint.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const extendsPrefix = [
'plugin:n/recommended',
'plugin:unicorn/recommended',
'xo',
'plugin:perfectionist/recommended-natural',
'plugin:perfectionist/recommended-natural-legacy',
'prettier', // Needed here as well for files not caught by overrides
]
const extendsTypescript = ['plugin:@typescript-eslint/recommended-type-checked', 'xo-typescript']
Expand All @@ -31,7 +31,9 @@ const globalRulesPrefix = {
'perfectionist/sort-imports': [
'error',
{
'newlines-between': 'never',
// Is this already set in the preset?
type: 'natural',
newlinesBetween: 'never',
},
],
'unicorn/no-array-reduce': 'off',
Expand Down
2 changes: 1 addition & 1 deletion packages/repo-config/init/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"explorer.fileNesting.patterns": {
".env": ".env.*",
"package.json": ".*.cjs, .*.js, .*.json, .*.mjs, .*.toml, .*.ts, .*.yaml, .*.yml, .*ignore, .*rc, *config.cjs, *config.js, *config.json, *config.mjs, *config.toml, *config.ts, *config.yaml, *config.yml, lerna.json, netlify.toml, package-lock.json, , pnpm*, turbo.json, vercel.json, workspace*, wrangler.toml, yarn.lock, yarn*",
"readme.md": "authors*, backers*, changelog*, citation*, code_of_conduct*, codeowners*, contributing*, contributors*, copying*, credits*, governance*, history*, license*, maintainers*, release_notes*, security*, sponsors*"
"readme.md": "authors*, backers*, changelog*, citation*, code_of_conduct*, contributing*, contributors*, copying*, credits*, governance*, history*, license*, maintainers*, release_notes*, security*, sponsors*"
}
}
2 changes: 1 addition & 1 deletion packages/repo-config/src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env node
import { buildCommands } from '../../../src/command-builder.js'
import fse from 'fs-extra'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { packageUp } from 'package-up'
import { buildCommands } from '../../../src/command-builder.js'

await buildCommands('repo-config', '[Repo Config]', 'gray', {
init: {},
Expand Down
4 changes: 2 additions & 2 deletions packages/shared-config/src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node
import { type OptionCommands, buildCommands, execute } from '../../../src/command-builder.js'
import { capabilities } from '../build/capabilities.js'
import chalk from 'chalk'
import { buildCommands, execute, type OptionCommands } from '../../../src/command-builder.js'
import { capabilities } from '../build/capabilities.js'

function kebabCase(text: string): string {
return text.replaceAll(/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g, (match) => '-' + match.toLowerCase())
Expand Down
12 changes: 6 additions & 6 deletions src/command-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
// Creates cli bin files for each package
// based on the shared-config field in their package.js

import { merge, stringify } from './json-utils.js'
import type { Flag } from 'meow'
// eslint-disable-next-line unicorn/import-style
import chalk, { type foregroundColorNames } from 'chalk'
import { cosmiconfig } from 'cosmiconfig'
import { type ExecaError, execa } from 'execa'
import { execa, type ExecaError } from 'execa'
import fse from 'fs-extra'
import meow from 'meow'
import type { Flag } from 'meow'
import path from 'node:path'
import { Transform } from 'node:stream'
import { PassThrough, type Stream } from 'node:stream'
import { fileURLToPath } from 'node:url'
import { packageUp } from 'package-up'
import { merge, stringify } from './json-utils.js'

// TODO get these from meow?
type StringFlag = Flag<'string', string> | Flag<'string', string[], true>
Expand Down Expand Up @@ -50,7 +50,7 @@ export type OptionCommands = {

function createStreamTransform(logPrefix: string | undefined, logColor: ChalkColor): Transform {
return new Transform({
transform(chunk: Uint8Array | string, _: BufferEncoding, callback) {
transform(chunk: string | Uint8Array, _: BufferEncoding, callback) {
// Convert the chunk to a string and prepend the string to each line
const lines: string[] = chunk
.toString()
Expand Down Expand Up @@ -324,7 +324,7 @@ export async function buildCommands(
if (typeof optionCommand.command === 'function') {
checkArguments(input, optionCommand, logStream)

const args = input.length === 0 ? optionCommand.defaultArguments ?? [] : input
const args = input.length === 0 ? (optionCommand.defaultArguments ?? []) : input
const options = optionCommand.options ?? []

// Custom function execution is always the same
Expand Down Expand Up @@ -432,7 +432,7 @@ export async function buildCommands(
}

case 'printConfig': {
const args = input.length === 0 ? optionCommand.defaultArguments ?? ['.'] : input
const args = input.length === 0 ? (optionCommand.defaultArguments ?? ['.']) : input
const filePath = args?.at(0)

// Brittle, could pass config name to commandBuilder() instead
Expand Down
4 changes: 2 additions & 2 deletions src/json-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-explicit-any */

import jsonColorizer from '@pinojs/json-colorizer'
import type { ArrayMergeOptions, Options } from 'deepmerge'
import jsonColorizer from '@pinojs/json-colorizer'
import deepmerge from 'deepmerge'
import jsonStringifyPrettyCompact from 'json-stringify-pretty-compact'

export function stringify(object: unknown): string {
return jsonColorizer(
jsonStringifyPrettyCompact(object, {
indent: 2,
replacer(key, value) {
replacer(_, value) {
if (typeof value === 'function') {
// eslint-disable-next-line @typescript-eslint/ban-types
return (value as Function).name
Expand Down

0 comments on commit c74181e

Please sign in to comment.