@ulrik.ek/wgs84 1.0.5 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,15 +1,15 @@
1
1
  export interface Point {
2
- type: 'Point';
3
2
  coordinates: number[];
3
+ type: 'Point';
4
4
  }
5
5
  export declare function point(lat: number, lon: number, height?: number): Point;
6
- export declare function R1(position: Point): number;
7
- export declare function R2(position: Point): number;
8
- export declare function distanceNorth(origin: Point, target: Point): number;
6
+ export declare function bearing(origin: Point, target: Point): number;
7
+ export declare function distance(origin: Point, target: Point): number;
9
8
  export declare function distanceEast(origin: Point, target: Point): number;
9
+ export declare function distanceNorth(origin: Point, target: Point): number;
10
10
  export declare function distanceUp(origin: Point, target: Point): number;
11
- export declare function distance(origin: Point, target: Point): number;
12
- export declare function bearing(origin: Point, target: Point): number;
13
- export declare function pointNorthOf(origin: Point, dN: number): Point;
14
- export declare function pointEastOf(origin: Point, dE: number): Point;
15
11
  export declare function pointAbove(origin: Point, dH: number): Point;
12
+ export declare function pointEastOf(origin: Point, dE: number): Point;
13
+ export declare function pointNorthOf(origin: Point, dN: number): Point;
14
+ export declare function R1(position: Point): number;
15
+ export declare function R2(position: Point): number;
package/dist/index.js CHANGED
@@ -1,16 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.point = point;
4
- exports.R1 = R1;
5
- exports.R2 = R2;
6
- exports.distanceNorth = distanceNorth;
4
+ exports.bearing = bearing;
5
+ exports.distance = distance;
7
6
  exports.distanceEast = distanceEast;
7
+ exports.distanceNorth = distanceNorth;
8
8
  exports.distanceUp = distanceUp;
9
- exports.distance = distance;
10
- exports.bearing = bearing;
11
- exports.pointNorthOf = pointNorthOf;
12
- exports.pointEastOf = pointEastOf;
13
9
  exports.pointAbove = pointAbove;
