From 6d2a5147f5645bc092f7fdcc162342eadd303623 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Desboeufs?= Date: Wed, 30 Oct 2019 23:19:02 +0100 Subject: [PATCH] Revert xo changes --- improve-csv.js | 4 ++-- lib/parse.js | 2 +- lib/recog.js | 4 ++-- package.json | 5 ++++- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/improve-csv.js b/improve-csv.js index 361e0ac..68f980a 100644 --- a/improve-csv.js +++ b/improve-csv.js @@ -84,7 +84,7 @@ function convertRow(row, {culturesMap, culturesSpecialesMap}) { if (commune.code !== communeActuelleCadastre.code) { converted.ancien_id_parcelle = idParcelle - converted.id_parcelle = `${communeActuelle.code}${commune.code.slice(2, 3)}${idParcelle.slice(8)}` + converted.id_parcelle = `${communeActuelle.code}${commune.code.substr(2, 3)}${idParcelle.substr(8)}` } } @@ -130,7 +130,7 @@ async function main() { if (process.env.DISABLE_GEOCODING !== '1') { console.log('Géocodage à la parcelle') - const communesRows = groupBy(rows, r => r.id_parcelle.slice(0, 5)) + const communesRows = groupBy(rows, r => r.id_parcelle.substr(0, 5)) await bluebird.map(Object.keys(communesRows), async codeCommune => { const communeRows = communesRows[codeCommune] const parcelles = await getParcellesCommune(codeCommune) diff --git a/lib/parse.js b/lib/parse.js index ae9eaa3..742b5a8 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -12,7 +12,7 @@ function getPrefixeSection(row) { function getDateMutation(row) { const rawDateMutation = row['Date mutation'] - return `${rawDateMutation.slice(6, 4)}-${rawDateMutation.slice(3, 2)}-${rawDateMutation.slice(0, 2)}` + return `${rawDateMutation.substr(6, 4)}-${rawDateMutation.substr(3, 2)}-${rawDateMutation.substr(0, 2)}` } function getIdParcelle(row) { diff --git a/lib/recog.js b/lib/recog.js index 1a9932c..0ccf6b6 100644 --- a/lib/recog.js +++ b/lib/recog.js @@ -30,7 +30,7 @@ connectGraph(historiqueCommunes) const byCodeCommune = groupBy(historiqueCommunes.concat(arrondissementsMunicipaux), h => `${h.type}${h.code}`) function getCodeDepartement(codeCommune) { - return codeCommune.startsWith('97') ? codeCommune.slice(0, 3) : codeCommune.slice(0, 2) + return codeCommune.startsWith('97') ? codeCommune.substr(0, 3) : codeCommune.substr(0, 2) } function isValidAt(communeEntry, dateValeur) { @@ -59,7 +59,7 @@ function getCommuneFromCadastre(codeCommune, prefixeSection) { return getOlderCommune(codeCommune) } - const code1 = `${codeCommune.slice(0, 2)}${prefixeSection}` + const code1 = `${codeCommune.substr(0, 2)}${prefixeSection}` const commune1 = getOlderCommune(code1) if (commune1) { diff --git a/package.json b/package.json index 4575c7b..3500cbb 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,10 @@ }, "xo": { "semicolon": false, - "space": "2" + "space": "2", + "rules": { + "unicorn/prefer-string-slice": "off" + } }, "engines": { "node": ">= 10"