-
-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#2025: Add check to ensure files end in .json #2026
base: master
Are you sure you want to change the base?
Changes from all commits
d60a69d
b6e3a13
f5da46f
b0a7315
29c4844
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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": "[email protected]", | ||
"web": "https://www.autoscout24.de/", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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": "[email protected]", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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": "[email protected]", | ||
"web": "https://www.prettylittlething.com", | ||
"sources": [ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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": "[email protected]", | ||
"web": "https://soundcloud.com/", | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -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") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
return { | ||||||
message: `File \`${filename}\` should end in .json. Please rename the file.`, | ||||||
location: { start: { line: 1 } }, | ||||||
Comment on lines
+16
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This won't make much sense as a suggestion from the reviewbot, but afaik there is no way for a code suggestion to rename a file in GH. @baltpeter do you have an opinion on this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
No, there isn't. I agree, this should just be a comment without a suggestion. |
||||||
suggestions: [basename(filename, file_extension) + '.json'], | ||||||
}; | ||||||
}, | ||||||
}; | ||||||
export default check; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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/'), | ||
}, | ||
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.startsWith('suggested-companies/'), | ||
}, | ||
Comment on lines
+35
to
+39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to establish another check type for this? The suggested companies are deprecated (and can actually be removed from the repo now). If we made this a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually: If we decide, we only need this for |
||
}; | ||
}; | ||
export default linters; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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}/*`); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I worried this might create a problem on systems that like to automatically place files in directories ( We should ignore everything in the |
||
|
||
for (const f of files) { | ||
const file_content = fs.readFileSync(f).toString(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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": "[email protected]", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a stray import.