Skip to content

Commit

Permalink
updated eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-jonathan committed Nov 14, 2024
1 parent db2ec81 commit f831a71
Show file tree
Hide file tree
Showing 3 changed files with 316 additions and 317 deletions.
198 changes: 100 additions & 98 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,42 @@ root: true
env:
node: true
browser: true
es6: true
parser: '@typescript-eslint/parser'
es2021: true
parser: 'vue-eslint-parser'
parserOptions:
parser: '@typescript-eslint/parser'
ecmaVersion: 2021
sourceType: module
plugins:
- '@typescript-eslint'
- 'import'
- 'vue'
extends:
- eslint:recommended
- plugin:@typescript-eslint/eslint-recommended
- plugin:vue/vue3-recommended
- plugin:@typescript-eslint/recommended
- plugin:yml/standard
- plugin:import/errors
- plugin:import/warnings
- plugin:import/typescript
overrides:
- files:
- '**/*.js'
- '**/*.js'
- '**/*.ts'
rules:
'@typescript-eslint/no-inferrable-types':
- 0
'@typescript-eslint/explicit-function-return-type':
- 0
'@typescript-eslint/no-inferrable-types': off
'@typescript-eslint/explicit-function-return-type': off
rules:
'@typescript-eslint/no-empty-interface':
- error
'@typescript-eslint/no-inferrable-types':
- error
'@typescript-eslint/explicit-function-return-type':
- error
eqeqeq:
- error
camelcase:
- error
no-console:
- error
no-lonely-if:
- error
'@typescript-eslint/no-empty-interface': error
'@typescript-eslint/no-explicit-any': warn
'@typescript-eslint/explicit-module-boundary-types': error
'@typescript-eslint/no-unused-vars':
- error
- argsIgnorePattern: '^_'
varsIgnorePattern: '^_'
eqeqeq: error
camelcase: error
no-console: error
no-lonely-if: error
comma-dangle:
- error
- arrays: never
Expand All @@ -45,8 +49,7 @@ rules:
- error
- 4
- SwitchCase: 1
no-tabs:
- error
no-tabs: error
object-curly-spacing:
- error
- always
Expand All @@ -56,93 +59,92 @@ rules:
curly:
- error
- all
template-curly-spacing:
- error
no-trailing-spaces:
- error
no-spaced-func:
- error
space-before-blocks:
- error
template-curly-spacing: error
no-trailing-spaces: error
space-before-blocks: error
semi:
- error
- never
quotes:
- error
- single
- avoidEscape: true
object-curly-newline:
- error
- multiline: true
minProperties: 2
consistent: true
object-property-newline:
- error
object-shorthand:
- error
- allowAllPropertiesOnSameLine: true
object-shorthand: error
no-param-reassign:
- error
- props: false
no-extra-parens:
- error
no-return-await:
- error
no-self-compare:
- error
no-template-curly-in-string:
- error
no-throw-literal:
- error
no-undef-init:
- error
no-unmodified-loop-condition:
- error
no-unneeded-ternary:
- error
no-unreachable-loop:
- error
no-unsafe-optional-chaining:
- error
no-unused-expressions:
- error
no-extra-parens: error
no-return-await: error
no-self-compare: error
no-template-curly-in-string: error
no-throw-literal: error
no-undef-init: error
no-unmodified-loop-condition: error
no-unneeded-ternary: error
no-unreachable-loop: error
no-unsafe-optional-chaining: error
no-unused-expressions: error
no-use-before-define:
- error
- functions: false
no-useless-backreference:
- error
no-useless-call:
- error
no-useless-computed-key:
- error
no-useless-concat:
- error
no-useless-constructor:
- error
no-useless-rename:
- error
no-useless-return:
- error
no-var:
- error
nonblock-statement-body-position:
- error
one-var-declaration-per-line:
- error
prefer-arrow-callback:
- error
prefer-const:
- error
prefer-exponentiation-operator:
- error
prefer-numeric-literals:
- error
prefer-object-spread:
- error
prefer-promise-reject-errors:
- error
prefer-template:
- error
prefer-rest-params:
- error
rest-spread-spacing:
- error
require-atomic-updates:
- error
require-await:
classes: true
variables: true
no-useless-backreference: error
no-useless-call: error
no-useless-computed-key: error
no-useless-concat: error
no-useless-constructor: error
no-useless-rename: error
no-useless-return: error
no-var: error
nonblock-statement-body-position: error
one-var-declaration-per-line: error
prefer-arrow-callback: error
prefer-const: error
prefer-exponentiation-operator: error
prefer-numeric-literals: error
prefer-object-spread: error
prefer-promise-reject-errors: error
prefer-template: error
prefer-rest-params: error
rest-spread-spacing: error
require-atomic-updates: error
require-await: error
import/order:
- error
- groups:
- builtin
- external
- internal
- parent
- sibling
- index
newlines-between: always
alphabetize:
order: asc
caseInsensitive: true
vue/html-indent:
- error
- 4
vue/max-attributes-per-line:
- error
- singleline: 3
multiline: 1
vue/require-default-prop: off
vue/html-self-closing:
- error
- html:
void: never
normal: always
component: always
settings:
import/resolver:
typescript: {}
95 changes: 47 additions & 48 deletions src/sort/MergeSort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
*/

