Merge pull request #2639 from betagouv/ec-lint

Add and use eclint
This commit is contained in:
gregoirenovel 2018-09-20 16:49:43 +02:00 committed by GitHub
commit 04153ff4e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
36 changed files with 801 additions and 115 deletions

View file

@ -9,3 +9,6 @@ charset = utf-8
indent_size = 2 indent_size = 2
indent_style = space indent_style = space
trim_trailing_whitespace = true trim_trailing_whitespace = true
[*.{ico,keep,pdf,svg}]
insert_final_newline = false

View file

@ -193,7 +193,7 @@
// CAUTION: IE hackery ahead // CAUTION: IE hackery ahead
&::-ms-expand { &::-ms-expand {
display: none; // remove default arrow in IE 10 and 11 */ display: none; // remove default arrow in IE 10 and 11 */
} }
// target Internet Explorer 9 to undo the custom arrow */ // target Internet Explorer 9 to undo the custom arrow */
@media screen and (min-width:0\0) { @media screen and (min-width:0\0) {

View file

@ -1,6 +1,7 @@
/* http://meyerweb.com/eric/tools/css/reset/ /*
v2.0 | 20110126 http://meyerweb.com/eric/tools/css/reset/
License: none (public domain) v2.0 | 20110126
License: none (public domain)
*/ */
html, body, div, span, applet, object, iframe, html, body, div, span, applet, object, iframe,
@ -12,37 +13,37 @@ b, u, i, center,
dl, dt, dd, ol, ul, li, dl, dt, dd, ol, ul, li,
fieldset, form, label, legend, fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td, table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup, figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary, menu, nav, output, ruby, section, summary,
time, mark, audio, video { time, mark, audio, video {
margin: 0; margin: 0;
padding: 0; padding: 0;
border: 0; border: 0;
font-size: 100%; font-size: 100%;
font: inherit; font: inherit;
vertical-align: baseline; vertical-align: baseline;
} }
/* HTML5 display-role reset for older browsers */ /* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section { footer, header, hgroup, menu, nav, section {
display: block; display: block;
} }
body { body {
line-height: 1; line-height: 1;
} }
ol, ul { ol, ul {
list-style: none; list-style: none;
} }
blockquote, q { blockquote, q {
quotes: none; quotes: none;
} }
blockquote:before, blockquote:after, blockquote:before, blockquote:after,
q:before, q:after { q:before, q:after {
content: ''; content: '';
content: none; content: none;
} }
table { table {
border-collapse: collapse; border-collapse: collapse;
border-spacing: 0; border-spacing: 0;
} }

View file

@ -76,5 +76,5 @@ class Users::CarteController < UsersController
multipolygone.to_json multipolygone.to_json
end end
end end
end end
end end

View file

@ -0,0 +1,21 @@
module DemandeHelper
def nb_of_procedures_options
{
'je ne sais pas' => Pipedrive::DealAdapter::PIPEDRIVE_NB_OF_PROCEDURES_DO_NOT_KNOW_VALUE,
'1' => Pipedrive::DealAdapter::PIPEDRIVE_NB_OF_PROCEDURES_1_VALUE,
'1 à 10' => Pipedrive::DealAdapter::PIPEDRIVE_NB_OF_PROCEDURES_1_TO_10_VALUE,
'10 à 100 ' => Pipedrive::DealAdapter::PIPEDRIVE_NB_OF_PROCEDURES_10_TO_100_VALUE,
'plus de 100' => Pipedrive::DealAdapter::PIPEDRIVE_NB_OF_PROCEDURES_ABOVE_100_VALUE
}
end
def deadline_options
{
'le plus vite possible' => Pipedrive::DealAdapter::PIPEDRIVE_DEADLINE_ASAP_VALUE,
'dans les 3 prochains mois' => Pipedrive::DealAdapter::PIPEDRIVE_DEADLINE_NEXT_3_MONTHS_VALUE,
'dans les 6 prochains mois' => Pipedrive::DealAdapter::PIPEDRIVE_DEADLINE_NEXT_6_MONTHS_VALUE,
'dans les 12 prochains mois' => Pipedrive::DealAdapter::PIPEDRIVE_DEADLINE_NEXT_12_MONTHS_VALUE,
'pas de date' => Pipedrive::DealAdapter::PIPEDRIVE_DEADLINE_NO_DATE_VALUE
}
end
end

View file

@ -848,4 +848,4 @@
{ {
"nom": "ZIMBABWE" "nom": "ZIMBABWE"
} }
] ]

View file

@ -8,7 +8,7 @@ class AdministrateurMailer < ApplicationMailer
@subject = "N'oubliez pas d'activer votre compte administrateur" @subject = "N'oubliez pas d'activer votre compte administrateur"
mail(to: administrateur.email, mail(to: administrateur.email,
subject: @subject, subject: @subject,
reply_to: CONTACT_EMAIL) reply_to: CONTACT_EMAIL)
end end
end end

View file

@ -7,7 +7,7 @@ class AdministrationMailer < ApplicationMailer
subject = "Création d'un compte admininistrateur" subject = "Création d'un compte admininistrateur"
mail(to: TECH_EMAIL, mail(to: TECH_EMAIL,
subject: subject) subject: subject)
end end
def invite_admin(admin, reset_password_token, administration_id) def invite_admin(admin, reset_password_token, administration_id)
@ -17,16 +17,16 @@ class AdministrationMailer < ApplicationMailer
subject = "Activez votre compte administrateur" subject = "Activez votre compte administrateur"
mail(to: admin.email, mail(to: admin.email,
subject: subject, subject: subject,
reply_to: CONTACT_EMAIL) reply_to: CONTACT_EMAIL)
end end
def refuse_admin(admin_email) def refuse_admin(admin_email)
subject = "Votre demande de compte a été refusée" subject = "Votre demande de compte a été refusée"
mail(to: admin_email, mail(to: admin_email,
subject: subject, subject: subject,
reply_to: CONTACT_EMAIL) reply_to: CONTACT_EMAIL)
end end
def dubious_procedures(procedures_and_type_de_champs) def dubious_procedures(procedures_and_type_de_champs)
@ -34,6 +34,6 @@ class AdministrationMailer < ApplicationMailer
subject = "[RGS] De nouvelles démarches comportent des champs interdits" subject = "[RGS] De nouvelles démarches comportent des champs interdits"
mail(to: EQUIPE_EMAIL, mail(to: EQUIPE_EMAIL,
subject: subject) subject: subject)
end end
end end

View file

@ -7,8 +7,8 @@ class GestionnaireMailer < ApplicationMailer
subject = "Activez votre compte instructeur" subject = "Activez votre compte instructeur"
mail(to: gestionnaire.email, mail(to: gestionnaire.email,
subject: subject, subject: subject,
reply_to: CONTACT_EMAIL) reply_to: CONTACT_EMAIL)
end end
def user_to_gestionnaire(email) def user_to_gestionnaire(email)

View file

@ -20,7 +20,7 @@ class InviteMailer < ApplicationMailer
email = invite.email email = invite.email
mail(to: email, mail(to: email,
subject: subject, subject: subject,
reply_to: reply_to) reply_to: reply_to)
end end
end end

View file

@ -26,8 +26,8 @@ class PreactivateUsersMailer < ApplicationMailer
END_OF_MAIL END_OF_MAIL
mail(to: model.email, mail(to: model.email,
subject: subject, subject: subject,
reply_to: CONTACT_EMAIL, reply_to: CONTACT_EMAIL,
body: body) body: body)
end end
end end

View file

@ -193,7 +193,7 @@ module TagsSubstitutionConcern
tags_and_datas tags_and_datas
.map { |(tags, data)| [filter_tags(tags), data] } .map { |(tags, data)| [filter_tags(tags), data] }
.inject(text) { |acc, (tags, data)| replace_tags_with_values_from_data(acc, tags, data) } .inject(text) { |acc, (tags, data)| replace_tags_with_values_from_data(acc, tags, data) }
end end
def replace_type_de_champ_tags(text, types_de_champ, dossier_champs) def replace_type_de_champ_tags(text, types_de_champ, dossier_champs)
types_de_champ.inject(text) do |acc, tag| types_de_champ.inject(text) do |acc, tag|

View file

@ -1 +1 @@
<%= "togglePathMessage(true, #{@mine})" %> <%= "togglePathMessage(true, #{@mine})" %>

View file

@ -46,11 +46,7 @@
Combien de démarches souhaitez-vous dématerialiser ? Combien de démarches souhaitez-vous dématerialiser ?
%span.mandatory * %span.mandatory *
= select_tag :nb_of_procedures, = select_tag :nb_of_procedures,
options_for_select({ 'je ne sais pas' => Pipedrive::DealAdapter::PIPEDRIVE_NB_OF_PROCEDURES_DO_NOT_KNOW_VALUE, options_for_select(nb_of_procedures_options),
'1' => Pipedrive::DealAdapter::PIPEDRIVE_NB_OF_PROCEDURES_1_VALUE,
'1 à 10' => Pipedrive::DealAdapter::PIPEDRIVE_NB_OF_PROCEDURES_1_TO_10_VALUE,
'10 à 100 ' => Pipedrive::DealAdapter::PIPEDRIVE_NB_OF_PROCEDURES_10_TO_100_VALUE,
'plus de 100' => Pipedrive::DealAdapter::PIPEDRIVE_NB_OF_PROCEDURES_ABOVE_100_VALUE }),
prompt: 'choisir un intervalle', prompt: 'choisir un intervalle',
required: true required: true
@ -58,11 +54,7 @@
À quelle échance voudriez-vous dématerialiser ? À quelle échance voudriez-vous dématerialiser ?
%span.mandatory * %span.mandatory *
= select_tag :deadline, = select_tag :deadline,
options_for_select({ 'le plus vite possible' => Pipedrive::DealAdapter::PIPEDRIVE_DEADLINE_ASAP_VALUE, options_for_select(deadline_options),
'dans les 3 prochains mois' => Pipedrive::DealAdapter::PIPEDRIVE_DEADLINE_NEXT_3_MONTHS_VALUE,
'dans les 6 prochains mois' => Pipedrive::DealAdapter::PIPEDRIVE_DEADLINE_NEXT_6_MONTHS_VALUE,
'dans les 12 prochains mois' => Pipedrive::DealAdapter::PIPEDRIVE_DEADLINE_NEXT_12_MONTHS_VALUE,
'pas de date' => Pipedrive::DealAdapter::PIPEDRIVE_DEADLINE_NO_DATE_VALUE }),
prompt: 'choisir une échéance', prompt: 'choisir une échéance',
required: true required: true

View file

@ -3,9 +3,9 @@
- if @facade.dossier.types_de_piece_justificative.size > 0 - if @facade.dossier.types_de_piece_justificative.size > 0
.col-lg-4.col-md-4.col-sm-4.col-xs-4.action .col-lg-4.col-md-4.col-sm-4.col-xs-4.action
%a#maj_pj.action{ "data-target" => "#upload-pj-modal", %a#maj_pj.action{ "data-target" => "#upload-pj-modal",
"data-toggle" => "modal", "data-toggle" => "modal",
:type => "button", :type => "button",
style: 'margin-bottom: 15px; margin-top: -30px;' } style: 'margin-bottom: 15px; margin-top: -30px;' }
Modifier les documents Modifier les documents
%br %br
= render partial: 'users/recapitulatif/modal_upload_pj' = render partial: 'users/recapitulatif/modal_upload_pj'

View file

@ -9,4 +9,4 @@ error_form_siret('<%= invalid_siret %>');
function render_new_siret(){ function render_new_siret(){
$('.row.etape.etape-2').html("<%= escape_javascript(render partial: '/dossiers/etapes/etape_2/entreprise', locals: { facade: @facade } ) %>"); $('.row.etape.etape-2').html("<%= escape_javascript(render partial: '/dossiers/etapes/etape_2/entreprise', locals: { facade: @facade } ) %>");
} }

View file

@ -10,4 +10,4 @@ error_form_siret('<%= invalid_siret %>');
function render_new_siret(){ function render_new_siret(){
$('.row.etape.etape-2').html("<%= escape_javascript(render partial: '/dossiers/etapes/etape2', locals: { facade: @facade } ) %>"); $('.row.etape.etape-2').html("<%= escape_javascript(render partial: '/dossiers/etapes/etape2', locals: { facade: @facade } ) %>");
} }

View file

@ -3,4 +3,4 @@
<% end -%> <% end -%>
<br> <br>
<%= link_to "Mot de passe oublié ?", new_password_path(resource_name) %><br /> <%= link_to "Mot de passe oublié ?", new_password_path(resource_name) %><br />

View file

@ -158,7 +158,7 @@ fr:
invalid_siret: "Le siret est incorrect" invalid_siret: "Le siret est incorrect"
procedure_not_found: "La démarche n'existe pas" procedure_not_found: "La démarche n'existe pas"
france_connect: france_connect:
connexion: "Erreur lors de la connexion à France Connect." connexion: "Erreur lors de la connexion à France Connect."
extension_white_list_error: "Le format de fichier de la pièce jointe n'est pas valide." extension_white_list_error: "Le format de fichier de la pièce jointe n'est pas valide."
procedure_archived: "Cette démarche en ligne a été fermée, il n'est plus possible de déposer de dossier." procedure_archived: "Cette démarche en ligne a été fermée, il n'est plus possible de déposer de dossier."

View file

@ -36,7 +36,7 @@ module Cellar
canonicalized_amz_headers = "" canonicalized_amz_headers = ""
canonicalized_resource = "/#{@bucket}/#{key}" canonicalized_resource = "/#{@bucket}/#{key}"
string_to_sign = "#{method}\n#{checksum}\n#{content_type}\n#{expires}#{date}\n" + string_to_sign = "#{method}\n#{checksum}\n#{content_type}\n#{expires}#{date}\n" +
"#{canonicalized_amz_headers}#{canonicalized_resource}" "#{canonicalized_amz_headers}#{canonicalized_resource}"
Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha1'), @secret_access_key, string_to_sign)).strip Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha1'), @secret_access_key, string_to_sign)).strip
end end
end end

View file

@ -3,5 +3,6 @@ task :lint do
sh "bundle exec haml-lint app/views/" sh "bundle exec haml-lint app/views/"
sh "bundle exec scss-lint app/assets/stylesheets/" sh "bundle exec scss-lint app/assets/stylesheets/"
sh "bundle exec brakeman --no-pager" sh "bundle exec brakeman --no-pager"
sh "yarn lint:ec"
sh "yarn lint:js" sh "yarn lint:js"
end end

View file

@ -15,6 +15,7 @@
"turbolinks": "^5.1.1" "turbolinks": "^5.1.1"
}, },
"devDependencies": { "devDependencies": {
"eclint": "^2.8.0",
"eslint": "^5.2.0", "eslint": "^5.2.0",
"eslint-config-prettier": "^2.9.0", "eslint-config-prettier": "^2.9.0",
"eslint-plugin-prettier": "^2.6.2", "eslint-plugin-prettier": "^2.6.2",
@ -22,6 +23,7 @@
"webpack-dev-server": "^3.1.4" "webpack-dev-server": "^3.1.4"
}, },
"scripts": { "scripts": {
"lint:ec": "eclint check $({ git ls-files ; find vendor -type f ; echo 'db/schema.rb' ; } | sort | uniq -u)",
"lint:js": "eslint ./app/javascript ./config/webpack" "lint:js": "eslint ./app/javascript ./config/webpack"
}, },
"engines": { "engines": {

View file

@ -691,9 +691,9 @@ describe Admin::ProceduresController, type: :controller do
let(:procedure) { create :procedure, :published, administrateur: admin } let(:procedure) { create :procedure, :published, administrateur: admin }
before do before do
subject subject
procedure.reload procedure.reload
end end
it { expect(procedure.hidden_at).not_to be_nil } it { expect(procedure.hidden_at).not_to be_nil }
it { expect(procedure.procedure_path).to be_nil } it { expect(procedure.procedure_path).to be_nil }

View file

@ -55,7 +55,7 @@ describe CARTO::SGMAP::API do
before do before do
stub_request(:post, "https://apicarto.sgmap.fr/cadastre/geometrie") stub_request(:post, "https://apicarto.sgmap.fr/cadastre/geometrie")
.with(:body => /.*/, .with(:body => /.*/,
:headers => { 'Content-Type' => 'application/json' }) :headers => { 'Content-Type' => 'application/json' })
.to_return(status: status, body: body) .to_return(status: status, body: body)
end end
context 'when geojson is empty' do context 'when geojson is empty' do

View file

@ -2,21 +2,21 @@ describe EmailSanitizableConcern, type: :model do
describe 'sanitize_email' do describe 'sanitize_email' do
let(:email_concern) do let(:email_concern) do
(Class.new do (Class.new do
include EmailSanitizableConcern include EmailSanitizableConcern
attr_accessor :email attr_accessor :email
def initialize(email) def initialize(email)
self.email = email self.email = email
end end
def [](key) def [](key)
self.send(key) self.send(key)
end end
def []=(key, value) def []=(key, value)
self.send("#{key}=", value) self.send("#{key}=", value)
end end
end).new(email) end).new(email)
end end
before do before do

View file

@ -14,18 +14,17 @@ describe TagsSubstitutionConcern, type: :model do
let(:template_concern) do let(:template_concern) do
(Class.new do (Class.new do
include TagsSubstitutionConcern include TagsSubstitutionConcern
public :replace_tags
def initialize(p, s) def initialize(p, s)
@procedure = p @procedure = p
self.class.const_set(:DOSSIER_STATE, s) self.class.const_set(:DOSSIER_STATE, s)
end end
def procedure def procedure
@procedure @procedure
end end
end).new(procedure, state) end).new(procedure, state)
end end
describe 'replace_tags' do describe 'replace_tags' do
@ -35,7 +34,7 @@ describe TagsSubstitutionConcern, type: :model do
before { Timecop.freeze(Time.now) } before { Timecop.freeze(Time.now) }
subject { template_concern.replace_tags(template, dossier) } subject { template_concern.send(:replace_tags, template, dossier) }
after { Timecop.return } after { Timecop.return }
@ -253,7 +252,7 @@ describe TagsSubstitutionConcern, type: :model do
let(:template) { '--motivation-- --date de décision--' } let(:template) { '--motivation-- --date de décision--' }
let(:state) { Dossier.states.fetch(:en_instruction) } let(:state) { Dossier.states.fetch(:en_instruction) }
subject { template_concern.replace_tags(template, dossier) } subject { template_concern.send(:replace_tags, template, dossier) }
it "does not treat motivation or date de décision as tags" do it "does not treat motivation or date de décision as tags" do
is_expected.to eq('--motivation-- --date de décision--') is_expected.to eq('--motivation-- --date de décision--')

View file

@ -114,4 +114,4 @@
"type": "Feature" "type": "Feature"
} }
] ]
} }

View file

@ -6,4 +6,4 @@
"query": "Paris", "query": "Paris",
"type": "FeatureCollection", "type": "FeatureCollection",
"features": [] "features": []
} }

View file

@ -180,4 +180,4 @@
} }
}, },
"gateway_error": false "gateway_error": false
} }

View file

@ -46,4 +46,4 @@
} }
}, },
"gateway_error": false "gateway_error": false
} }

View file

@ -29,4 +29,4 @@
] ]
} }
} }
} }

View file

@ -26,4 +26,4 @@
] ]
] ]
} }
} }

View file

@ -1214,4 +1214,4 @@
} }
} }
] ]
} }

View file

@ -27,4 +27,4 @@
} }
} }
] ]
} }

View file

@ -27,4 +27,4 @@
"mise_a_jour": 1392295833 "mise_a_jour": 1392295833
}, },
"date_extraction_donnees": 1427210585 "date_extraction_donnees": 1427210585
} }

707
yarn.lock

File diff suppressed because it is too large Load diff