From d7fcd0597e6ae7d9764e4be59223a7b0288b255f Mon Sep 17 00:00:00 2001 From: Michael Kreil Date: Tue, 24 Sep 2024 17:05:36 +0200 Subject: [PATCH] fix: eslint --- eslint.config.js | 223 +----------------------- package-lock.json | 27 ++- package.json | 3 +- scripts/build-sprites.test.ts | 6 +- scripts/build-styles.test.ts | 6 +- scripts/config-sprites.ts | 2 +- scripts/lib/icons.test.ts | 2 +- scripts/lib/sprites.test.ts | 8 +- scripts/lib/sprites.ts | 12 +- src/guess_style/guess_style.test.ts | 6 +- src/guess_style/guess_style.ts | 11 +- src/guess_style/random_color.ts | 4 +- src/index.test.ts | 2 +- src/lib/utils.test.ts | 2 +- src/lib/utils.ts | 2 +- src/shortbread/layers.ts | 2 +- src/shortbread/properties.test.ts | 2 +- src/shortbread/template.test.ts | 2 +- src/shortbread/template.ts | 2 +- src/style_builder/decorator.ts | 2 +- src/style_builder/style_builder.test.ts | 2 +- src/style_builder/style_builder.ts | 2 +- src/styles/colorful.ts | 2 +- src/styles/neutrino.ts | 2 +- src/types/maplibre.ts | 4 +- src/types/tilejson.test.ts | 2 +- src/types/tilejson.ts | 2 +- 27 files changed, 79 insertions(+), 263 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index e2eabf5..d47f9a2 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,7 +1,11 @@ +import js from '@eslint/js'; +import ts from 'typescript-eslint'; import parser from '@typescript-eslint/parser'; import eslint_plugin from '@typescript-eslint/eslint-plugin'; export default [ + js.configs.recommended, + ...ts.configs.recommended, { ignores: [ '**/dist/**/*.*', @@ -25,7 +29,7 @@ export default [ parserOptions: { sourceType: 'module', project: './tsconfig.json', - tsconfigRootDir: new URL('./', import.meta.url).pathname, + tsconfigRootDir: import.meta.dirname, }, }, plugins: { @@ -33,223 +37,6 @@ export default [ }, linterOptions: { reportUnusedDisableDirectives: true, - }, - rules: { - // https://github.com/typescript-eslint/typescript-eslint/blob/29c2e688afa7d9b8873d97c3961b65805d87cf2a/packages/eslint-plugin/src/configs/eslint-recommended.ts - 'constructor-super': 'off', // ts(2335) & ts(2377) - 'getter-return': 'off', // ts(2378) - 'no-const-assign': 'off', // ts(2588) - 'no-dupe-args': 'off', // ts(2300) - 'no-dupe-class-members': 'off', // ts(2393) & ts(2300) - 'no-dupe-keys': 'off', // ts(1117) - 'no-func-assign': 'off', // ts(2630) - 'no-import-assign': 'off', // ts(2632) & ts(2540) - 'no-new-symbol': 'off', // ts(7009) - 'no-obj-calls': 'off', // ts(2349) - 'no-redeclare': 'off', // ts(2451) - 'no-setter-return': 'off', // ts(2408) - 'no-this-before-super': 'off', // ts(2376) & ts(17009) - 'no-undef': 'off', // ts(2304) & ts(2552) - 'no-unreachable': 'off', // ts(7027) - 'no-unsafe-negation': 'off', // ts(2365) & ts(2322) & ts(2358)s - 'no-var': 'error', // ts transpiles let/const to var, so no need for vars any more - 'prefer-const': 'error', // ts provides better types with const - 'prefer-rest-params': 'error', // ts provides better types with rest args over arguments - 'prefer-spread': 'error', // ts transpiles spread to apply, so no need for manual apply - - // https://github.com/typescript-eslint/typescript-eslint/blob/29c2e688afa7d9b8873d97c3961b65805d87cf2a/packages/eslint-plugin/src/configs/all.ts - '@typescript-eslint/adjacent-overload-signatures': 'error', - '@typescript-eslint/array-type': 'error', - '@typescript-eslint/await-thenable': 'error', - '@typescript-eslint/ban-ts-comment': 'error', - '@typescript-eslint/ban-tslint-comment': 'error', - '@typescript-eslint/ban-types': 'error', - '@typescript-eslint/block-spacing': 'error', - 'brace-style': 'off', - '@typescript-eslint/brace-style': 'error', - '@typescript-eslint/class-literal-property-style': 'error', - 'comma-spacing': 'off', - '@typescript-eslint/comma-spacing': 'error', - '@typescript-eslint/consistent-generic-constructors': 'error', - '@typescript-eslint/consistent-indexed-object-style': 'error', - '@typescript-eslint/consistent-type-assertions': 'error', - '@typescript-eslint/consistent-type-definitions': 'error', - '@typescript-eslint/consistent-type-exports': 'error', - '@typescript-eslint/consistent-type-imports': 'error', - 'default-param-last': 'off', - '@typescript-eslint/default-param-last': 'error', - 'dot-notation': 'off', - '@typescript-eslint/dot-notation': 'error', - '@typescript-eslint/explicit-function-return-type': 'error', - '@typescript-eslint/explicit-member-accessibility': 'error', - '@typescript-eslint/explicit-module-boundary-types': 'error', - 'func-call-spacing': 'off', - '@typescript-eslint/func-call-spacing': 'error', - 'key-spacing': 'off', - '@typescript-eslint/key-spacing': 'error', - 'keyword-spacing': 'off', - '@typescript-eslint/keyword-spacing': 'error', - 'lines-around-comment': 'off', - '@typescript-eslint/lines-around-comment': 'error', - 'max-params': 'off', - '@typescript-eslint/max-params': 'error', - '@typescript-eslint/member-delimiter-style': 'error', - '@typescript-eslint/member-ordering': 'error', - '@typescript-eslint/method-signature-style': 'error', - 'no-array-constructor': 'off', - '@typescript-eslint/no-array-constructor': 'error', - '@typescript-eslint/no-base-to-string': 'error', - '@typescript-eslint/no-confusing-non-null-assertion': 'error', - '@typescript-eslint/no-confusing-void-expression': 'error', - 'no-dupe-class-members': 'off', - '@typescript-eslint/no-dupe-class-members': 'error', - '@typescript-eslint/no-duplicate-enum-values': 'error', - '@typescript-eslint/no-duplicate-type-constituents': 'error', - '@typescript-eslint/no-dynamic-delete': 'error', - 'no-empty-function': 'off', - '@typescript-eslint/no-empty-function': 'error', - '@typescript-eslint/no-empty-interface': 'error', - '@typescript-eslint/no-explicit-any': 'error', - '@typescript-eslint/no-extra-non-null-assertion': 'error', - 'no-extra-semi': 'off', - '@typescript-eslint/no-extra-semi': 'error', - '@typescript-eslint/no-extraneous-class': 'error', - '@typescript-eslint/no-floating-promises': 'error', - '@typescript-eslint/no-for-in-array': 'error', - 'no-implied-eval': 'off', - '@typescript-eslint/no-implied-eval': 'error', - '@typescript-eslint/no-import-type-side-effects': 'error', - '@typescript-eslint/no-inferrable-types': 'error', - 'no-invalid-this': 'off', - '@typescript-eslint/no-invalid-this': 'error', - '@typescript-eslint/no-invalid-void-type': 'error', - 'no-loop-func': 'off', - '@typescript-eslint/no-loop-func': 'error', - 'no-loss-of-precision': 'off', - '@typescript-eslint/no-loss-of-precision': 'error', - '@typescript-eslint/no-meaningless-void-operator': 'error', - '@typescript-eslint/no-misused-new': 'error', - '@typescript-eslint/no-misused-promises': 'error', - '@typescript-eslint/no-mixed-enums': 'error', - '@typescript-eslint/no-namespace': 'error', - '@typescript-eslint/no-non-null-asserted-nullish-coalescing': 'error', - '@typescript-eslint/no-non-null-asserted-optional-chain': 'error', - '@typescript-eslint/no-non-null-assertion': 'error', - 'no-redeclare': 'off', - '@typescript-eslint/no-redeclare': 'error', - '@typescript-eslint/no-redundant-type-constituents': 'error', - '@typescript-eslint/no-require-imports': 'error', - 'no-restricted-imports': 'off', - '@typescript-eslint/no-restricted-imports': 'error', - 'no-shadow': 'off', - '@typescript-eslint/no-shadow': 'error', - '@typescript-eslint/no-this-alias': 'error', - 'no-throw-literal': 'off', - '@typescript-eslint/no-throw-literal': 'error', - '@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error', - '@typescript-eslint/no-unnecessary-condition': 'error', - '@typescript-eslint/no-unnecessary-qualifier': 'error', - '@typescript-eslint/no-unnecessary-type-arguments': 'error', - '@typescript-eslint/no-unnecessary-type-assertion': 'error', - '@typescript-eslint/no-unnecessary-type-constraint': 'error', - '@typescript-eslint/no-unsafe-argument': 'error', - '@typescript-eslint/no-unsafe-assignment': 'error', - '@typescript-eslint/no-unsafe-call': 'error', - '@typescript-eslint/no-unsafe-declaration-merging': 'error', - '@typescript-eslint/no-unsafe-enum-comparison': 'error', - '@typescript-eslint/no-unsafe-member-access': 'error', - '@typescript-eslint/no-unsafe-return': 'error', - 'no-unused-expressions': 'off', - '@typescript-eslint/no-unused-expressions': 'error', - 'no-unused-vars': 'off', - '@typescript-eslint/no-unused-vars': 'error', - 'no-useless-constructor': 'off', - '@typescript-eslint/no-useless-constructor': 'error', - '@typescript-eslint/no-useless-empty-export': 'error', - '@typescript-eslint/no-var-requires': 'error', - '@typescript-eslint/non-nullable-type-assertion-style': 'error', - 'padding-line-between-statements': 'off', - '@typescript-eslint/padding-line-between-statements': 'error', - '@typescript-eslint/parameter-properties': 'error', - '@typescript-eslint/prefer-as-const': 'error', - '@typescript-eslint/prefer-enum-initializers': 'error', - 'prefer-destructuring': 'off', - '@typescript-eslint/prefer-destructuring': 'error', - '@typescript-eslint/prefer-for-of': 'error', - '@typescript-eslint/prefer-function-type': 'error', - '@typescript-eslint/prefer-includes': 'error', - '@typescript-eslint/prefer-literal-enum-member': 'error', - '@typescript-eslint/prefer-namespace-keyword': 'error', - '@typescript-eslint/prefer-nullish-coalescing': 'error', - '@typescript-eslint/prefer-optional-chain': 'error', - '@typescript-eslint/prefer-readonly': 'error', - '@typescript-eslint/prefer-reduce-type-parameter': 'error', - '@typescript-eslint/prefer-regexp-exec': 'error', - '@typescript-eslint/prefer-return-this-type': 'error', - '@typescript-eslint/prefer-string-starts-ends-with': 'error', - '@typescript-eslint/prefer-ts-expect-error': 'error', - '@typescript-eslint/promise-function-async': 'error', - '@typescript-eslint/require-array-sort-compare': 'error', - 'require-await': 'off', - '@typescript-eslint/require-await': 'error', - '@typescript-eslint/restrict-plus-operands': 'error', - '@typescript-eslint/restrict-template-expressions': 'error', - 'no-return-await': 'off', - '@typescript-eslint/return-await': 'error', - 'semi': 'off', - '@typescript-eslint/semi': 'error', - '@typescript-eslint/sort-type-constituents': 'error', - 'space-before-blocks': 'off', - '@typescript-eslint/space-before-blocks': 'error', - 'space-infix-ops': 'off', - '@typescript-eslint/space-infix-ops': 'error', - '@typescript-eslint/strict-boolean-expressions': 'error', - '@typescript-eslint/switch-exhaustiveness-check': 'error', - '@typescript-eslint/triple-slash-reference': 'error', - '@typescript-eslint/type-annotation-spacing': 'error', - '@typescript-eslint/typedef': 'error', - '@typescript-eslint/unbound-method': 'error', - '@typescript-eslint/unified-signatures': 'error', - - // my specials: - 'indent': 'off', - '@typescript-eslint/indent': ['error', 'tab', { 'SwitchCase': 1 }], - - 'linebreak-style': ['error', 'unix'], - - 'quotes': 'off', - '@typescript-eslint/quotes': ['error', 'single'], - - 'object-curly-spacing': 'off', - '@typescript-eslint/object-curly-spacing': ['error', 'always'], - - 'comma-dangle': 'off', - '@typescript-eslint/comma-dangle': ['error', 'always-multiline'], - - 'lines-between-class-members': 'off', - '@typescript-eslint/lines-between-class-members': ['error'], - - '@typescript-eslint/naming-convention': 'error', - - 'no-magic-numbers': 'off', - '@typescript-eslint/no-magic-numbers': 'off', - - 'no-extra-parens': 'off', - '@typescript-eslint/no-extra-parens': ['error', 'all', { 'conditionalAssign': false, 'nestedBinaryExpressions': false, 'ternaryOperandBinaryExpressions': false }], - - 'space-before-function-paren': 'off', - '@typescript-eslint/space-before-function-paren': ['error', { 'anonymous': 'always', 'named': 'never', 'asyncArrow': 'always' }], - - 'no-use-before-define': 'off', - '@typescript-eslint/no-use-before-define': ['error', { 'functions': false }], - - '@typescript-eslint/prefer-readonly-parameter-types': 'off', - - 'class-methods-use-this': 'off', - '@typescript-eslint/class-methods-use-this': 'off', - - 'init-declarations': 'off', - '@typescript-eslint/init-declarations': 'off', } } ] diff --git a/package-lock.json b/package-lock.json index 2834cf5..3e8b459 100644 --- a/package-lock.json +++ b/package-lock.json @@ -43,7 +43,8 @@ "ts-jest": "^29.2.5", "ts-node": "^10.9.2", "tsx": "^4.19.1", - "typescript": "^5.6.2" + "typescript": "^5.6.2", + "typescript-eslint": "^8.7.0" } }, "node_modules/@ampproject/remapping": { @@ -9577,6 +9578,30 @@ "node": ">=14.17" } }, + "node_modules/typescript-eslint": { + "version": "8.7.0", + "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.7.0.tgz", + "integrity": "sha512-nEHbEYJyHwsuf7c3V3RS7Saq+1+la3i0ieR3qP0yjqWSzVmh8Drp47uOl9LjbPANac4S7EFSqvcYIKXUUwIfIQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/eslint-plugin": "8.7.0", + "@typescript-eslint/parser": "8.7.0", + "@typescript-eslint/utils": "8.7.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, "node_modules/typewise": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/typewise/-/typewise-1.0.3.tgz", diff --git a/package.json b/package.json index 079c8b2..2b84bf4 100644 --- a/package.json +++ b/package.json @@ -67,6 +67,7 @@ "ts-jest": "^29.2.5", "ts-node": "^10.9.2", "tsx": "^4.19.1", - "typescript": "^5.6.2" + "typescript": "^5.6.2", + "typescript-eslint": "^8.7.0" } } diff --git a/scripts/build-sprites.test.ts b/scripts/build-sprites.test.ts index fadad53..5e16ca8 100644 --- a/scripts/build-sprites.test.ts +++ b/scripts/build-sprites.test.ts @@ -1,6 +1,6 @@ -/* eslint-disable @typescript-eslint/naming-convention */ -/* eslint-disable @typescript-eslint/unbound-method */ -/* eslint-disable @typescript-eslint/consistent-type-imports */ + + + import { jest } from '@jest/globals'; import type { Pack } from 'tar-stream'; diff --git a/scripts/build-styles.test.ts b/scripts/build-styles.test.ts index a90e534..2ddcdbc 100644 --- a/scripts/build-styles.test.ts +++ b/scripts/build-styles.test.ts @@ -1,6 +1,6 @@ -/* eslint-disable @typescript-eslint/naming-convention */ -/* eslint-disable @typescript-eslint/unbound-method */ -/* eslint-disable @typescript-eslint/consistent-type-imports */ + + + import { jest } from '@jest/globals'; import type { Pack } from 'tar-stream'; diff --git a/scripts/config-sprites.ts b/scripts/config-sprites.ts index 5f175d2..a76f9fc 100644 --- a/scripts/config-sprites.ts +++ b/scripts/config-sprites.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/naming-convention */ + export default { ratio: { diff --git a/scripts/lib/icons.test.ts b/scripts/lib/icons.test.ts index ebe09b6..a8bd4a9 100644 --- a/scripts/lib/icons.test.ts +++ b/scripts/lib/icons.test.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/naming-convention */ + import { jest } from '@jest/globals'; diff --git a/scripts/lib/sprites.test.ts b/scripts/lib/sprites.test.ts index 97d11cf..21df1ee 100644 --- a/scripts/lib/sprites.test.ts +++ b/scripts/lib/sprites.test.ts @@ -1,9 +1,9 @@ -/* eslint-disable @typescript-eslint/no-unsafe-call */ -/* eslint-disable @typescript-eslint/no-unsafe-assignment */ + + -/* eslint-disable @typescript-eslint/no-unsafe-member-access */ + /* eslint-disable @typescript-eslint/no-explicit-any */ -/* eslint-disable @typescript-eslint/naming-convention */ + import { jest } from '@jest/globals'; diff --git a/scripts/lib/sprites.ts b/scripts/lib/sprites.ts index 2778d81..b7b3aa8 100644 --- a/scripts/lib/sprites.ts +++ b/scripts/lib/sprites.ts @@ -20,7 +20,7 @@ export class Sprite { private distance?: Float64Array; - // eslint-disable-next-line @typescript-eslint/max-params + private constructor(entries: SpriteEntry[], width: number, height: number, buffer: Buffer) { if (width % 1 !== 0) throw Error(); if (height % 1 !== 0) throw Error(); @@ -148,9 +148,9 @@ export class Sprite { for (let i = 1; i < max; i++) { do { - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment + const r = v[k]; - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + s = (f[i] - f[r] + i ** 2 - r ** 2) / (i - r) / 2; } while (s <= z[k] && --k >= 0); @@ -163,9 +163,9 @@ export class Sprite { k = 0; for (let i = 0; i < max; i++) { while (z[k + 1] < i) k++; - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment + const r = v[k]; - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + data[offset + i * stepSize] = f[r] + (i - r) ** 2; } } @@ -257,7 +257,7 @@ export class Sprite { return this.bufferPng; } - // eslint-disable-next-line @typescript-eslint/require-await + private async getJSON(): Promise { let json = this.entries.map(e => ' "' + e.name + '": ' + JSON.stringify({ width: e.width, diff --git a/src/guess_style/guess_style.test.ts b/src/guess_style/guess_style.test.ts index 939dbc7..eefdeed 100644 --- a/src/guess_style/guess_style.test.ts +++ b/src/guess_style/guess_style.test.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/naming-convention */ + import type { Container, Header } from '@versatiles/container'; import { getShortbreadTemplate } from '../shortbread/index.js'; import type { TileJSONSpecificationVector, VectorLayer } from '../types/index.js'; @@ -140,7 +140,7 @@ describe('guessStyle', () => { cases.forEach(({ type, options }) => { it(type, () => { const style = guessStyle({ ...options, tiles: ['https://example1.org/tiles/{z}/{x}/{y}'], baseUrl: 'https://example2.org/' }); - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + expect(Object.values(style.sources)[0].tiles).toEqual(['https://example1.org/tiles/{z}/{x}/{y}']); }); }); @@ -150,7 +150,7 @@ describe('guessStyle', () => { cases.forEach(({ type, options }) => { it(type, () => { const style = guessStyle({ ...options, tiles: ['./{z}/{x}/{y}'], baseUrl: 'https://example2.org/tiles/' }); - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + expect(Object.values(style.sources)[0].tiles).toEqual(['https://example2.org/tiles/{z}/{x}/{y}']); }); }); diff --git a/src/guess_style/guess_style.ts b/src/guess_style/guess_style.ts index eaa7d30..8ca75a9 100644 --- a/src/guess_style/guess_style.ts +++ b/src/guess_style/guess_style.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/naming-convention */ + import type { TileJSONSpecification, TileJSONSpecificationBasic, MaplibreStyle, TileJSONSpecificationRaster, TileJSONSpecificationVector, VectorLayer } from '../types/index.js'; import { isTileJSONSpecification, isVectorLayers } from '../types/index.js'; @@ -35,11 +35,12 @@ export function guessStyle(opt: GuessStyleOptions): MaplibreStyle { let k: keyof typeof tilejsonBasic; for (k in tilejsonBasic) { - // eslint-disable-next-line @typescript-eslint/no-dynamic-delete + if (tilejsonBasic[k] === undefined) delete tilejsonBasic[k]; } let tilejson: TileJSONSpecification; + let vectorLayers: unknown[] | undefined; switch (format) { case 'avif': case 'jpg': @@ -48,7 +49,7 @@ export function guessStyle(opt: GuessStyleOptions): MaplibreStyle { tilejson = { ...tilejsonBasic, type: 'raster', format }; break; case 'pbf': - const { vectorLayers } = opt; + vectorLayers = opt.vectorLayers; if (!isVectorLayers(vectorLayers)) throw Error('property vector_layers is invalid'); tilejson = { ...tilejsonBasic, type: 'vector', format, vector_layers: vectorLayers }; break; @@ -103,7 +104,9 @@ export async function guessStyleFromContainer(container: Container, options: Gue try { const t = JSON.parse(metadata) as object; if (('vector_layers' in t) && Array.isArray(t.vector_layers)) vectorLayers = t.vector_layers; - } catch (e) { } + } catch (error) { + console.log(error); + } } const guessStyleOptions: GuessStyleOptions = { diff --git a/src/guess_style/random_color.ts b/src/guess_style/random_color.ts index 137aa6c..c022151 100644 --- a/src/guess_style/random_color.ts +++ b/src/guess_style/random_color.ts @@ -101,7 +101,7 @@ export default function randomColorGenerator(startSeed?: number | string): Rando if (typeof hue === 'string') { const color = colorDictionary[hue]; - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + if (color?.hueRange) return color.hueRange; } @@ -157,7 +157,7 @@ export default function randomColorGenerator(startSeed?: number | string): Rando return dic; } - // eslint-disable-next-line @typescript-eslint/naming-convention + function HSVtoHSL(hsv: [number, number, number]): [number, number, number] { const s = hsv[1] / 100, v = hsv[2] / 100, k = (2 - s) * v; return [hsv[0], 100 * s * v / (k < 1 ? k : 2 - k), 100 * k / 2]; diff --git a/src/index.test.ts b/src/index.test.ts index 61ab6df..cfacbe3 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/naming-convention */ + import type { VectorLayer } from './index.js'; import { guessStyle, styles } from './index.js'; diff --git a/src/lib/utils.test.ts b/src/lib/utils.test.ts index a9678e2..658979e 100644 --- a/src/lib/utils.test.ts +++ b/src/lib/utils.test.ts @@ -51,7 +51,7 @@ describe('isSimpleObject', () => { it('rejects objects with prototype properties', () => { class MyClass { - readonly #property = true; + readonly property = true; } expect(isSimpleObject(new MyClass())).toBe(false); }); diff --git a/src/lib/utils.ts b/src/lib/utils.ts index a4ffb4b..9c9f8da 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -118,7 +118,7 @@ export function deepMerge(source0: T, ...sources: T[]): T { } export function resolveUrl(base: string, url: string): string { - if (!Boolean(base)) return url; + if (!base) return url; url = new URL(url, base).href; url = url.replace(/%7B/gi, '{'); url = url.replace(/%7D/gi, '}'); diff --git a/src/shortbread/layers.ts b/src/shortbread/layers.ts index c59c7a9..3871dac 100644 --- a/src/shortbread/layers.ts +++ b/src/shortbread/layers.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/naming-convention */ + import type { LegacyFilterSpecification } from '@maplibre/maplibre-gl-style-spec'; import type { LanguageSuffix } from '../style_builder/index.js'; diff --git a/src/shortbread/properties.test.ts b/src/shortbread/properties.test.ts index e104e23..6b3268a 100644 --- a/src/shortbread/properties.test.ts +++ b/src/shortbread/properties.test.ts @@ -12,7 +12,7 @@ describe('propertyLookup', () => { expectedTypes.forEach(type => { propertyLookup.forEach((value, key) => { if (key.startsWith(type)) { - expect(key).toMatch(new RegExp(`^${type}\/`)); + expect(key).toMatch(new RegExp(`^${type}/`)); } }); }); diff --git a/src/shortbread/template.test.ts b/src/shortbread/template.test.ts index d4e7d4c..f7b25dd 100644 --- a/src/shortbread/template.test.ts +++ b/src/shortbread/template.test.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/naming-convention */ + import type { MaplibreStyle } from '../types/index.js'; import { getShortbreadTemplate } from './template.js'; diff --git a/src/shortbread/template.ts b/src/shortbread/template.ts index 7e759ed..7dd211d 100644 --- a/src/shortbread/template.ts +++ b/src/shortbread/template.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/naming-convention */ + import type { MaplibreStyleVector } from '../types/index.js'; diff --git a/src/style_builder/decorator.ts b/src/style_builder/decorator.ts index c73bdf4..519e9db 100644 --- a/src/style_builder/decorator.ts +++ b/src/style_builder/decorator.ts @@ -94,7 +94,7 @@ export function decorate(layers: MaplibreLayer[], rules: StyleRules, recolor: Ca layer.paint[key] = value; break; default: - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + throw new Error(`unknown parent "${propertyDef.parent}" for key "${key}"`); } }); diff --git a/src/style_builder/style_builder.test.ts b/src/style_builder/style_builder.test.ts index 5fd3ef0..e36f31d 100644 --- a/src/style_builder/style_builder.test.ts +++ b/src/style_builder/style_builder.test.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/naming-convention */ + import Color from 'color'; import type { MaplibreStyle } from '../types/maplibre.js'; import type { StyleRules, StyleRulesOptions } from './types.js'; diff --git a/src/style_builder/style_builder.ts b/src/style_builder/style_builder.ts index ec93ab4..f857a5a 100644 --- a/src/style_builder/style_builder.ts +++ b/src/style_builder/style_builder.ts @@ -23,7 +23,7 @@ export default abstract class StyleBuilder & { - // eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style + 'sources': { [_: string]: TileJSONSpecificationRaster }; }; /** Type for Maplibre styles specifically designed for vector sources. */ export type MaplibreStyleVector = Omit & { - // eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style + 'sources': { [_: string]: TileJSONSpecificationVector }; }; diff --git a/src/types/tilejson.test.ts b/src/types/tilejson.test.ts index 7534ceb..12d1790 100644 --- a/src/types/tilejson.test.ts +++ b/src/types/tilejson.test.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/naming-convention */ + import { isTileJSONSpecification } from './tilejson.js'; diff --git a/src/types/tilejson.ts b/src/types/tilejson.ts index 9d63720..8b82284 100644 --- a/src/types/tilejson.ts +++ b/src/types/tilejson.ts @@ -30,7 +30,7 @@ export interface TileJSONSpecificationRaster extends TileJSONSpecificationBasic export interface TileJSONSpecificationVector extends TileJSONSpecificationBasic { type: 'vector'; format: 'pbf'; - // eslint-disable-next-line @typescript-eslint/naming-convention + vector_layers: VectorLayer[]; }