10
+ exports.pointEastOf = pointEastOf;
11
+ exports.pointNorthOf = pointNorthOf;
12
+ exports.R1 = R1;
13
+ exports.R2 = R2;
14
14
  function point(lat, lon, height) {
15
15
  const result = height
16
16
  ? { coordinates: [lon, lat, height], type: 'Point' }
@@ -21,22 +21,22 @@ function point(lat, lon, height) {
21
21
  const R = 6378.137 * 1000;
22
22
  const f = 1 / 298.257_223_563;
23
23
  const eSquared = f * (2 - f);
24
- function R1(position) {
25
- validCoord(position);
26
- const lat = degToRad(position.coordinates[1]);
27
- return (R * (1 - eSquared)) / Math.pow(1 - eSquared * Math.pow(Math.sin(lat), 2), 3 / 2);
28
- }
29
- function R2(position) {
30
- validCoord(position);
31
- const lat = degToRad(position.coordinates[1]);
32
- return R / Math.sqrt(1 - eSquared * Math.pow(Math.sin(lat), 2));
33
- }
34
- function distanceNorth(origin, target) {
24
+ function bearing(origin, target) {
35
25
  validCoord(origin);
36
26
  validCoord(target);
37
- const originLat = degToRad(origin.coordinates[1]);
38
- const targetLat = degToRad(target.coordinates[1]);
39
- return R1(origin) * (targetLat - originLat);
27
+ return ((radToDeg(Math.atan2(distanceEast(origin, target), distanceNorth(origin, target))) + 360) %
28
+ 360);
29
+ }
30
+ function distance(origin, target) {
31
+ if (origin.coordinates.length === 2 || target.coordinates.length === 2) {
32
+ return Math.hypot(distanceNorth(origin, target), distanceEast(origin, target));
33
+ }
34
+ else if (origin.coordinates.length === 3 && target.coordinates.length === 3) {
35
+ return Math.hypot(distanceNorth(origin, target), distanceEast(origin, target), distanceUp(origin, target));
36
+ }
37
+ else {
38
+ throw new Error('Inputs are not GeoJSON Points.');
39
+ }
40
40
  }
41
41
  function distanceEast(origin, target) {
42
42
  validCoord(origin);
@@ -53,6 +53,13 @@ function distanceEast(origin, target) {
53
53
  }
54
54
  return R2(origin) * Math.cos(originLat) * deltaAngle;
55
55
  }
56
+ function distanceNorth(origin, target) {
57
+ validCoord(origin);
58
+ validCoord(target);
59
+ const originLat = degToRad(origin.coordinates[1]);
60
+ const targetLat = degToRad(target.coordinates[1]);
61
+ return R1(origin) * (targetLat - originLat);
62
+ }
56
63
  function distanceUp(origin, target) {
57
64
  if (origin.coordinates.length === 3 && target.coordinates.length === 3) {
58
65
  return target.coordinates[2] - origin.coordinates[2];
@@ -61,37 +68,12 @@ function distanceUp(origin, target) {
61
68
  throw new Error('Input is not GeoJSON Point with height.');
62
69
  }
63
70
  }
64
- function distance(origin, target) {
65
- if (origin.coordinates.length === 2 || target.coordinates.length === 2) {
66
- return Math.hypot(distanceNorth(origin, target), distanceEast(origin, target));
67
- }
68
- else if (origin.coordinates.length === 3 && target.coordinates.length === 3) {
69
- return Math.hypot(distanceNorth(origin, target), distanceEast(origin, target), distanceUp(origin, target));
70
- }
71
- else {
72
- throw new Error('Inputs are not GeoJSON Points.');
73
- }
74
- }
75
- function bearing(origin, target) {
76
- validCoord(origin);
77
- validCoord(target);
78
- return ((radToDeg(Math.atan2(distanceEast(origin, target), distanceNorth(origin, target))) + 360) %
79
- 360);
80
- }
81
- function pointNorthOf(origin, dN) {
71
+ function pointAbove(origin, dH) {
82
72
  validCoord(origin);
83
- const lon = origin.coordinates[0];
84
- const lat = radToDeg(degToRad(origin.coordinates[1]) + dN / R1(origin));
85
- let result;
86
- if (origin.coordinates[2]) {
87
- const h = origin.coordinates[2];
88
- result = { coordinates: [lon, lat, h], type: 'Point' };
89
- }
90
- else {
91
- result = { coordinates: [lon, lat], type: 'Point' };
92
- }
93
- validCoord(result);
94
- return result;
73
+ return {
74
+ coordinates: [origin.coordinates[0], origin.coordinates[1], origin.coordinates[2] + dH],
75
+ type: 'Point'
76
+ };
95
77
  }
96
78
  function pointEastOf(origin, dE) {
97
79
  validCoord(origin);
@@ -111,12 +93,30 @@ function pointEastOf(origin, dE) {
111
93
  return { coordinates: [lon, lat], type: 'Point' };
112
94
  }
113
95
  }
114
- function pointAbove(origin, dH) {
96
+ function pointNorthOf(origin, dN) {
115
97
  validCoord(origin);
116
- return {
117
- coordinates: [origin.coordinates[0], origin.coordinates[1], origin.coordinates[2] + dH],
118
- type: 'Point'
119
- };
98
+ const lon = origin.coordinates[0];
99
+ const lat = radToDeg(degToRad(origin.coordinates[1]) + dN / R1(origin));
100
+ let result;
101
+ if (origin.coordinates[2]) {
102
+ const h = origin.coordinates[2];
103
+ result = { coordinates: [lon, lat, h], type: 'Point' };
104
+ }
105
+ else {
106
+ result = { coordinates: [lon, lat], type: 'Point' };
107
+ }
108
+ validCoord(result);
109
+ return result;
110
+ }
111
+ function R1(position) {
112
+ validCoord(position);
113
+ const lat = degToRad(position.coordinates[1]);
114
+ return (R * (1 - eSquared)) / Math.pow(1 - eSquared * Math.pow(Math.sin(lat), 2), 3 / 2);
115
+ }
116
+ function R2(position) {
117
+ validCoord(position);
118
+ const lat = degToRad(position.coordinates[1]);
119
+ return R / Math.sqrt(1 - eSquared * Math.pow(Math.sin(lat), 2));
120
120
  }
121
121
  function degToRad(deg) {
122
122
  return (deg * Math.PI) / 180;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAiBA,sBAMC;AAeD,gBAIC;AAQD,gBAIC;AASD,sCAMC;AASD,oCAaC;AAQD,gCAMC;AAUD,4BAYC;AAUD,0BAQC;AASD,oCAaC;AASD,kCAiBC;AASD,gCAMC;AA/LD,SAAgB,KAAK,CAAC,GAAW,EAAE,GAAW,EAAE,MAAe;IAC3D,MAAM,MAAM,GAAU,MAAM;QACxB,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE;QACpD,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IACjD,UAAU,CAAC,MAAM,CAAC,CAAC;IACnB,OAAO,MAAM,CAAC;AAClB,CAAC;AAGD,MAAM,CAAC,GAAW,QAAQ,GAAG,IAAI,CAAC;AAElC,MAAM,CAAC,GAAW,CAAC,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I,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,CAAC;QAC1D,CAAC,EAAE,IAAI,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;QACvB,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,EAAE;QACrB,CAAC,GAAG,IAAI,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;QACxB,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,GAAG,EACzB,CAAC;QACC,OAAO,IAAI,CAAC;IAChB,CAAC;SAAM,CAAC;QACJ,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAC/D,CAAC;AACL,CAAC"}
@@ -1 +1 @@
1
- {"root":["../src/index.ts"],"version":"5.9.3"}
1
+ {"root":["../src/index.ts"],"errors":true,"version":"6.0.2"}
package/eslint.config.mjs CHANGED
@@ -1,336 +1,79 @@
1
1
  // @ts-check
2
2
  import eslint from '@eslint/js';
3
3
  import tseslint from 'typescript-eslint';
4
- import jestPlugin from 'eslint-plugin-jest';
5
- import importPlugin from 'eslint-plugin-import';
6
- import simpleImportSort from 'eslint-plugin-simple-import-sort';
7
- import sortKeysFix from 'eslint-plugin-sort-keys-fix';
8
- import sortClassMembers from 'eslint-plugin-sort-class-members';
4
+ import perfectionist from 'eslint-plugin-perfectionist';
5
+ import globals from 'globals';
9
6
 
10
7
  export default tseslint.config(
11
- // Base recommended configs
8
+ // 1. Globala ignoreringar (ersätter din gamla ignores-block)
9
+ {
10
+ ignores: [
11
+ 'dist/**',
12
+ 'coverage/**',
13
+ 'report/**',
14
+ 'node_modules/**',
15
+ 'doc/**',
16
+ '*.config.*'
17
+ ],
18
+ },
19
+
20
+ // 2. Bas-konfiguration (JS & TS Rekommenderat + Sortering)
12
21
  eslint.configs.recommended,
13
22
  ...tseslint.configs.recommended,
14
-
15
- // Global configuration for TypeScript files with type checking
16
- {
17
- files: ['src/**/*.ts'],
18
- extends: [...tseslint.configs.recommendedTypeChecked],
19
-
20
- plugins: {
21
- '@typescript-eslint': tseslint.plugin,
22
- 'jest': jestPlugin,
23
- 'import': importPlugin,
24
- 'simple-import-sort': simpleImportSort,
25
- 'sort-keys-fix': sortKeysFix,
26
- 'sort-class-members': sortClassMembers,
27
- },
23
+ perfectionist.configs['recommended-natural'],
28
24
 
25
+ // 3. Gemensamma inställningar för alla filer
26
+ {
29
27
  languageOptions: {
30
- parser: tseslint.parser,
31
- parserOptions: {
32
- ecmaVersion: 2018,
33
- sourceType: 'module',
34
- project: './tsconfig.json',
35
- },
28
+ ecmaVersion: 'latest',
29
+ sourceType: 'module',
36
30
  globals: {
37
- // Node.js globals
38
- process: 'readonly',
39
- __dirname: 'readonly',
40
- __filename: 'readonly',
41
- require: 'readonly',
42
- module: 'readonly',
43
- exports: 'writable',
44
- Buffer: 'readonly',
45
- console: 'readonly',
46
- // Jest globals
47
- describe: 'readonly',
48
- test: 'readonly',
49
- it: 'readonly',
50
- expect: 'readonly',
51
- beforeEach: 'readonly',
52
- afterEach: 'readonly',
53
- beforeAll: 'readonly',
54
- afterAll: 'readonly',
55
- jest: 'readonly',
31
+ ...globals.node,
32
+ ...globals.vitest, // Lägger till describe, it, expect etc. automatiskt
56
33
  },
57
34
  },
58
-
59
- settings: {
60
- 'import/parsers': {
61
- '@typescript-eslint/parser': ['.ts'],
62
- },
63
- 'import/resolver': {
64
- node: {
65
- extensions: ['.ts'],
66
- },
67
- },
68
- },
69
-
70
35
  rules: {
71
- // Jest recommended rules
72
- ...jestPlugin.configs.recommended.rules,
73
-
74
- // Import plugin rules
75
- 'import/first': 'error',
76
- 'import/newline-after-import': 'error',
77
- 'import/no-duplicates': 'error',
78
- 'import/no-default-export': 'error',
79
-
80
- // Simple import sort
81
- 'sort-imports': 'off',
82
- 'import/order': 'off',
83
- 'simple-import-sort/imports': 'error',
84
- 'simple-import-sort/exports': 'error',
85
-
86
- // Sort class members
87
- 'sort-class-members/sort-class-members': ['error', {
88
- order: [
89
- '[static-properties]',
90
- '[properties]',
91
- '[conventional-private-properties]',
92
- 'constructor',
93
- '[static-methods]',
94
- '[methods]',
95
- '[conventional-private-methods]',
96
- ],
97
- accessorPairPositioning: 'getThenSet',
98
- }],
99
-
100
- // Sort keys
101
- 'sort-keys-fix/sort-keys-fix': 'warn',
102
-
103
- // Error prevention
104
- 'no-async-promise-executor': 'off',
105
- 'no-return-assign': 'error',
106
- 'curly': 'error',
107
- 'no-throw-literal': 'error',
108
- 'eqeqeq': ['error', 'always'],
109
-
110
- // Function rules
111
- 'func-names': ['error', 'always'],
112
- 'func-name-matching': ['error', { considerPropertyDescriptor: true }],
113
-
114
- // Code consistency
115
- 'no-confusing-arrow': 'error',
116
- 'no-useless-computed-key': 'error',
36
+ // Allmänna regler
37
+ 'no-console': 'error',
117
38
  'no-var': 'error',
118
39
  'prefer-const': 'error',
119
- 'prefer-spread': 'error',
120
- 'no-console': 'error',
121
- 'no-void': 'error',
122
-
123
- // Padding/spacing
124
- 'padding-line-between-statements': [
125
- 'error',
126
- { blankLine: 'always', prev: '*', next: 'function' },
127
- { blankLine: 'always', prev: '*', next: 'export' },
128
- ],
40
+ 'eqeqeq': ['error', 'always'],
41
+ 'curly': 'error',
42
+ 'no-throw-literal': 'error',
129
43
 
130
- // TypeScript-specific rules
131
- '@typescript-eslint/restrict-template-expressions': 'off',
132
- '@typescript-eslint/no-misused-promises': 'off',
133
- '@typescript-eslint/no-inferrable-types': 'off',
134
- '@typescript-eslint/no-unused-vars': 'off',
135
- '@typescript-eslint/no-namespace': ['error', {
136
- allowDeclarations: false,
137
- allowDefinitionFiles: false,
138
- }],
139
- '@typescript-eslint/explicit-member-accessibility': ['error', {
140
- accessibility: 'explicit',
141
- overrides: {
142
- constructors: 'no-public',
143
- properties: 'no-public',
144
- },
145
- }],
146
- '@typescript-eslint/no-empty-interface': 'off',
44
+ // TypeScript-specifika regler (utan typ-check krav)
45
+ '@typescript-eslint/no-unused-vars': 'warn',
147
46
  '@typescript-eslint/explicit-function-return-type': 'error',
148
- '@typescript-eslint/explicit-module-boundary-types': 'error',
149
- '@typescript-eslint/interface-name-prefix': 'off',
150
- '@typescript-eslint/member-delimiter-style': 'off',
151
- '@typescript-eslint/consistent-type-assertions': ['error', {
152
- assertionStyle: 'as',
153
- }],
154
- '@typescript-eslint/member-ordering': 'off',
155
- '@typescript-eslint/no-extra-non-null-assertion': 'error',
156
- '@typescript-eslint/no-misused-new': 'error',
157
- '@typescript-eslint/no-useless-constructor': 'error',
158
- '@typescript-eslint/prefer-function-type': 'error',
159
- '@typescript-eslint/prefer-nullish-coalescing': 'error',
160
- '@typescript-eslint/require-array-sort-compare': 'error',
161
- '@typescript-eslint/restrict-plus-operands': 'error',
162
- '@typescript-eslint/unified-signatures': 'error',
163
- '@typescript-eslint/prefer-readonly': 'error',
164
- '@typescript-eslint/prefer-includes': 'error',
47
+ '@typescript-eslint/no-explicit-any': 'warn',
48
+ '@typescript-eslint/consistent-type-assertions': ['error', { assertionStyle: 'as' }],
49
+
50
+ // Perfectionist sköter nu all sortering (imports, keys, class members)
51
+ // Du behöver inte längre definiera order[] manuellt om du inte vill ha en special-ordning.
165
52
  },
166
53
  },
167
54
 
168
- // Configuration for test and example files (without type checking)
55
+ // 4. Konfiguration för källkod med strikt typ-check
169
56
  {
170
- files: ['test/**/*.ts', 'example/**/*.ts', 'scripts/**/*.ts'],
171
-
172
- plugins: {
173
- '@typescript-eslint': tseslint.plugin,
174
- 'jest': jestPlugin,
175
- 'import': importPlugin,
176
- 'simple-import-sort': simpleImportSort,
177
- 'sort-keys-fix': sortKeysFix,
178
- 'sort-class-members': sortClassMembers,
179
- },
180
-
57
+ files: ['src/**/*.ts'],
181
58
  languageOptions: {
182
- parser: tseslint.parser,
183
59
  parserOptions: {
184
- ecmaVersion: 2018,
185
- sourceType: 'module',
186
- // No project option - skip type checking for these files
187
- },
188
- globals: {
189
- process: 'readonly',
190
- __dirname: 'readonly',
191
- __filename: 'readonly',
192
- require: 'readonly',
193
- module: 'readonly',
194
- exports: 'writable',
195
- Buffer: 'readonly',
196
- console: 'readonly',
197
- describe: 'readonly',
198
- test: 'readonly',
199
- it: 'readonly',
200
- expect: 'readonly',
201
- beforeEach: 'readonly',
202
- afterEach: 'readonly',
203
- beforeAll: 'readonly',
204
- afterAll: 'readonly',
205
- jest: 'readonly',
206
- },
207
- },
208
-
209
- settings: {
210
- 'import/parsers': {
211
- '@typescript-eslint/parser': ['.ts'],
212
- },
213
- 'import/resolver': {
214
- node: {
215
- extensions: ['.ts'],
216
- },
60
+ project: './tsconfig.json',
61
+ tsconfigRootDir: import.meta.dirname,
217
62
  },
218
63
  },
219
-
220
64
  rules: {
221
- // Jest recommended rules
222
- ...jestPlugin.configs.recommended.rules,
223
-
224
- // Import plugin rules
225
- 'import/first': 'error',
226
- 'import/newline-after-import': 'error',
227
- 'import/no-duplicates': 'error',
228
- 'import/no-default-export': 'error',
229
-
230
- // Simple import sort
231
- 'sort-imports': 'off',
232
- 'import/order': 'off',
233
- 'simple-import-sort/imports': 'error',
234
- 'simple-import-sort/exports': 'error',
235
-
236
- // Sort class members
237
- 'sort-class-members/sort-class-members': ['error', {
238
- order: [
239
- '[static-properties]',
240
- '[properties]',
241
- '[conventional-private-properties]',
242
- 'constructor',
243
- '[static-methods]',
244
- '[methods]',
245
- '[conventional-private-methods]',
246
- ],
247
- accessorPairPositioning: 'getThenSet',
248
- }],
249
-
250
- // Sort keys
251
- 'sort-keys-fix/sort-keys-fix': 'warn',
252
-
253
- // Error prevention
254
- 'no-async-promise-executor': 'off',
255
- 'no-return-assign': 'error',
256
- 'curly': 'error',
257
- 'no-throw-literal': 'error',
258
- 'eqeqeq': ['error', 'always'],
259
-
260
- // Function rules
261
- 'func-names': ['error', 'always'],
262
- 'func-name-matching': ['error', { considerPropertyDescriptor: true }],
263
-
264
- // Code consistency
265
- 'no-confusing-arrow': 'error',
266
- 'no-useless-computed-key': 'error',
267
- 'no-var': 'error',
268
- 'prefer-const': 'error',
269
- 'prefer-spread': 'error',
270
- 'no-console': 'off', // Allow console in tests/examples
271
- 'no-void': 'error',
272
-
273
- // Padding/spacing
274
- 'padding-line-between-statements': [
275
- 'error',
276
- { blankLine: 'always', prev: '*', next: 'function' },
277
- { blankLine: 'always', prev: '*', next: 'export' },
278
- ],
279
-
280
- // TypeScript-specific rules (non-type-checked versions)
281
- '@typescript-eslint/no-unused-vars': 'off',
282
- '@typescript-eslint/no-namespace': ['error', {
283
- allowDeclarations: false,
284
- allowDefinitionFiles: false,
285
- }],
286
- '@typescript-eslint/explicit-member-accessibility': ['error', {
287
- accessibility: 'explicit',
288
- overrides: {
289
- constructors: 'no-public',
290
- properties: 'no-public',
291
- },
292
- }],
293
- '@typescript-eslint/no-empty-interface': 'off',
294
- '@typescript-eslint/explicit-function-return-type': 'error',
295
- '@typescript-eslint/explicit-module-boundary-types': 'error',
296
- '@typescript-eslint/interface-name-prefix': 'off',
297
- '@typescript-eslint/member-delimiter-style': 'off',
298
- '@typescript-eslint/consistent-type-assertions': ['error', {
299
- assertionStyle: 'as',
300
- }],
301
- '@typescript-eslint/member-ordering': 'off',
302
- '@typescript-eslint/no-extra-non-null-assertion': 'error',
303
- '@typescript-eslint/no-misused-new': 'error',
304
- '@typescript-eslint/no-useless-constructor': 'error',
305
-
306
- // Relaxed rules for test/example files
307
- '@typescript-eslint/no-explicit-any': 'off',
308
- '@typescript-eslint/unbound-method': 'off',
309
- '@typescript-eslint/require-await': 'off',
310
- '@typescript-eslint/ban-ts-ignore': 'off',
311
- 'jest/no-disabled-tests': 'off',
65
+ // Här kan du lägga till regler som kräver projekt-context
66
+ '@typescript-eslint/prefer-readonly': 'error',
67
+ '@typescript-eslint/require-array-sort-compare': 'error',
312
68
  },
313
69
  },
314
70
 
315
- // Override rules for server files
71
+ // 5. Undantag för tester och exempel (tillåt console etc.)
316
72
  {
317
- files: ['**/server/*.ts'],
73
+ files: ['test/**/*.ts', 'example/**/*.ts'],
318
74
  rules: {
319
- 'no-inner-declarations': 'off',
75
+ 'no-console': 'off', // Tillåt console i exempel och tester
76
+ '@typescript-eslint/no-explicit-any': 'off',
320
77
  },
321
- },
322
-
323
-
324
-
325
- // Ignore patterns (including config files)
326
- {
327
- ignores: [
328
- 'dist/**',
329
- 'coverage/**',
330
- 'report/**',
331
- 'node_modules/**',
332
- '*.config.*',
333
- 'eslint.config.mjs'
334
- ],
335
78
  }
336
79
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ulrik.ek/wgs84",
3
- "version": "1.0.5",
3
+ "version": "1.1.0",
4
4
  "description": "Basic library for computing small distances between WGS84 coordinates using a flat earth approximation.",
5
5
  "author": "Ulrik E.",
6
6
  "license": "MIT",
@@ -19,34 +19,29 @@
19
19
  "verify_and_install": "npm cache verify && npm install",
20
20
  "clean": "npx shx rm -rf ./coverage/ ./report/ ./dist/",
21
21
  "build": "tsc --build tsconfig.json",
22
- "test": "npm run clean && npx jest --clearCache && jest --verbose --coverage --color --modulePathIgnorePatterns=./dist/ && npm run build",
23
- "run_example": "npx ts-node example/index.ts",
22
+ "test": "vitest run --coverage",
23
+ "test:watch": "vitest",
24
+ "run_example": "npx tsx example/index.ts",
24
25
  "type_doc": "npx typedoc --plugin typedoc-plugin-markdown --out doc src/index.ts --excludeNotDocumented"
25
26
  },
26
27
  "devDependencies": {
27
- "@eslint/js": "^9.15.0",
28
+ "@eslint/js": "^10.0.1",
28
29
  "@types/geojson": "^7946.0.16",
29
30
  "@types/jest": "^30.0.0",
30
- "@types/node": "^24.10.1",
31
- "@typescript-eslint/eslint-plugin": "^8.47.0",
32
- "@typescript-eslint/parser": "^8.47.0",
33
- "eslint": "^9.15.0",
34
- "eslint-plugin-import": "^2.31.0",
35
- "eslint-plugin-jest": "^28.9.0",
36
- "eslint-plugin-simple-import-sort": "^12.1.1",
37
- "eslint-plugin-sort-class-members": "^1.21.0",
38
- "eslint-plugin-sort-keys-fix": "^1.1.2",
39
- "globals": "^15.12.0",
40
- "jest": "^30.2.0",
41
- "jest-junit": "^16.0.0",
42
- "prettier": "3.6.2",
31
+ "@types/node": "^25.5.2",
32
+ "@vitest/coverage-v8": "^4.1.2",
33
+ "eslint": "^10.2.0",
34
+ "eslint-plugin-perfectionist": "^5.8.0",
35
+ "globals": "^17.4.0",
36
+ "prettier": "^3.8.1",
43
37
  "shx": "^0.4.0",
44
- "ts-jest": "^29.4.5",
45
- "ts-node": "^10.9.2",
46
- "typescript-eslint": "^8.47.0",
47
- "typedoc": "^0.28.14",
48
- "typedoc-plugin-markdown": "^4.9.0",
49
- "typescript": "^5.9.3"
38
+ "ts-jest": "^29.4.9",
39
+ "tsx": "^4.21.0",
40
+ "typedoc": "^0.28.18",
41
+ "typedoc-plugin-markdown": "^4.11.0",
42
+ "typescript": "^6.0.2",
43
+ "typescript-eslint": "^8.58.0",
44
+ "vitest": "^4.1.2"
50
45
  },
51
46
  "types": "./dist/index.d.ts",
52
47
  "repository": {
@@ -0,0 +1 @@
1
+ {"root":["./src/index.ts"],"version":"6.0.2"}
@@ -0,0 +1,12 @@
1
+ import { defineConfig } from 'vitest/config';
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ globals: true, // Gör att 'describe', 'it', 'expect' finns tillgängliga globalt (som i Jest)
6
+ environment: 'node',
7
+ coverage: {
8
+ provider: 'v8',
9
+ reporter: ['text', 'json', 'html']
10
+ }
11
+ }
12
+ });