Verified Commit d097e213 authored by Kaspar Vollenweider's avatar Kaspar Vollenweider
Browse files

add eslint and stylelint to linting pipeline

parent 77f570ba
app/assets/javascripts/js.cookie.js
app/assets/javascripts/bootstrap-treeview.js
{
"env": {
"browser": true,
"commonjs": false,
"es6": true,
"node": false,
"jquery": true
},
"parserOptions": {
"ecmaFeatures": {
"jsx": false
},
"sourceType": "script"
},
"rules": {
"prettier/prettier": [
"error",
{
"singleQuote": true,
"parser": "flow"
}
],
"no-const-assign": "warn",
"no-this-before-super": "warn",
"no-undef": "warn",
"no-unreachable": "warn",
"no-unused-vars": "warn",
"constructor-super": "warn",
"valid-typeof": "warn"
},
"plugins": [
"prettier"
],
"extends": [
"defaults",
"prettier"
]
}
---
plugins:
- prettier
extends:
- prettier
- standard
env:
browser: true
commonjs: false
es6: true
node: false
jquery: true
parserOptions:
sourceType: script
ecmaVersion: 2018
globals:
Routes: readonly
rules:
prettier/prettier:
- error
- singleQuote: true
parser: flow
no-const-assign: error
no-this-before-super: 'off'
no-undef: 'off'
no-unreachable: warn
no-unused-vars:
- error
- vars: local
args: after-used
ignoreRestSiblings: true
constructor-super: warn
valid-typeof: 'off'
camelcase: 'off'
comma-dangle:
- error
- arrays: always-multiline
objects: always-multiline
imports: always-multiline
exports: never
functions: never
space-before-function-paren: 'off'
......@@ -51,7 +51,9 @@ lint:
- .pull-push-cash
- .test-extend
script:
- yarn lint:js
- bundle exec rubocop
- yarn lint:css
test:
extends:
......
scss_files: "**/*.scss"
plugin_directories: ['.scss-linters']
plugin_gems: []
severity: warning
linters:
BangFormat:
enabled: true
space_before_bang: true
space_after_bang: false
BemDepth:
enabled: false
max_elements: 1
BorderZero:
enabled: true
convention: zero
ChainedClasses:
enabled: false
ColorKeyword:
enabled: true
ColorVariable:
enabled: true
Comment:
enabled: true
style: silent
DebugStatement:
enabled: true
DeclarationOrder:
enabled: true
DisableLinterReason:
enabled: false
DuplicateProperty:
enabled: true
ElsePlacement:
enabled: true
style: same_line
EmptyLineBetweenBlocks:
enabled: true
ignore_single_line_blocks: true
EmptyRule:
enabled: true
ExtendDirective:
enabled: false
FinalNewline:
enabled: true
present: true
HexLength:
enabled: true
style: short
HexNotation:
enabled: true
style: lowercase
HexValidation:
enabled: true
IdSelector:
enabled: true
ImportantRule:
enabled: true
ImportPath:
enabled: true
leading_underscore: false
filename_extension: false
Indentation:
enabled: true
allow_non_nested_indentation: false
character: space
width: 2
LeadingZero:
enabled: true
style: exclude_zero
MergeableSelector:
enabled: true
force_nesting: true
NameFormat:
enabled: true
allow_leading_underscore: true
convention: hyphenated_lowercase
NestingDepth:
enabled: true
max_depth: 3
ignore_parent_selectors: false
PlaceholderInExtend:
enabled: true
PrivateNamingConvention:
enabled: false
prefix: _
PropertyCount:
enabled: false
include_nested: false
max_properties: 10
PropertySortOrder:
enabled: true
ignore_unspecified: false
min_properties: 2
separate_groups: false
PropertySpelling:
enabled: true
extra_properties: []
disabled_properties: []
PropertyUnits:
enabled: true
global: [
'ch', 'em', 'ex', 'rem',
'cm', 'in', 'mm', 'pc', 'pt', 'px', 'q',
'vh', 'vw', 'vmin', 'vmax',
'deg', 'grad', 'rad', 'turn',
'ms', 's',
'Hz', 'kHz',
'dpi', 'dpcm', 'dppx',
'%']
properties: {}
PseudoElement:
enabled: true
QualifyingElement:
enabled: true
allow_element_with_attribute: false
allow_element_with_class: false
allow_element_with_id: false
SelectorDepth:
enabled: true
max_depth: 3
SelectorFormat:
enabled: true
convention: hyphenated_lowercase
Shorthand:
enabled: true
allowed_shorthands: [1, 2, 3, 4]
SingleLinePerProperty:
enabled: true
allow_single_line_rule_sets: true
SingleLinePerSelector:
enabled: true
SpaceAfterComma:
enabled: true
style: one_space
SpaceAfterComment:
enabled: false
style: one_space
allow_empty_comments: true
SpaceAfterPropertyColon:
enabled: true
style: one_space
SpaceAfterPropertyName:
enabled: true
SpaceAfterVariableColon:
enabled: false
style: one_space
SpaceAfterVariableName:
enabled: true
SpaceAroundOperator:
enabled: true
style: one_space
SpaceBeforeBrace:
enabled: true
style: space
allow_single_line_padding: false
SpaceBetweenParens:
enabled: true
spaces: 0
StringQuotes:
enabled: true
style: single_quotes
TrailingSemicolon:
enabled: true
TrailingWhitespace:
enabled: true
TrailingZero:
enabled: false
TransitionAll:
enabled: false
UnnecessaryMantissa:
enabled: true
UnnecessaryParentReference:
enabled: true
UrlFormat:
enabled: true
UrlQuotes:
enabled: true
VariableForProperty:
enabled: false
properties: []
VendorPrefix:
enabled: true
identifier_list: base
additional_identifiers: []
excluded_identifiers: []
ZeroUnit:
enabled: true
Compass::*:
enabled: false
---
plugins:
- stylelint-prettier
extends:
- stylelint-config-suitcss
- stylelint-prettier/recommended
rules:
prettier/prettier:
- true
- singleQuote: true
tabWidth: 2
at-rule-empty-line-before:
- always
- except:
- blockless-after-same-name-blockless
- blockless-after-blockless
- after-same-name
- first-nested
ignoreAtRules:
- import
at-rule-no-vendor-prefix: true
block-closing-brace-newline-after: always
block-closing-brace-newline-before: always-multi-line
block-closing-brace-space-before: always-single-line
block-no-empty: true
block-opening-brace-newline-after: always-multi-line
block-opening-brace-space-after: always-single-line
block-opening-brace-space-before: always
color-hex-case: lower
color-hex-length: short
color-no-invalid-hex: true
comment-empty-line-before: always
comment-whitespace-inside: always
declaration-bang-space-after: never
declaration-bang-space-before: always
declaration-block-no-shorthand-property-overrides: true
declaration-block-semicolon-newline-after: always-multi-line
declaration-block-semicolon-space-after: always-single-line
declaration-block-semicolon-space-before: never
declaration-block-single-line-max-declarations: 1
declaration-block-trailing-semicolon: always
declaration-colon-newline-after: always-multi-line
declaration-colon-space-after: always-single-line
declaration-colon-space-before: never
function-calc-no-unspaced-operator: true
function-comma-newline-after: always-multi-line
function-comma-space-after: always-single-line
function-comma-space-before: never
function-linear-gradient-no-nonstandard-direction: true
function-parentheses-newline-inside: always-multi-line
function-parentheses-space-inside: never-single-line
function-whitespace-after: always
function-url-quotes: always
indentation: 2
max-empty-lines: 1
max-line-length:
- 80
- ignore: non-comments
media-feature-colon-space-after: always
media-feature-colon-space-before: never
media-feature-name-no-vendor-prefix: true
media-feature-parentheses-space-inside: never
media-feature-range-operator-space-after: always
media-feature-range-operator-space-before: always
media-query-list-comma-newline-after: always-multi-line
media-query-list-comma-space-after: always-single-line
media-query-list-comma-space-before: never
no-eol-whitespace: true
no-missing-end-of-source-newline: true
number-leading-zero: always
number-no-trailing-zeros: true
length-zero-no-unit: true
order/properties-alphabetical-order: true
property-no-vendor-prefix: true
rule-empty-line-before:
- always
- except:
- first-nested
- after-single-line-comment
selector-combinator-space-after: always
selector-combinator-space-before: always
selector-list-comma-newline-after: always
selector-list-comma-space-before: never
selector-no-vendor-prefix: true
selector-pseudo-element-colon-notation: double
suitcss/custom-property-no-outside-root: true
suitcss/root-no-standard-properties: true
suitcss/selector-root-no-composition: true
string-quotes: single
value-list-comma-newline-after: always-multi-line
value-list-comma-space-after: always-single-line
value-list-comma-space-before: never
value-no-vendor-prefix: true
......@@ -67,7 +67,6 @@ group :development do
gem 'rubocop-rails', require: false
gem 'ruby-debug-ide', require: false
gem 'ruby-lint', require: false
gem 'scss_lint', require: false
end
group :development, :test do
......
......@@ -371,11 +371,6 @@ GEM
ruby_parser (3.14.2)
sexp_processor (~> 4.9)
rubyzip (2.3.0)
sass (3.7.4)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
sassc (2.3.0)
ffi (~> 1.9)
sassc-rails (2.1.2)
......@@ -384,8 +379,6 @@ GEM
sprockets (> 3.0)
sprockets-rails
tilt
scss_lint (0.59.0)
sass (~> 3.5, >= 3.5.5)
selectize-rails (0.12.6)
selenium-webdriver (3.142.7)
childprocess (>= 0.5, < 4.0)
......@@ -524,7 +517,6 @@ DEPENDENCIES
ruby-lint
rubyzip (>= 1.2.2)
sassc-rails
scss_lint
selectize-rails
selenium-webdriver
simple_form
......
$(() => {
jQuery.extend(window, Routes)
truncateModal();
conditionalField();
tableRowSelectable();
volunteerForm();
groupOfferForm();
emailTemplate();
inplaceFields();
clientForm()
});
$(() => {
$('.api-button').click(({target}) => {
$('.api-button').click(({ target }) => {
const { method, url, template } = $(target).data()
const tableCell = $(target).closest('td')
$.ajax({ method, url, dataType: 'json' })
.done(data => {
if (data.errors) {
$(tableCell).append(`<p class="text-danger">Es gab einen Fehler: ${data.errors.join('; ')}</p>`)
} else {
const compiled = _.template(template, { 'variable': 'data', 'imports': { 'data': data } })
$(target).remove()
$(tableCell).append(compiled(data))
}
})
$.ajax({ method, url, dataType: 'json' }).done((data) => {
if (data.errors) {
$(tableCell).append(
`<p class="text-danger">Es gab einen Fehler: ${data.errors.join(
'; '
)}</p>`
)
} else {
const compiled = _.template(template, {
variable: 'data',
imports: { data: data },
})
$(target).remove()
$(tableCell).append(compiled(data))
}
})
})
})
......@@ -25,3 +25,15 @@
//
//= require_tree .
//= require global
$(() => {
jQuery.extend(window, Routes)
truncateModal()
conditionalField()
tableRowSelectable()
volunteerForm()
groupOfferForm()
emailTemplate()
inplaceFields()
clientForm()
})
......@@ -5,9 +5,8 @@
//= require_self
//= require_tree ./channels
(function() {
this.App || (this.App = {});
;(function () {
this.App || (this.App = {})
App.cable = ActionCable.createConsumer();
}).call(this);
App.cable = ActionCable.createConsumer()
}.call(this))
function conditionalField() {
const getFieldsLabel = ({id}) => ($(`label[for="${id}"]`));
const getFieldsLabel = ({ id }) => $(`label[for="${id}"]`)
const showFieldWithLabel = (field) => {
$(field).show();
getFieldsLabel(field).show();
$(field).show()
getFieldsLabel(field).show()
}
const hideFieldWithLabel = (field) => {
$(field).hide();
getFieldsLabel(field).hide();
$(field).hide()
getFieldsLabel(field).hide()
}
const getFormGroupInputs = ({subject, model}) => (
$(`.form-group.${model}_${subject} input[type="checkbox"],.form-group.${model}_${subject} input[type="radio"]`)
);
const getFormGroupInputs = ({ subject, model }) =>
$(
`.form-group.${model}_${subject} input[type="checkbox"],.form-group.${model}_${subject} input[type="radio"]`
)
const getInputCollection = ({model, subject}) => (
subject.map((formGroup) => (
getFormGroupInputs({model, subject: formGroup})[0]
))
);
const getInputCollection = ({ model, subject }) =>
subject.map(
(formGroup) => getFormGroupInputs({ model, subject: formGroup })[0]
)
const reduceInputCollectionChecked = (inputs) => (
inputs.reduce((first, second) => (
( ((typeof first === 'boolean') ? first : first.checked) || second.checked )
))
);
const reduceInputCollectionChecked = (inputs) =>
inputs.reduce(
(first, second) =>
(typeof first === 'boolean' ? first : first.checked) || second.checked
)
const handleInputGroupChange = ({inputs, field}) => {
const parentRowNode = $(field).parents('.row')[0];
$(parentRowNode).hide();
const handleInputGroupChange = ({ inputs, field }) => {
const parentRowNode = $(field).parents('.row')[0]
$(parentRowNode).hide()
inputs.forEach((input) => {
if(input.checked) {
showFieldWithLabel(field);
$(parentRowNode).show();
if (input.checked) {
showFieldWithLabel(field)
$(parentRowNode).show()