Skip to content

Commit

Permalink
chore(deps): update antfu stylelint config (#5127)
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va authored Feb 6, 2024
1 parent 79a50c3 commit dcf0d6a
Show file tree
Hide file tree
Showing 35 changed files with 361 additions and 244 deletions.
2 changes: 2 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export default antfu(
'node/prefer-global/buffer': 'off',
'node/prefer-global/process': 'off',
'no-empty-pattern': 'off',
'antfu/indent-binary-ops': 'off',
'style/member-delimiter-style': ['error', { multiline: { delimiter: 'none' }, singleline: { delimiter: 'semi' } }],

'ts/no-invalid-this': 'off',

Expand Down
12 changes: 6 additions & 6 deletions examples/react-storybook/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ export function App() {
<h1>Storybook Testing Example</h1>
{isLoading && <span aria-label="loading">Loading...</span>}
{isSuccess
&& data!.map(post => (
<article key={post.id}>
<h2>{post.title}</h2>
<p>{post.body}</p>
</article>
))}
&& data!.map(post => (
<article key={post.id}>
<h2>{post.title}</h2>
<p>{post.body}</p>
</article>
))}
{isError && <span>Error loading posts</span>}
</main>
)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"test:browser:playwright": "pnpm -C test/browser run test:playwright"
},
"devDependencies": {
"@antfu/eslint-config": "^1.1.1",
"@antfu/eslint-config": "^1.2.1",
"@antfu/ni": "^0.21.12",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-json": "^6.0.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/browser/src/node/esmInjector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export function injectVitestModule(code: string, id: string, parse: PluginContex
s.appendLeft(
position,
`\nObject.defineProperty(${viInjectedKey}, "${name}", `
+ `{ enumerable: true, configurable: true, get(){ return ${local} }});`,
+ `{ enumerable: true, configurable: true, get(){ return ${local} }});`,
)
}

Expand Down Expand Up @@ -171,7 +171,7 @@ export function injectVitestModule(code: string, id: string, parse: PluginContex
s.remove(node.start, node.start + 15 /* 'export default '.length */)
s.append(
`\nObject.defineProperty(${viInjectedKey}, "default", `
+ `{ enumerable: true, configurable: true, value: ${name} });`,
+ `{ enumerable: true, configurable: true, value: ${name} });`,
)
}
else {
Expand Down
8 changes: 4 additions & 4 deletions packages/expect/src/jest-asymmetric-matchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ export class ArrayContaining<T = unknown> extends AsymmetricMatcher<Array<T>> {
const result
= this.sample.length === 0
|| (Array.isArray(other)
&& this.sample.every(item =>
other.some(another => equals(item, another, matcherContext.customTesters)),
))
&& this.sample.every(item =>
other.some(another => equals(item, another, matcherContext.customTesters)),
))

return this.inverse ? !result : result
}
Expand All @@ -185,7 +185,7 @@ export class Any extends AsymmetricMatcher<any> {
if (typeof sample === 'undefined') {
throw new TypeError(
'any() expects to be passed a constructor function. '
+ 'Please pass one or use anything() to match any object.',
+ 'Please pass one or use anything() to match any object.',
)
}
super(sample)
Expand Down
6 changes: 3 additions & 3 deletions packages/expect/src/jest-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,9 +435,9 @@ function hasPropertyInObject(object: object, key: string): boolean {

function isObjectWithKeys(a: any) {
return isObject(a)
&& !(a instanceof Error)
&& !(Array.isArray(a))
&& !(a instanceof Date)
&& !(a instanceof Error)
&& !(Array.isArray(a))
&& !(a instanceof Date)
}

export function subsetEquality(object: unknown, subset: unknown, customTesters: Array<Tester> = []): boolean | undefined {
Expand Down
4 changes: 2 additions & 2 deletions packages/snapshot/src/port/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ export default class SnapshotState {
// * There's no snapshot file or a file without this snapshot on a CI environment.
if (
(hasSnapshot && this._updateSnapshot === 'all')
|| ((!hasSnapshot || !snapshotIsPersisted)
&& (this._updateSnapshot === 'new' || this._updateSnapshot === 'all'))
|| ((!hasSnapshot || !snapshotIsPersisted)
&& (this._updateSnapshot === 'new' || this._updateSnapshot === 'all'))
) {
if (this._updateSnapshot === 'all') {
if (!pass) {
Expand Down
4 changes: 2 additions & 2 deletions packages/spy/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,8 @@ export const mocks = new Set<MockInstance>()

export function isMockFunction(fn: any): fn is MockInstance {
return typeof fn === 'function'
&& '_isMockFunction' in fn
&& fn._isMockFunction
&& '_isMockFunction' in fn
&& fn._isMockFunction
}

export function spyOn<T, S extends Properties<Required<T>>>(
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/client/composables/summary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export const filesSuccess = computed(() => files.value.filter(f => f.result?.sta
export const filesIgnore = computed(() => files.value.filter(f => f.mode === 'skip' || f.mode === 'todo'))
export const filesRunning = computed(() => files.value.filter(f =>
!filesFailed.value.includes(f)
&& !filesSuccess.value.includes(f)
&& !filesIgnore.value.includes(f),
&& !filesSuccess.value.includes(f)
&& !filesIgnore.value.includes(f),
))
export const filesSkipped = computed(() => filesIgnore.value.filter(f => f.mode === 'skip'))
export const filesSnapshotFailed = computed(() => files.value.filter(hasFailedSnapshot))
Expand Down
6 changes: 3 additions & 3 deletions packages/utils/src/ast/esmWalker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export function esmWalker(
// assignment of a destructuring variable
if (
(parent?.type === 'TemplateLiteral'
&& parent?.expressions.includes(child))
&& parent?.expressions.includes(child))
|| (parent?.type === 'CallExpression' && parent?.callee === child)
)
return
Expand Down Expand Up @@ -210,8 +210,8 @@ function isRefIdentifier(id: Identifier, parent: _Node, parentStack: _Node[]) {
if (
parent.type === 'CatchClause'
|| ((parent.type === 'VariableDeclarator'
|| parent.type === 'ClassDeclaration')
&& parent.id === id)
|| parent.type === 'ClassDeclaration')
&& parent.id === id)
)
return false

Expand Down
10 changes: 5 additions & 5 deletions packages/utils/src/ast/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export function esmWalker(
// assignment of a destructuring variable
if (
(parent?.type === 'TemplateLiteral'
&& parent?.expressions.includes(child))
&& parent?.expressions.includes(child))
|| (parent?.type === 'CallExpression' && parent?.callee === child)
)
return
Expand Down Expand Up @@ -227,10 +227,10 @@ export function esmWalker(
const parent = stack[0]
const grandparent = stack[1]
const hasBindingShortcut = isStaticProperty(parent) && parent.shorthand
&& (!isNodeInPattern(parent) || isInDestructuringAssignment(parent, parentStack))
&& (!isNodeInPattern(parent) || isInDestructuringAssignment(parent, parentStack))

const classDeclaration = (parent.type === 'PropertyDefinition'
&& grandparent?.type === 'ClassBody') || (parent.type === 'ClassDeclaration' && node === parent.superClass)
&& grandparent?.type === 'ClassBody') || (parent.type === 'ClassDeclaration' && node === parent.superClass)

const classExpression = parent.type === 'ClassExpression' && node === parent.id

Expand All @@ -248,8 +248,8 @@ function isRefIdentifier(id: Identifier, parent: _Node, parentStack: _Node[]) {
if (
parent.type === 'CatchClause'
|| ((parent.type === 'VariableDeclarator'
|| parent.type === 'ClassDeclaration')
&& parent.id === id)
|| parent.type === 'ClassDeclaration')
&& parent.id === id)
)
return false

Expand Down
57 changes: 28 additions & 29 deletions packages/utils/src/diff/cleanupSemantic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ const diff_commonPrefix = function (text1: string, text2: string): number {
let pointermid = pointermax
let pointerstart = 0
while (pointermin < pointermid) {
if (text1.substring(pointerstart, pointermid)
=== text2.substring(pointerstart, pointermid)) {
if (text1.substring(pointerstart, pointermid) === text2.substring(pointerstart, pointermid)) {
pointermin = pointermid
pointerstart = pointermin
}
Expand All @@ -99,7 +98,7 @@ const diff_commonPrefix = function (text1: string, text2: string): number {
const diff_commonSuffix = function (text1: string, text2: string): number {
// Quick check for common null cases.
if (!text1 || !text2
|| text1.charAt(text1.length - 1) !== text2.charAt(text2.length - 1))
|| text1.charAt(text1.length - 1) !== text2.charAt(text2.length - 1))
return 0

// Binary search.
Expand All @@ -110,7 +109,7 @@ const diff_commonSuffix = function (text1: string, text2: string): number {
let pointerend = 0
while (pointermin < pointermid) {
if (text1.substring(text1.length - pointermid, text1.length - pointerend)
=== text2.substring(text2.length - pointermid, text2.length - pointerend)) {
=== text2.substring(text2.length - pointermid, text2.length - pointerend)) {
pointermin = pointermid
pointerend = pointermin
}
Expand Down Expand Up @@ -163,7 +162,7 @@ const diff_commonOverlap_ = function (text1: string, text2: string): number {

length += found
if (found === 0 || text1.substring(text_length - length)
=== text2.substring(0, length)) {
=== text2.substring(0, length)) {
best = length
length++
}
Expand Down Expand Up @@ -207,8 +206,8 @@ const diff_cleanupSemantic = function (diffs: Array<Diff>) {
// Eliminate an equality that is smaller or equal to the edits on both
// sides of it.
if (lastEquality && (lastEquality.length
<= Math.max(length_insertions1, length_deletions1))
&& (lastEquality.length <= Math.max(length_insertions2, length_deletions2))) {
<= Math.max(length_insertions1, length_deletions1))
&& (lastEquality.length <= Math.max(length_insertions2, length_deletions2))) {
// Duplicate record.
diffs.splice(equalities[equalitiesLength - 1], 0, new Diff(DIFF_DELETE, lastEquality))
// Change second copy to insert.
Expand Down Expand Up @@ -244,14 +243,14 @@ const diff_cleanupSemantic = function (diffs: Array<Diff>) {
pointer = 1
while (pointer < diffs.length) {
if (diffs[pointer - 1][0] === DIFF_DELETE
&& diffs[pointer][0] === DIFF_INSERT) {
&& diffs[pointer][0] === DIFF_INSERT) {
const deletion = diffs[pointer - 1][1]
const insertion = diffs[pointer][1]
const overlap_length1 = diff_commonOverlap_(deletion, insertion)
const overlap_length2 = diff_commonOverlap_(insertion, deletion)
if (overlap_length1 >= overlap_length2) {
if (overlap_length1 >= deletion.length / 2
|| overlap_length1 >= insertion.length / 2) {
|| overlap_length1 >= insertion.length / 2) {
// Overlap found. Insert an equality and trim the surrounding edits.
diffs.splice(pointer, 0, new Diff(DIFF_EQUAL, insertion.substring(0, overlap_length1)))
diffs[pointer - 1][1]
Expand All @@ -262,7 +261,7 @@ const diff_cleanupSemantic = function (diffs: Array<Diff>) {
}
else {
if (overlap_length2 >= deletion.length / 2
|| overlap_length2 >= insertion.length / 2) {
|| overlap_length2 >= insertion.length / 2) {
// Reverse overlap found.
// Insert an equality and swap and trim the surrounding edits.
diffs.splice(pointer, 0, new Diff(DIFF_EQUAL, deletion.substring(0, overlap_length2)))
Expand Down Expand Up @@ -321,17 +320,17 @@ function diff_cleanupSemanticLossless(diffs: Array<Diff>) {
const nonAlphaNumeric1 = char1.match(nonAlphaNumericRegex_)
const nonAlphaNumeric2 = char2.match(nonAlphaNumericRegex_)
const whitespace1 = nonAlphaNumeric1
&& char1.match(whitespaceRegex_)
&& char1.match(whitespaceRegex_)
const whitespace2 = nonAlphaNumeric2
&& char2.match(whitespaceRegex_)
&& char2.match(whitespaceRegex_)
const lineBreak1 = whitespace1
&& char1.match(linebreakRegex_)
&& char1.match(linebreakRegex_)
const lineBreak2 = whitespace2
&& char2.match(linebreakRegex_)
&& char2.match(linebreakRegex_)
const blankLine1 = lineBreak1
&& one.match(blanklineEndRegex_)
&& one.match(blanklineEndRegex_)
const blankLine2 = lineBreak2
&& two.match(blanklineStartRegex_)
&& two.match(blanklineStartRegex_)

if (blankLine1 || blankLine2) {
// Five points for blank lines.
Expand Down Expand Up @@ -360,7 +359,7 @@ function diff_cleanupSemanticLossless(diffs: Array<Diff>) {
// Intentionally ignore the first and last element (don't need checking).
while (pointer < diffs.length - 1) {
if (diffs[pointer - 1][0] === DIFF_EQUAL
&& diffs[pointer + 1][0] === DIFF_EQUAL) {
&& diffs[pointer + 1][0] === DIFF_EQUAL) {
// This is a single edit surrounded by equalities.
let equality1 = diffs[pointer - 1][1]
let edit = diffs[pointer][1]
Expand All @@ -380,13 +379,13 @@ function diff_cleanupSemanticLossless(diffs: Array<Diff>) {
let bestEdit = edit
let bestEquality2 = equality2
let bestScore = diff_cleanupSemanticScore_(equality1, edit)
+ diff_cleanupSemanticScore_(edit, equality2)
+ diff_cleanupSemanticScore_(edit, equality2)
while (edit.charAt(0) === equality2.charAt(0)) {
equality1 += edit.charAt(0)
edit = edit.substring(1) + equality2.charAt(0)
equality2 = equality2.substring(1)
const score = diff_cleanupSemanticScore_(equality1, edit)
+ diff_cleanupSemanticScore_(edit, equality2)
+ diff_cleanupSemanticScore_(edit, equality2)
// The >= encourages trailing rather than leading whitespace on edits.
if (score >= bestScore) {
bestScore = score
Expand Down Expand Up @@ -453,8 +452,8 @@ function diff_cleanupMerge(diffs: Array<Diff>) {
commonlength = diff_commonPrefix(text_insert, text_delete)
if (commonlength !== 0) {
if ((pointer - count_delete - count_insert) > 0
&& diffs[pointer - count_delete - count_insert - 1][0]
=== DIFF_EQUAL) {
&& diffs[pointer - count_delete - count_insert - 1][0]
=== DIFF_EQUAL) {
diffs[pointer - count_delete - count_insert - 1][1]
+= text_insert.substring(0, commonlength)
}
Expand All @@ -469,11 +468,11 @@ function diff_cleanupMerge(diffs: Array<Diff>) {
commonlength = diff_commonSuffix(text_insert, text_delete)
if (commonlength !== 0) {
diffs[pointer][1] = text_insert.substring(text_insert.length
- commonlength) + diffs[pointer][1]
- commonlength) + diffs[pointer][1]
text_insert = text_insert.substring(0, text_insert.length
- commonlength)
- commonlength)
text_delete = text_delete.substring(0, text_delete.length
- commonlength)
- commonlength)
}
}
// Delete the offending records and add the merged ones.
Expand Down Expand Up @@ -515,20 +514,20 @@ function diff_cleanupMerge(diffs: Array<Diff>) {
// Intentionally ignore the first and last element (don't need checking).
while (pointer < diffs.length - 1) {
if (diffs[pointer - 1][0] === DIFF_EQUAL
&& diffs[pointer + 1][0] === DIFF_EQUAL) {
&& diffs[pointer + 1][0] === DIFF_EQUAL) {
// This is a single edit surrounded by equalities.
if (diffs[pointer][1].substring(diffs[pointer][1].length
- diffs[pointer - 1][1].length) === diffs[pointer - 1][1]) {
- diffs[pointer - 1][1].length) === diffs[pointer - 1][1]) {
// Shift the edit over the previous equality.
diffs[pointer][1] = diffs[pointer - 1][1]
+ diffs[pointer][1].substring(0, diffs[pointer][1].length
- diffs[pointer - 1][1].length)
+ diffs[pointer][1].substring(0, diffs[pointer][1].length
- diffs[pointer - 1][1].length)
diffs[pointer + 1][1] = diffs[pointer - 1][1] + diffs[pointer + 1][1]
diffs.splice(pointer - 1, 1)
changes = true
}
else if (diffs[pointer][1].substring(0, diffs[pointer + 1][1].length)
=== diffs[pointer + 1][1]) {
=== diffs[pointer + 1][1]) {
// Shift the edit over the next equality.
diffs[pointer - 1][1] += diffs[pointer + 1][1]
diffs[pointer][1]
Expand Down
6 changes: 3 additions & 3 deletions packages/utils/src/diff/diffLines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ function printAnnotation({

export function printDiffLines(diffs: Array<Diff>, options: DiffOptionsNormalized): string {
return printAnnotation(options, countChanges(diffs))
+ (options.expand
? joinAlignedDiffsExpand(diffs, options)
: joinAlignedDiffsNoExpand(diffs, options))
+ (options.expand
? joinAlignedDiffsExpand(diffs, options)
: joinAlignedDiffsNoExpand(diffs, options))
}

// Compare two arrays of strings line-by-line. Format as comparison lines.
Expand Down
8 changes: 5 additions & 3 deletions packages/utils/src/diff/normalizeDiffOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ function getCompareKeys(compareKeys?: CompareKeys): CompareKeys {
}

function getContextLines(contextLines?: number): number {
return (typeof contextLines === 'number'
&& Number.isSafeInteger(contextLines)
&& contextLines >= 0)
return (
typeof contextLines === 'number'
&& Number.isSafeInteger(contextLines)
&& contextLines >= 0
)
? contextLines
: DIFF_CONTEXT_DEFAULT
}
Expand Down
Loading

0 comments on commit dcf0d6a

Please sign in to comment.