Skip to content

Commit

Permalink
Bump deps
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Jul 22, 2024
1 parent 8d5c951 commit 9fd5f5c
Show file tree
Hide file tree
Showing 13 changed files with 1,932 additions and 2,166 deletions.
23 changes: 0 additions & 23 deletions .babelrc

This file was deleted.

3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

16 changes: 0 additions & 16 deletions .eslintrc.json

This file was deleted.

10 changes: 5 additions & 5 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ on: push

jobs:
test:
name: Lint, build, and test on node 14.x and ubuntu-latest
name: Lint, build, and test on node 20.x and ubuntu-latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js 14.x
uses: actions/setup-node@v1
- uses: actions/checkout@v4
- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 14.x
node-version: 20.x
- name: Install deps (with cache)
uses: bahmutov/npm-install@v1
- name: Lint codebase
Expand Down
6 changes: 0 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
## [5.0.10](https://github.com/GMOD/vcf-js/compare/v5.0.9...v5.0.10) (2022-12-17)



- Use es2015 for nodejs build

## [5.0.9](https://github.com/GMOD/vcf-js/compare/v5.0.8...v5.0.9) (2022-11-23)



- Fix erroneous parsing of symbolic alleles as breakends

## [5.0.8](https://github.com/GMOD/vcf-js/compare/v5.0.7...v5.0.8) (2022-11-20)



- Parse single breakends and large insertion shorthand notation (#95)

<a name="5.0.7"></a>
Expand Down
58 changes: 58 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import prettier from "eslint-plugin-prettier";
import tsParser from "@typescript-eslint/parser";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});

export default [...compat.extends(
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-type-checked",
"plugin:@typescript-eslint/stylistic-type-checked",
"prettier",
), {
plugins: {
"@typescript-eslint": typescriptEslint,
prettier,
},

languageOptions: {
parser: tsParser,
ecmaVersion: 5,
sourceType: "script",

parserOptions: {
tsconfigRootDir: "/home/cdiesh/src/gmod/vcf-js",
project: "./tsconfig.lint.json",
},
},

rules: {
curly: "error",

"@typescript-eslint/no-unused-vars": ["warn", {
argsIgnorePattern: "^_",
ignoreRestSiblings: true,
}],

"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-this-alias": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-return": "off",
"prettier/prettier": "error",
},
}];
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
};
}
24 changes: 13 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"scripts": {
"test": "jest",
"coverage": "npm test -- --coverage",
"lint": "eslint . --ext .ts,.js",
"lint": "eslint --report-unused-disable-directives --max-warnings 0 src test",
"docs": "documentation readme src/parse.ts --section=API --shallow",
"postdocs": "prettier --write README.md",
"clean": "rimraf dist esm",
Expand All @@ -40,19 +40,21 @@
},
"devDependencies": {
"@babel/core": "^7.20.5",
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.7.0",
"@types/jest": "^29.2.4",
"@typescript-eslint/eslint-plugin": "^5.46.1",
"@typescript-eslint/parser": "^5.46.1",
"@typescript-eslint/eslint-plugin": "^7.17.0",
"@typescript-eslint/parser": "^7.17.0",
"documentation": "^14.0.1",
"eslint": "^8.30.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint": "^9.7.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"jest": "^29.3.1",
"prettier": "^2.8.1",
"rimraf": "^3.0.2",
"standard-changelog": "^2.0.27",
"ts-jest": "^29.0.3",
"typescript": "^4.9.4"
"prettier": "^3.2.4",
"rimraf": "^6.0.1",
"standard-changelog": "^6.0.0",
"ts-jest": "^29.1.2",
"typescript": "^5.3.3"
},
"keywords": [
"vcf",
Expand Down
5 changes: 2 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ export function parseBreakend(breakendString: string): Breakend | undefined {
let Join
let Replacement
let MatePosition
for (let i = 0; i < tokens.length; i += 1) {
const tok = tokens[i]
for (const tok of tokens) {
if (tok) {
if (tok.includes(':')) {
// this is the remote location
Expand Down Expand Up @@ -45,7 +44,7 @@ export function parseBreakend(breakendString: string): Breakend | undefined {
SingleBreakend: true,
Replacement: breakendString.slice(0, breakendString.length - 1),
}
} else if (breakendString[0] === '<') {
} else if (breakendString.startsWith('<')) {
const res = breakendString.match('<(.*)>(.*)')
if (!res) {
throw new Error(`failed to parse ${breakendString}`)
Expand Down
26 changes: 12 additions & 14 deletions src/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default class VCF {
header: string
strict?: boolean
}) {
if (!header || !header.length) {
if (!header?.length) {
throw new Error('empty header received')
}
const headerLines = header.split(/[\r\n]+/).filter(line => line)
Expand Down Expand Up @@ -183,8 +183,8 @@ export default class VCF {
*/
getMetadata(...args: string[]) {
let filteredMetadata: any = this.metadata
for (let i = 0; i < args.length; i += 1) {
filteredMetadata = filteredMetadata[args[i]]
for (const arg of args) {
filteredMetadata = filteredMetadata[arg]
if (!filteredMetadata) {
return filteredMetadata
}
Expand All @@ -211,33 +211,33 @@ export default class VCF {
let currKey = ''
let currValue = ''
let state = 1 // states: 1: read key to = or pair sep, 2: read value to sep or quote, 3: read value to quote
for (let i = 0; i < str.length; i += 1) {
for (const s of str) {
if (state === 1) {
// read key to = or pair sep
if (str[i] === '=') {
if (s === '=') {
state = 2
} else if (str[i] !== pairSeparator) {
currKey += str[i]
} else if (s !== pairSeparator) {
currKey += s
} else if (currValue === '') {
data[currKey] = null
currKey = ''
}
} else if (state === 2) {
// read value to pair sep or quote
if (str[i] === pairSeparator) {
if (s === pairSeparator) {
data[currKey] = currValue
currKey = ''
currValue = ''
state = 1
} else if (str[i] === '"') {
} else if (s === '"') {
state = 3
} else {
currValue += str[i]
currValue += s
}
} else if (state === 3) {
// read value to quote
if (str[i] !== '"') {
currValue += str[i]
if (s !== '"') {
currValue += s
} else {
state = 2
}
Expand All @@ -258,7 +258,6 @@ export default class VCF {
* CRLF newlines.
*/
parseLine(line: string) {
// eslint-disable-next-line no-param-reassign
line = line.trim()
if (!line.length) {
return undefined
Expand Down Expand Up @@ -320,7 +319,6 @@ export default class VCF {
})
} else if (itemType === 'Flag') {
if (info[key]) {
// eslint-disable-next-line no-console
console.warn(
`Info field ${key} is a Flag and should not have a value (got value ${info[key]})`,
)
Expand Down
2 changes: 1 addition & 1 deletion test/parse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ test('shortcut parsing with 1000 genomes', () => {
expect(Object.keys(variants[0].SAMPLES).slice(0, 5)).toMatchSnapshot()
expect(Object.keys(variants[0].SAMPLES).slice(-5)).toMatchSnapshot()
const ret = variants.map(v => {
const { SAMPLES, ...rest } = v
const { SAMPLES: _, ...rest } = v
return rest
})
expect(ret).toMatchSnapshot()
Expand Down
4 changes: 4 additions & 0 deletions tsconfig.lint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "./tsconfig",
"include": ["src", "test"]
}
Loading

0 comments on commit 9fd5f5c

Please sign in to comment.