From d60a69d8164cedf043c3e250a439f89d017f837a Mon Sep 17 00:00:00 2001 From: dave Date: Sat, 31 Dec 2022 00:31:32 +0100 Subject: [PATCH 1/5] #2025: Add check to ensure files end in .json --- src/checks/generic/json-file-extension.ts | 22 ++++++++++++++++++++++ src/checks/index.ts | 5 +++++ src/checks/record/match-filename-slug.ts | 4 ++-- src/test-records.ts | 2 +- 4 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 src/checks/generic/json-file-extension.ts diff --git a/src/checks/generic/json-file-extension.ts b/src/checks/generic/json-file-extension.ts new file mode 100644 index 000000000..0977d6d62 --- /dev/null +++ b/src/checks/generic/json-file-extension.ts @@ -0,0 +1,22 @@ +import { basename, extname } from 'path'; +import { exit } from 'process'; +import { Check } from '../../types/checks'; + +const check: Check = { + id: 'json-file-extension', + desc: 'Data files should end with `.json` (#2025)', + url: 'https://github.com/datenanfragen/data/#data-formats', + severity: 'ERROR', + run: (json, ctx) => { + const filename = basename(ctx.file_path); + const file_extension = extname(ctx.file_path) + + if (file_extension != ".json") + return { + message: `File \`${filename}\` should end in .json. Please rename the file.`, + location: { start: { line: 1 } }, + suggestions: [basename(filename, file_extension) + '.json'], + }; + }, +}; +export default check; diff --git a/src/checks/index.ts b/src/checks/index.ts index a84e785c3..34f28389e 100644 --- a/src/checks/index.ts +++ b/src/checks/index.ts @@ -32,6 +32,11 @@ const linters = async () => { url: 'https://github.com/datenanfragen/data/blob/master/src/checks/pack', path_filter: (path: string) => path.startsWith('company-packs/'), }, + generic: { + checks: await importChecks('generic'), + url: 'https://github.com/datenanfragen/data/blob/master/src/checks/generic', + path_filter: (path: string) => path.startsWith('companies/') || path.startsWith('company-packs/') || path.startsWith('supervisory-authorities/'), + }, }; }; export default linters; diff --git a/src/checks/record/match-filename-slug.ts b/src/checks/record/match-filename-slug.ts index e98f4cc25..c1d1aa46b 100644 --- a/src/checks/record/match-filename-slug.ts +++ b/src/checks/record/match-filename-slug.ts @@ -7,8 +7,8 @@ const check: Check = { url: 'https://github.com/datenanfragen/data/#data-formats', severity: 'ERROR', run: (json, ctx) => { - const filename = basename(ctx.file_path); - if (json.slug + '.json' !== filename) + const filename = basename(ctx.file_path, '.json'); + if (json.slug !== filename) return { message: `Filename \`${filename}\` does not match slug \`${json.slug}\`. diff --git a/src/test-records.ts b/src/test-records.ts index 5afb03311..0e29a9ffc 100644 --- a/src/test-records.ts +++ b/src/test-records.ts @@ -37,7 +37,7 @@ const validate = async (dir: string) => { const check_results: RdjsonLine[] = []; const linters = await _linters(); - const files = glob.sync(`${dir}/*.json`); + const files = glob.sync(`${dir}/*`); for (const f of files) { const file_content = fs.readFileSync(f).toString(); From b6e3a130e2fd09d17ddb8be98599d1ed5c70b323 Mon Sep 17 00:00:00 2001 From: dave Date: Sat, 31 Dec 2022 00:32:19 +0100 Subject: [PATCH 2/5] #2025: Fix file with missing extension --- companies/mdm-de.json | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 companies/mdm-de.json diff --git a/companies/mdm-de.json b/companies/mdm-de.json new file mode 100644 index 000000000..483a25bcb --- /dev/null +++ b/companies/mdm-de.json @@ -0,0 +1,24 @@ +{ + "slug": "mdm-de", + "relevant-countries": [ + "all" + ], + "categories": [ + "finance", + "commerce" + ], + "name": "MDM Münzhandelsgesellschaft mbH & Co. KG Deutsche Münze", + "address": "Theodor-Heuss-Straße 7\n38097 Braunschweig\nDeutschland", + "phone": "+49 531 2052053", + "fax": "+49 531 2051500", + "email": "datenschutz@mdm.de", + "web": "https://www.mdm.de", + "sources": [ + "https://www.mdm.de/service/Datenschutz/", + "https://www.mdm.de/ueber-mdm/impressum/", + "https://www.mdm.de/service/versand/", + "https://github.com/datenanfragen/data/pull/1236" + ], + "suggested-transport-medium": "email", + "quality": "verified" +} From f5da46f123709a05bc8887c285d432b0a8cc0afc Mon Sep 17 00:00:00 2001 From: dave Date: Sat, 31 Dec 2022 00:39:07 +0100 Subject: [PATCH 3/5] #2025: Delete file without file extension from git --- companies/mdm-de | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 companies/mdm-de diff --git a/companies/mdm-de b/companies/mdm-de deleted file mode 100644 index 483a25bcb..000000000 --- a/companies/mdm-de +++ /dev/null @@ -1,24 +0,0 @@ -{ - "slug": "mdm-de", - "relevant-countries": [ - "all" - ], - "categories": [ - "finance", - "commerce" - ], - "name": "MDM Münzhandelsgesellschaft mbH & Co. KG Deutsche Münze", - "address": "Theodor-Heuss-Straße 7\n38097 Braunschweig\nDeutschland", - "phone": "+49 531 2052053", - "fax": "+49 531 2051500", - "email": "datenschutz@mdm.de", - "web": "https://www.mdm.de", - "sources": [ - "https://www.mdm.de/service/Datenschutz/", - "https://www.mdm.de/ueber-mdm/impressum/", - "https://www.mdm.de/service/versand/", - "https://github.com/datenanfragen/data/pull/1236" - ], - "suggested-transport-medium": "email", - "quality": "verified" -} From b0a731551dfee7959889ae5f564f04b83d27d8f3 Mon Sep 17 00:00:00 2001 From: dave Date: Sun, 1 Jan 2023 22:39:39 +0100 Subject: [PATCH 4/5] #2025: Add suggested companies folder to json file end test --- src/checks/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/checks/index.ts b/src/checks/index.ts index 34f28389e..ac3cacc04 100644 --- a/src/checks/index.ts +++ b/src/checks/index.ts @@ -32,10 +32,10 @@ const linters = async () => { url: 'https://github.com/datenanfragen/data/blob/master/src/checks/pack', path_filter: (path: string) => path.startsWith('company-packs/'), }, - generic: { + genericlint: { checks: await importChecks('generic'), url: 'https://github.com/datenanfragen/data/blob/master/src/checks/generic', - path_filter: (path: string) => path.startsWith('companies/') || path.startsWith('company-packs/') || path.startsWith('supervisory-authorities/'), + path_filter: (path: string) => path.startsWith('companies/') || path.startsWith('company-packs/') || path.startsWith('supervisory-authorities/') || path.startsWith('suggested-companies/'), }, }; }; From 29c4844dca49de1bf82d3ab36be907a697108717 Mon Sep 17 00:00:00 2001 From: dave Date: Sat, 7 Jan 2023 01:39:41 +0100 Subject: [PATCH 5/5] Smite away invisible unicode chars --- companies/autoscout24.json | 2 +- companies/moebel-boss.json | 2 +- companies/prettylittlething.json | 2 +- companies/soundcloud.json | 2 +- supervisory-authorities/grdpa.json | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/companies/autoscout24.json b/companies/autoscout24.json index e62198a8c..345f278ab 100644 --- a/companies/autoscout24.json +++ b/companies/autoscout24.json @@ -6,7 +6,7 @@ "insurance" ], "name": "AutoScout24 GmbH", - "address": "Bothestraße 11 – 15\n81675 München\nDeutschland", + "address": "Bothestraße 11 – 15\n81675 München\nDeutschland", "phone": "+49 89 444 56 1666", "email": "widerspruch@autoscout24.de", "web": "https://www.autoscout24.de/", diff --git a/companies/moebel-boss.json b/companies/moebel-boss.json index ffa477ce3..a4e9f5727 100644 --- a/companies/moebel-boss.json +++ b/companies/moebel-boss.json @@ -7,7 +7,7 @@ "commerce" ], "name": "SB-Möbel Boss Handelsgesellschaft mbH & Co. KG", - "address": "Bakenweg 16 – 20\n32457 Porta Westfalica\nDeutschland", + "address": "Bakenweg 16 – 20\n32457 Porta Westfalica\nDeutschland", "phone": "+49 5731 609 0", "fax": "+49 5731 609 588", "email": "info@moebel-boss.de", diff --git a/companies/prettylittlething.json b/companies/prettylittlething.json index c5ac1f95c..ce355fabe 100644 --- a/companies/prettylittlething.json +++ b/companies/prettylittlething.json @@ -7,7 +7,7 @@ "commerce" ], "name": "Prettylittlething.com Ltd.", - "address": "49 – 51 Dale Street\nManchester\nM1 2HF\nUnited Kingdom", + "address": "49 – 51 Dale Street\nManchester\nM1 2HF\nUnited Kingdom", "email": "customerservices@prettylittlething.com", "web": "https://www.prettylittlething.com", "sources": [ diff --git a/companies/soundcloud.json b/companies/soundcloud.json index ae38b7d98..3c43fc9c3 100644 --- a/companies/soundcloud.json +++ b/companies/soundcloud.json @@ -11,7 +11,7 @@ "SoundCloud Go+", "SoundCloud Inc." ], - "address": "Rheinsberger Straße 76 – 77\n10115 Berlin\nDeutschland", + "address": "Rheinsberger Straße 76 – 77\n10115 Berlin\nDeutschland", "phone": "+49 30 467 247 600", "email": "dataprotection@soundcloud.com", "web": "https://soundcloud.com/", diff --git a/supervisory-authorities/grdpa.json b/supervisory-authorities/grdpa.json index aaffa25eb..5cab60a99 100644 --- a/supervisory-authorities/grdpa.json +++ b/supervisory-authorities/grdpa.json @@ -4,7 +4,7 @@ "gr" ], "name": "Αρχή Προστασίας Δεδομένων Προσωπικού Χαρακτήρα (Hellenic Data Protection Authority)", - "address": "Kifissias 1 – 3\n115 23 Athens\nGreece", + "address": "Kifissias 1 – 3\n115 23 Athens\nGreece", "phone": "+30 210 64756 00", "fax": "+30 210 64756 28", "email": "complaints@dpa.gr",