import {
CompareFn,
CompareFn,
} from '@/utils'

/**
Expand All @@ -74,56 +74,55 @@ import {
* @performance O(log(n))
*/
const merge = <T>(data: T[], p: number, q: number, r: number, fn: CompareFn<T>): void => {
const n1 = q - p + 1
const n2 = r - q
const n1 = q - p + 1
const n2 = r - q

let i
let j
let k
let i
let j
let k

const L: T[] = []
const R: T[] = []
const L: T[] = []
const R: T[] = []

for (i = 0; i < n1; ++i) {
L[i] = data[p + i]
}
for (i = 0; i < n1; ++i) {
L[i] = data[p + i]
}

for (j = 0; j < n2; ++j) {
R[j] = data[q + j + 1]
}
for (j = 0; j < n2; ++j) {
R[j] = data[q + j + 1]
}

i = 0
j = 0
k = p // initial index of subarray
i = 0
j = 0
k = p // initial index of subarray

// merge the array L, R back into data
// while performing the sort operation
while (i < n1 && j < n2) {
if (1 > fn(L[i], R[j])) {
data[k] = L[i]
++i
}
else {
data[k] = R[j]
++j
}
// merge the array L, R back into data
// while performing the sort operation
while (i < n1 && j < n2) {
if (1 > fn(L[i], R[j])) {
data[k] = L[i]
++i
} else {
data[k] = R[j]
++j
}

++k
}
++k
}

// copy remaining elements of L
while (i < n1) {
data[k] = L[i]
++i
++k
}
// copy remaining elements of L
while (i < n1) {
data[k] = L[i]
++i
++k
}

// copy remaining elements of R
while (j < n2) {
data[k] = R[j]
++j
++k
}
// copy remaining elements of R
while (j < n2) {
data[k] = R[j]
++j
++k
}
}

/**
Expand All @@ -132,13 +131,13 @@ const merge = <T>(data: T[], p: number, q: number, r: number, fn: CompareFn<T>):
* @performance O(n)
*/
const sort = <T>(data: T[], p: number, r: number, fn: CompareFn<T>): void => {
if (p < r) {
if (p < r) {
// same as (p + r) / 2 but avoids overflow for large p
const q = Math.floor(p + (r - p) / 2)
sort(data, p, q, fn)
sort(data, q + 1, r, fn)
merge(data, p, q, r, fn)
}
const q = Math.floor(p + (r - p) / 2)
sort(data, p, q, fn)
sort(data, q + 1, r, fn)
merge(data, p, q, r, fn)
}
}

/**
Expand Down
Loading

0 comments on commit f831a71

Please sign in to comment.