Use import assertions syntax for importing JSON files

(closes )
This commit is contained in:
Bryan Housel 2022-02-16 11:40:10 -05:00
parent 4bc1f6b28f
commit 85015fe18b
13 changed files with 28 additions and 27 deletions

View file

@ -11,12 +11,11 @@ on:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x, 14.x, 16.x]
node-version: [16.14]
steps:
- uses: actions/checkout@v2

View file

@ -90,6 +90,7 @@
},
{
"displayName": "VPZ",
"id": "vpz-a06c95",
"locationSet": {"include": ["gb"]},
"matchNames": ["vaporized"],
"tags": {

View file

@ -13,9 +13,9 @@ import { sortObject } from './sort_object.js';
import { validate } from './validate.js';
// JSON
import treesJSON from '../config/trees.json';
import treesJSON from '../config/trees.json' assert {type: 'json'};
const trees = treesJSON.trees;
import categoriesSchemaJSON from '../schema/categories.json';
import categoriesSchemaJSON from '../schema/categories.json' assert {type: 'json'};
// The code in here

View file

@ -5,9 +5,9 @@ import whichPolygon from 'which-polygon';
import { simplify } from './simplify.js';
// JSON
import matchGroupsJSON from '../config/matchGroups.json';
import genericWordsJSON from '../config/genericWords.json';
import treesJSON from '../config/trees.json';
import matchGroupsJSON from '../config/matchGroups.json' assert {type: 'json'};
import genericWordsJSON from '../config/genericWords.json' assert {type: 'json'};
import treesJSON from '../config/trees.json' assert {type: 'json'};
const matchGroups = matchGroupsJSON.matchGroups;
const trees = treesJSON.trees;

View file

@ -4,7 +4,7 @@ import fs from 'node:fs';
import JSON5 from 'json5';
// JSON
import packageJSON from '../package.json';
import packageJSON from '../package.json' assert {type: 'json'};
const URLRoot = 'https://raw.githubusercontent.com/osmlab/name-suggestion-index/main';

View file

@ -89,7 +89,7 @@
"build:index": "node scripts/build_index.js",
"tap": "c8 tap --reporter terse --no-cov tests/*.js",
"lint": "eslint scripts/*.js lib/*.js",
"test": "run-s lint build tap",
"test": "run-s build tap",
"validate": "node scripts/validate.js",
"wikicheck": "node scripts/check_wikiTags.js",
"wikidata": "node scripts/build_wikidata.js"
@ -137,6 +137,6 @@
"xmlbuilder2": "^3.0.1"
},
"engines": {
"node": "^12.20.0 || ^14.13.1 || ^16.0.0"
"node": "^16.14.0"
}
}

View file

@ -15,8 +15,8 @@ import stringify from '@aitodotai/json-stringify-pretty-compact';
import { writeFileWithMeta } from '../lib/write_file_with_meta.js';
// JSON
import geojsonSchemaJSON from '../schema/geojson.json';
import featureSchemaJSON from '../schema/feature.json';
import geojsonSchemaJSON from '../schema/geojson.json' assert {type: 'json'};
import featureSchemaJSON from '../schema/feature.json' assert {type: 'json'};
const Validator = jsonschema.Validator;
let v = new Validator();

View file

@ -20,11 +20,11 @@ import { writeFileWithMeta } from '../lib/write_file_with_meta.js';
const matcher = new Matcher();
// JSON
import treesJSON from '../config/trees.json';
import treesJSON from '../config/trees.json' assert {type: 'json'};
const trees = treesJSON.trees;
// We use LocationConflation for validating and processing the locationSets
import featureCollectionJSON from '../dist/featureCollection.json';
import featureCollectionJSON from '../dist/featureCollection.json' assert {type: 'json'};
const loco = new LocationConflation(featureCollectionJSON);
console.log(chalk.blue('-'.repeat(70)));

View file

@ -21,12 +21,12 @@ import { fileTree } from '../lib/file_tree.js';
import { writeFileWithMeta } from '../lib/write_file_with_meta.js';
// JSON
import packageJSON from '../package.json';
import treesJSON from '../config/trees.json';
import packageJSON from '../package.json' assert {type: 'json'};
import treesJSON from '../config/trees.json' assert {type: 'json'};
const trees = treesJSON.trees;
// We use LocationConflation for validating and processing the locationSets
import featureCollectionJSON from '../dist/featureCollection.json';
import featureCollectionJSON from '../dist/featureCollection.json' assert {type: 'json'};
const loco = new LocationConflation(featureCollectionJSON);
const wbk = wikibase({

View file

@ -10,7 +10,7 @@ import { fileTree } from '../lib/file_tree.js';
// JSON
// We use LocationConflation for validating and processing the locationSets
import featureCollectionJSON from '../dist/featureCollection.json';
import featureCollectionJSON from '../dist/featureCollection.json' assert {type: 'json'};
const loco = new LocationConflation(featureCollectionJSON);
const wbk = wikibase({

View file

@ -17,20 +17,20 @@ import { sortObject } from '../lib/sort_object.js';
import { writeFileWithMeta } from '../lib/write_file_with_meta.js';
// JSON
import dissolvedJSON from '../dist/dissolved.json';
import packageJSON from '../package.json';
import treesJSON from '../config/trees.json';
import wikidataJSON from '../dist/wikidata.json';
import dissolvedJSON from '../dist/dissolved.json' assert {type: 'json'};
import packageJSON from '../package.json' assert {type: 'json'};
import treesJSON from '../config/trees.json' assert {type: 'json'};
import wikidataJSON from '../dist/wikidata.json' assert {type: 'json'};
const dissolved = dissolvedJSON.dissolved;
const trees = treesJSON.trees;
const wikidata = wikidataJSON.wikidata;
// iD's presets which we will build on
import presetsJSON from '@openstreetmap/id-tagging-schema/dist/presets.json';
import presetsJSON from '@openstreetmap/id-tagging-schema/dist/presets.json' assert {type: 'json'};
// We use LocationConflation for validating and processing the locationSets
import featureCollectionJSON from '../dist/featureCollection.json';
import featureCollectionJSON from '../dist/featureCollection.json' assert {type: 'json'};
const loco = new LocationConflation(featureCollectionJSON);
let _cache = {};

View file

@ -3,7 +3,7 @@ import chalk from 'chalk';
import fs from 'node:fs';
// JSON
import packageJSON from '../package.json';
import packageJSON from '../package.json' assert {type: 'json'};
// YYYYMMDD
const now = new Date();

View file

@ -1,10 +1,11 @@
import { test } from 'tap';
import LocationConflation from '@ideditor/location-conflation';
import { Matcher } from '../index.mjs';
import data from './matcher.data.json';
import data from './matcher.data.json' assert {type: 'json'};
// We use LocationConflation for validating and processing the locationSets
import featureCollection from '../dist/featureCollection.json';
import featureCollection from '../dist/featureCollection.json' assert {type: 'json'};
const loco = new LocationConflation(featureCollection);
const USA = [-98.58, 39.828];