diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 00000000..cd0118d2 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,82 @@ +/** @type {import("eslint").Linter.Config} */ +module.exports = { + parser: '@typescript-eslint/parser', + plugins: ['prettier', '@typescript-eslint'], + extends: [ + 'plugin:@typescript-eslint/recommended', + 'plugin:@typescript-eslint/recommended-type-checked', + 'plugin:@typescript-eslint/stylistic-type-checked', + 'plugin:prettier/recommended', + 'plugin:unicorn/recommended', + ], + parser: '@typescript-eslint/parser', + parserOptions: { + tsconfigRootDir: __dirname, + project: './tsconfig.lint.json', + }, + rules: { + '@typescript-eslint/no-unused-vars': [ + 'warn', + { argsIgnorePattern: '^_', ignoreRestSiblings: true }, + ], + 'no-underscore-dangle': 0, + curly: 'error', + '@typescript-eslint/no-explicit-any': 0, + '@typescript-eslint/explicit-module-boundary-types': 0, + '@typescript-eslint/ban-ts-comment': 0, + semi: ['error', 'never'], + 'unicorn/no-new-array': 'off', + 'unicorn/no-empty-file': 'off', + 'unicorn/prefer-type-error': 'off', + 'unicorn/prefer-modern-math-apis': 'off', + 'unicorn/prefer-node-protocol': 'off', + 'unicorn/no-unreadable-array-destructuring': 'off', + 'unicorn/no-abusive-eslint-disable': 'off', + 'unicorn/no-array-callback-reference': 'off', + 'unicorn/number-literal-case': 'off', + 'unicorn/prefer-add-event-listener': 'off', + 'unicorn/prefer-top-level-await': 'off', + 'unicorn/consistent-function-scoping': 'off', + 'unicorn/no-await-expression-member': 'off', + 'unicorn/no-lonely-if': 'off', + 'unicorn/consistent-destructuring': 'off', + 'unicorn/prefer-module': 'off', + 'unicorn/prefer-optional-catch-binding': 'off', + 'unicorn/no-useless-undefined': 'off', + 'unicorn/no-null': 'off', + 'unicorn/no-nested-ternary': 'off', + 'unicorn/filename-case': 'off', + 'unicorn/catch-error-name': 'off', + 'unicorn/prevent-abbreviations': 'off', + 'unicorn/prefer-code-point': 'off', + 'unicorn/numeric-separators-style': 'off', + 'unicorn/no-array-for-each': 'off', + 'unicorn/prefer-spread': 'off', + 'unicorn/explicit-length-check': 'off', + 'unicorn/prefer-regexp-test': 'off', + 'unicorn/relative-url-style': 'off', + 'unicorn/prefer-math-trunc': 'off', + 'unicorn/prefer-query-selector': 'off', + 'unicorn/no-negated-condition': 'off', + 'unicorn/switch-case-braces': 'off', + 'unicorn/prefer-switch': 'off', + 'unicorn/better-regex': 'off', + 'unicorn/no-for-loop': 'off', + 'unicorn/escape-case': 'off', + 'unicorn/prefer-number-properties': 'off', + 'unicorn/no-process-exit': 'off', + 'unicorn/prefer-at': 'off', + 'unicorn/prefer-string-replace-all': 'off', + 'unicorn/no-array-reduce': 'off', + + '@typescript-eslint/no-base-to-string': 'off', + '@typescript-eslint/no-unsafe-member-access': 'off', + '@typescript-eslint/no-unsafe-argument': 'off', + '@typescript-eslint/no-unsafe-assignment': 'off', + '@typescript-eslint/no-unsafe-call': 'off', + '@typescript-eslint/no-unsafe-return': 'off', + '@typescript-eslint/prefer-nullish-coalescing': 'off', + '@typescript-eslint/require-await': 'off', + '@typescript-eslint/restrict-template-expressions': 'off', + }, +} diff --git a/eslint.config.mjs b/eslint.config.mjs deleted file mode 100644 index 8af6b90a..00000000 --- a/eslint.config.mjs +++ /dev/null @@ -1,114 +0,0 @@ -import prettier from 'eslint-plugin-prettier' -import typescriptEslint from '@typescript-eslint/eslint-plugin' -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 [ - { - ignores: ['src/binary-parser/*.js'], - }, - ...compat.extends( - 'plugin:@typescript-eslint/recommended', - 'plugin:@typescript-eslint/recommended-type-checked', - 'plugin:@typescript-eslint/stylistic-type-checked', - 'plugin:prettier/recommended', - 'plugin:unicorn/recommended', - ), - { - plugins: { - prettier, - '@typescript-eslint': typescriptEslint, - }, - - languageOptions: { - parser: tsParser, - ecmaVersion: 5, - sourceType: 'script', - - parserOptions: { - tsconfigRootDir: '/Users/colin/src/cram-js', - project: './tsconfig.lint.json', - }, - }, - - rules: { - '@typescript-eslint/no-unused-vars': [ - 'warn', - { - argsIgnorePattern: '^_', - ignoreRestSiblings: true, - }, - ], - - 'no-underscore-dangle': 0, - curly: 'error', - '@typescript-eslint/no-explicit-any': 0, - '@typescript-eslint/explicit-module-boundary-types': 0, - '@typescript-eslint/ban-ts-comment': 0, - semi: ['error', 'never'], - 'unicorn/no-new-array': 'off', - 'unicorn/no-empty-file': 'off', - 'unicorn/prefer-type-error': 'off', - 'unicorn/prefer-modern-math-apis': 'off', - 'unicorn/prefer-node-protocol': 'off', - 'unicorn/no-unreadable-array-destructuring': 'off', - 'unicorn/no-abusive-eslint-disable': 'off', - 'unicorn/no-array-callback-reference': 'off', - 'unicorn/number-literal-case': 'off', - 'unicorn/prefer-add-event-listener': 'off', - 'unicorn/prefer-top-level-await': 'off', - 'unicorn/consistent-function-scoping': 'off', - 'unicorn/no-await-expression-member': 'off', - 'unicorn/no-lonely-if': 'off', - 'unicorn/consistent-destructuring': 'off', - 'unicorn/prefer-module': 'off', - 'unicorn/prefer-optional-catch-binding': 'off', - 'unicorn/no-useless-undefined': 'off', - 'unicorn/no-null': 'off', - 'unicorn/no-nested-ternary': 'off', - 'unicorn/filename-case': 'off', - 'unicorn/catch-error-name': 'off', - 'unicorn/prevent-abbreviations': 'off', - 'unicorn/prefer-code-point': 'off', - 'unicorn/numeric-separators-style': 'off', - 'unicorn/no-array-for-each': 'off', - 'unicorn/prefer-spread': 'off', - 'unicorn/explicit-length-check': 'off', - 'unicorn/prefer-regexp-test': 'off', - 'unicorn/relative-url-style': 'off', - 'unicorn/prefer-math-trunc': 'off', - 'unicorn/prefer-query-selector': 'off', - 'unicorn/no-negated-condition': 'off', - 'unicorn/switch-case-braces': 'off', - 'unicorn/prefer-switch': 'off', - 'unicorn/better-regex': 'off', - 'unicorn/no-for-loop': 'off', - 'unicorn/escape-case': 'off', - 'unicorn/prefer-number-properties': 'off', - 'unicorn/no-process-exit': 'off', - 'unicorn/prefer-at': 'off', - 'unicorn/prefer-string-replace-all': 'off', - 'unicorn/no-array-reduce': 'off', - '@typescript-eslint/no-base-to-string': 'off', - '@typescript-eslint/no-unsafe-member-access': 'off', - '@typescript-eslint/no-unsafe-argument': 'off', - '@typescript-eslint/no-unsafe-assignment': 'off', - '@typescript-eslint/no-unsafe-call': 'off', - '@typescript-eslint/no-unsafe-return': 'off', - '@typescript-eslint/prefer-nullish-coalescing': 'off', - '@typescript-eslint/require-await': 'off', - '@typescript-eslint/restrict-template-expressions': 'off', - }, - }, -] diff --git a/package.json b/package.json index 5467518a..51d6d95b 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ ], "scripts": { "test": "jest", - "lint": "eslint --report-unused-disable-directives --max-warnings 0 src test", + "lint": "eslint src test", "docs": "documentation readme --shallow src/indexedCramFile.ts --section=IndexedCramFile; documentation readme --shallow src/cramFile/file.ts --section=CramFile; documentation readme --shallow src/craiIndex.ts --section=CraiIndex; documentation readme --shallow errors.ts '--section=Exception Classes'; documentation readme --shallow src/cramFile/file.ts --section=CramFile; documentation readme --shallow src/cramFile/record.ts --section=CramRecord", "prebuild": "npm run clean", "clean": "rimraf dist esm", @@ -54,6 +54,8 @@ "xz-decompress": "^0.2.1" }, "devDependencies": { + "@babel/plugin-transform-modules-commonjs": "^7.18.2", + "@babel/preset-typescript": "^7.17.12", "@gmod/indexedfasta": "^2.1.0", "@types/jest": "^29.5.12", "@types/long": "^4.0.2", diff --git a/test/lib/syncLocalFile.ts b/test/lib/syncLocalFile.ts index 37a55cf7..316a9d96 100644 --- a/test/lib/syncLocalFile.ts +++ b/test/lib/syncLocalFile.ts @@ -1,6 +1,6 @@ //@ts-nocheck // don't load fs native module if running in webpacked code -const fs = typeof __webpack_require__ !== 'function' ? require('fs') : null +const fs = typeof __webpack_require__ !== 'function' ? require('fs') : null // eslint-disable-line camelcase const fsOpen = fs.openSync const fsRead = fs.readSync diff --git a/yarn.lock b/yarn.lock index 48a187bc..c9fe2410 100644 --- a/yarn.lock +++ b/yarn.lock @@ -59,6 +59,13 @@ "@jridgewell/trace-mapping" "^0.3.17" jsesc "^2.5.1" +"@babel/helper-annotate-as-pure@^7.22.5": + version "7.22.5" + resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.22.5.tgz#e7f06737b197d580a01edf75d97e2c8be99d3882" + integrity sha512-LvBTxu8bQSQkcyKOU+a1btnNFQ1dMAd0R6PyW3arXes06F6QLWLIrd681bxRPIXlrMGR3XYnW9JyML7dP3qgxg== + dependencies: + "@babel/types" "^7.22.5" + "@babel/helper-compilation-targets@^7.23.6": version "7.23.6" resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.23.6.tgz#4d79069b16cbcf1461289eccfbbd81501ae39991" @@ -70,6 +77,21 @@ lru-cache "^5.1.1" semver "^6.3.1" +"@babel/helper-create-class-features-plugin@^7.23.6": + version "7.24.0" + resolved "https://registry.yarnpkg.com/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.24.0.tgz#fc7554141bdbfa2d17f7b4b80153b9b090e5d158" + integrity sha512-QAH+vfvts51BCsNZ2PhY6HAggnlS6omLLFTsIpeqZk/MmJ6cW7tgz5yRv0fMJThcr6FmbMrENh1RgrWPTYA76g== + dependencies: + "@babel/helper-annotate-as-pure" "^7.22.5" + "@babel/helper-environment-visitor" "^7.22.20" + "@babel/helper-function-name" "^7.23.0" + "@babel/helper-member-expression-to-functions" "^7.23.0" + "@babel/helper-optimise-call-expression" "^7.22.5" + "@babel/helper-replace-supers" "^7.22.20" + "@babel/helper-skip-transparent-expression-wrappers" "^7.22.5" + "@babel/helper-split-export-declaration" "^7.22.6" + semver "^6.3.1" + "@babel/helper-environment-visitor@^7.22.20": version "7.22.20" resolved "https://registry.yarnpkg.com/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.20.tgz#96159db61d34a29dba454c959f5ae4a649ba9167" @@ -90,6 +112,13 @@ dependencies: "@babel/types" "^7.22.5" +"@babel/helper-member-expression-to-functions@^7.22.15", "@babel/helper-member-expression-to-functions@^7.23.0": + version "7.23.0" + resolved "https://registry.yarnpkg.com/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.23.0.tgz#9263e88cc5e41d39ec18c9a3e0eced59a3e7d366" + integrity sha512-6gfrPwh7OuT6gZyJZvd6WbTfrqAo7vm4xCzAXOusKqq/vWdKXphTpj5klHKNmRUU6/QRGlBsyU9mAIPaWHlqJA== + dependencies: + "@babel/types" "^7.23.0" + "@babel/helper-module-imports@^7.22.15": version "7.22.15" resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.22.15.tgz#16146307acdc40cc00c3b2c647713076464bdbf0" @@ -108,11 +137,27 @@ "@babel/helper-split-export-declaration" "^7.22.6" "@babel/helper-validator-identifier" "^7.22.20" +"@babel/helper-optimise-call-expression@^7.22.5": + version "7.22.5" + resolved "https://registry.yarnpkg.com/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.22.5.tgz#f21531a9ccbff644fdd156b4077c16ff0c3f609e" + integrity sha512-HBwaojN0xFRx4yIvpwGqxiV2tUfl7401jlok564NgB9EHS1y6QT17FmKWm4ztqjeVdXLuC4fSvHc5ePpQjoTbw== + dependencies: + "@babel/types" "^7.22.5" + "@babel/helper-plugin-utils@^7.0.0", "@babel/helper-plugin-utils@^7.10.4", "@babel/helper-plugin-utils@^7.12.13", "@babel/helper-plugin-utils@^7.14.5", "@babel/helper-plugin-utils@^7.22.5", "@babel/helper-plugin-utils@^7.8.0": version "7.24.0" resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.24.0.tgz#945681931a52f15ce879fd5b86ce2dae6d3d7f2a" integrity sha512-9cUznXMG0+FxRuJfvL82QlTqIzhVW9sL0KjMPHhAOOvpQGL8QtdxnBKILjBqxlHyliz0yCa1G903ZXI/FuHy2w== +"@babel/helper-replace-supers@^7.22.20": + version "7.22.20" + resolved "https://registry.yarnpkg.com/@babel/helper-replace-supers/-/helper-replace-supers-7.22.20.tgz#e37d367123ca98fe455a9887734ed2e16eb7a793" + integrity sha512-qsW0In3dbwQUbK8kejJ4R7IHVGwHJlV6lpG6UA7a9hSa2YEiAib+N1T2kr6PEeUT+Fl7najmSOS6SmAwCHK6Tw== + dependencies: + "@babel/helper-environment-visitor" "^7.22.20" + "@babel/helper-member-expression-to-functions" "^7.22.15" + "@babel/helper-optimise-call-expression" "^7.22.5" + "@babel/helper-simple-access@^7.22.5": version "7.22.5" resolved "https://registry.yarnpkg.com/@babel/helper-simple-access/-/helper-simple-access-7.22.5.tgz#4938357dc7d782b80ed6dbb03a0fba3d22b1d5de" @@ -120,6 +165,13 @@ dependencies: "@babel/types" "^7.22.5" +"@babel/helper-skip-transparent-expression-wrappers@^7.22.5": + version "7.22.5" + resolved "https://registry.yarnpkg.com/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.22.5.tgz#007f15240b5751c537c40e77abb4e89eeaaa8847" + integrity sha512-tK14r66JZKiC43p8Ki33yLBVJKlQDFoA8GYN67lWCDCqoL6EMMSuM9b+Iff2jHaM/RRFYl7K+iiru7hbRqNx8Q== + dependencies: + "@babel/types" "^7.22.5" + "@babel/helper-split-export-declaration@^7.22.6": version "7.22.6" resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.22.6.tgz#322c61b7310c0997fe4c323955667f18fcefb91c" @@ -137,7 +189,7 @@ resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz#c4ae002c61d2879e724581d96665583dbc1dc0e0" integrity sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A== -"@babel/helper-validator-option@^7.23.5": +"@babel/helper-validator-option@^7.22.15", "@babel/helper-validator-option@^7.23.5": version "7.23.5" resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.23.5.tgz#907a3fbd4523426285365d1206c423c4c5520307" integrity sha512-85ttAOMLsr53VgXkTbkx8oA6YTfT4q7/HzXSLEYmjcSTJPMPQtvq1BD79Byep5xMUYbGRzEpDsjUf3dyp54IKw== @@ -200,7 +252,7 @@ dependencies: "@babel/helper-plugin-utils" "^7.8.0" -"@babel/plugin-syntax-jsx@^7.7.2": +"@babel/plugin-syntax-jsx@^7.23.3", "@babel/plugin-syntax-jsx@^7.7.2": version "7.23.3" resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.23.3.tgz#8f2e4f8a9b5f9aa16067e142c1ac9cd9f810f473" integrity sha512-EB2MELswq55OHUoRZLGg/zC7QWUKfNLpE57m/S2yr1uEneIgsTgrSzXP3NXEsMkVn76OlaVVnzN+ugObuYGwhg== @@ -256,13 +308,43 @@ dependencies: "@babel/helper-plugin-utils" "^7.14.5" -"@babel/plugin-syntax-typescript@^7.7.2": +"@babel/plugin-syntax-typescript@^7.23.3", "@babel/plugin-syntax-typescript@^7.7.2": version "7.23.3" resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.23.3.tgz#24f460c85dbbc983cd2b9c4994178bcc01df958f" integrity sha512-9EiNjVJOMwCO+43TqoTrgQ8jMwcAd0sWyXi9RPfIsLTj4R2MADDDQXELhffaUx/uJv2AYcxBgPwH6j4TIA4ytQ== dependencies: "@babel/helper-plugin-utils" "^7.22.5" +"@babel/plugin-transform-modules-commonjs@^7.18.2", "@babel/plugin-transform-modules-commonjs@^7.23.3": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.23.3.tgz#661ae831b9577e52be57dd8356b734f9700b53b4" + integrity sha512-aVS0F65LKsdNOtcz6FRCpE4OgsP2OFnW46qNxNIX9h3wuzaNcSQsJysuMwqSibC98HPrf2vCgtxKNwS0DAlgcA== + dependencies: + "@babel/helper-module-transforms" "^7.23.3" + "@babel/helper-plugin-utils" "^7.22.5" + "@babel/helper-simple-access" "^7.22.5" + +"@babel/plugin-transform-typescript@^7.23.3": + version "7.23.6" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.23.6.tgz#aa36a94e5da8d94339ae3a4e22d40ed287feb34c" + integrity sha512-6cBG5mBvUu4VUD04OHKnYzbuHNP8huDsD3EDqqpIpsswTDoqHCjLoHb6+QgsV1WsT2nipRqCPgxD3LXnEO7XfA== + dependencies: + "@babel/helper-annotate-as-pure" "^7.22.5" + "@babel/helper-create-class-features-plugin" "^7.23.6" + "@babel/helper-plugin-utils" "^7.22.5" + "@babel/plugin-syntax-typescript" "^7.23.3" + +"@babel/preset-typescript@^7.17.12": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/preset-typescript/-/preset-typescript-7.23.3.tgz#14534b34ed5b6d435aa05f1ae1c5e7adcc01d913" + integrity sha512-17oIGVlqz6CchO9RFYn5U6ZpWRZIngayYCtrPRSgANSwC2V1Jb+iP74nVxzzXJte8b8BYxrL1yY96xfhTBrNNQ== + dependencies: + "@babel/helper-plugin-utils" "^7.22.5" + "@babel/helper-validator-option" "^7.22.15" + "@babel/plugin-syntax-jsx" "^7.23.3" + "@babel/plugin-transform-modules-commonjs" "^7.23.3" + "@babel/plugin-transform-typescript" "^7.23.3" + "@babel/template@^7.22.15", "@babel/template@^7.24.0", "@babel/template@^7.3.3": version "7.24.0" resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.24.0.tgz#c6a524aa93a4a05d66aaf31654258fae69d87d50"