mirror of
1
Fork 0

chore: add new lint rules

This commit is contained in:
Gusted 2024-10-23 08:10:18 +02:00
parent 1ec3e638a5
commit f63f02045e
No known key found for this signature in database
GPG Key ID: FD821B732837125F
5 changed files with 8 additions and 5 deletions

View File

@ -656,6 +656,7 @@ rules:
unicorn/catch-error-name: [0]
unicorn/consistent-destructuring: [2]
unicorn/consistent-empty-array-spread: [2]
unicorn/consistent-existence-index-check: [2]
unicorn/consistent-function-scoping: [2]
unicorn/custom-error-definition: [0]
unicorn/empty-brace-spaces: [2]
@ -732,10 +733,12 @@ rules:
unicorn/prefer-dom-node-text-content: [2]
unicorn/prefer-event-target: [2]
unicorn/prefer-export-from: [0]
unicorn/prefer-global-this: [0]
unicorn/prefer-includes: [2]
unicorn/prefer-json-parse-buffer: [0]
unicorn/prefer-keyboard-event-key: [2]
unicorn/prefer-logical-operator-over-ternary: [2]
unicorn/prefer-math-min-max: [2]
unicorn/prefer-math-trunc: [2]
unicorn/prefer-modern-dom-apis: [0]
unicorn/prefer-modern-math-apis: [2]

View File

@ -363,7 +363,7 @@ class ComboMarkdownEditor {
const lineStart = Math.max(0, value.lastIndexOf('\n', start - 1) + 1);
// Find the end and extract the line.
const lineEnd = value.indexOf('\n', start);
const line = value.slice(lineStart, lineEnd < 0 ? value.length : lineEnd);
const line = value.slice(lineStart, lineEnd === -1 ? value.length : lineEnd);
// Match any whitespace at the start + any repeatable prefix + exactly one space after.
const prefix = line.match(/^\s*((\d+)[.)]\s|[-*+]\s+(\[[ x]\]\s?)?|(>\s+)+)?/);

View File

@ -28,7 +28,7 @@ class Source {
deregister(port) {
const portIdx = this.clients.indexOf(port);
if (portIdx < 0) {
if (portIdx === -1) {
return this.clients.length;
}
this.clients.splice(portIdx, 1);

View File

@ -3,13 +3,13 @@ import {encode, decode} from 'uint8-to-base64';
// transform /path/to/file.ext to file.ext
export function basename(path = '') {
const lastSlashIndex = path.lastIndexOf('/');
return lastSlashIndex < 0 ? path : path.substring(lastSlashIndex + 1);
return lastSlashIndex === -1 ? path : path.substring(lastSlashIndex + 1);
}
// transform /path/to/file.ext to .ext
export function extname(path = '') {
const lastPointIndex = path.lastIndexOf('.');
return lastPointIndex < 0 ? '' : path.substring(lastPointIndex);
return lastPointIndex === -1 ? '' : path.substring(lastPointIndex);
}
// test whether a variable is an object

View File

@ -155,7 +155,7 @@ export function autosize(textarea, {viewportMarginBottom = 0} = {}) {
const isBorderBox = computedStyle.boxSizing === 'border-box';
const borderAddOn = isBorderBox ? topBorderWidth + bottomBorderWidth : 0;
const adjustedViewportMarginBottom = bottom < viewportMarginBottom ? bottom : viewportMarginBottom;
const adjustedViewportMarginBottom = Math.min(bottom, viewportMarginBottom);
const curHeight = parseFloat(computedStyle.height);
const maxHeight = curHeight + bottom - adjustedViewportMarginBottom;