Add stylelint and eslint to github actions
This commit is contained in:
parent
31b2e539f4
commit
696745b3d8
5
.eslintignore
Normal file
5
.eslintignore
Normal file
@ -0,0 +1,5 @@
|
||||
# eslint ignore file
|
||||
assets/javascripts/*.js
|
||||
!assets/javascripts/additionals*.js
|
||||
!assets/javascripts/mermaid_load.js
|
||||
!assets/javascripts/select2_helpers.js
|
13
.github/workflows/linters.yml
vendored
13
.github/workflows/linters.yml
vendored
@ -39,3 +39,16 @@ jobs:
|
||||
- name: Run Brakeman
|
||||
run: |
|
||||
bundle exec brakeman -5
|
||||
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: '14'
|
||||
|
||||
- run: yarn install
|
||||
|
||||
- name: Run Stylelint
|
||||
run: node_modules/.bin/stylelint assets/stylesheets/
|
||||
|
||||
- name: Run ESLint
|
||||
run: node_modules/.bin/eslint assets/javascripts/
|
||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -12,3 +12,5 @@ docs/_build
|
||||
docs/_static
|
||||
docs/_templates
|
||||
.enable_dev
|
||||
/node_modules
|
||||
/yarn.lock
|
||||
|
3
.stylelintignore
Normal file
3
.stylelintignore
Normal file
@ -0,0 +1,3 @@
|
||||
# stylelint ignore file
|
||||
assets/stylesheets/*.min.css
|
||||
assets/stylesheets/select2.css
|
@ -1,4 +0,0 @@
|
||||
# eslint ignore file
|
||||
*.js
|
||||
!additionals*.js
|
||||
!select2_helpers.js
|
@ -1,13 +1,16 @@
|
||||
/* global globalThis, mermaid */
|
||||
$(function() {
|
||||
var mermaidTheme;
|
||||
var mermaidThemeVariables;
|
||||
if (globalThis !== undefined && globalThis.mermaidTheme !== undefined) {
|
||||
var mermaidTheme = globalThis.mermaidTheme;
|
||||
mermaidTheme = globalThis.mermaidTheme;
|
||||
} else {
|
||||
var mermaidTheme = 'default';
|
||||
mermaidTheme = 'default';
|
||||
}
|
||||
if (globalThis !== undefined && globalThis.mermaidThemeVariables !== undefined) {
|
||||
var mermaidThemeVariables = globalThis.mermaidThemeVariables;
|
||||
mermaidThemeVariables = globalThis.mermaidThemeVariables;
|
||||
} else {
|
||||
var mermaidThemeVariables = { 'fontSize': '12px' };
|
||||
mermaidThemeVariables = { 'fontSize': '12px' };
|
||||
}
|
||||
|
||||
mermaid.initialize({
|
||||
|
@ -10,7 +10,7 @@ function filterAdditionalsFormatState (opt) {
|
||||
return $opt;
|
||||
}
|
||||
|
||||
/* global availableFilters additionals_field_formats additionals_filter_urls:true* */
|
||||
/* global availableFilters, additionals_filter_urls, additionals_field_formats */
|
||||
function additionals_transform_to_select2(field){
|
||||
var field_format = availableFilters[field]['field_format'];
|
||||
var initialized_select2 = $('#tr_' + field + ' .values .select2');
|
||||
@ -25,7 +25,7 @@ function additionals_transform_to_select2(field){
|
||||
data: function(params) {
|
||||
return { q: params.term };
|
||||
},
|
||||
processResults: function(data, params) {
|
||||
processResults: function(data) {
|
||||
return { results: data };
|
||||
},
|
||||
cache: true
|
||||
@ -34,7 +34,7 @@ function additionals_transform_to_select2(field){
|
||||
minimumInputLength: 1,
|
||||
width: '90%',
|
||||
templateResult: filterAdditionalsFormatState
|
||||
}).on('select2:open', function (e) {
|
||||
}).on('select2:open', function () {
|
||||
$(this).parent('span').find('.select2-search__field').val(' ').trigger($.Event('input', { which: 13 })).val('');
|
||||
});
|
||||
}
|
||||
@ -44,6 +44,9 @@ var SELECT2_DELAY = 250;
|
||||
|
||||
var select2Filters = {};
|
||||
|
||||
/* exported setSelect2Filter */
|
||||
/* global operatorByType */
|
||||
/* global buildFilterRow:writable */
|
||||
function setSelect2Filter(type, options) {
|
||||
if (typeof operatorByType === 'undefined') { return; }
|
||||
|
||||
@ -127,35 +130,38 @@ function findInRowBy(field, selector) {
|
||||
return $('#tr_' + sanitizeToId(field) + ' ' + selector);
|
||||
}
|
||||
|
||||
/* exported formatStateWithAvatar */
|
||||
function formatStateWithAvatar(opt) {
|
||||
return $('<span>' + opt.avatar + ' ' + opt.text + '</span>');
|
||||
}
|
||||
|
||||
/* exported formatStateWithMultiaddress */
|
||||
function formatStateWithMultiaddress(opt) {
|
||||
return $('<span class="select2-contact">' + opt.avatar + '<p class="select2-contact__name">' + opt.text + '</p><p class="select2-contact__email">' + opt.email + '</p></span>');
|
||||
}
|
||||
|
||||
function transformToSelect2(field, options) {
|
||||
if (rowHasSelect2(field)) { return }
|
||||
if (rowHasSelect2(field)) { return; }
|
||||
|
||||
findInRowBy(field, '.toggle-multiselect').hide();
|
||||
var selectField = findSelectTagInRowBy(field);
|
||||
selectField.select2(buildSelect2Options(options));
|
||||
|
||||
var select2Instance = selectField.data('select2');
|
||||
select2Instance.on('results:message', function(params){
|
||||
select2Instance.on('results:message', function(){
|
||||
this.dropdown._resizeDropdown();
|
||||
this.dropdown._positionDropdown();
|
||||
});
|
||||
}
|
||||
|
||||
/* exported select2Tag */
|
||||
function select2Tag(id, options) {
|
||||
$(function () {
|
||||
var selectField = $('select#' + id);
|
||||
selectField.select2(buildSelect2Options(options));
|
||||
|
||||
var select2Instance = selectField.data('select2');
|
||||
select2Instance.on('results:message', function(params){
|
||||
select2Instance.on('results:message', function(){
|
||||
this.dropdown._resizeDropdown();
|
||||
this.dropdown._positionDropdown();
|
||||
});
|
||||
@ -163,7 +169,7 @@ function select2Tag(id, options) {
|
||||
}
|
||||
|
||||
function buildSelect2Options(options) {
|
||||
result = {
|
||||
var result = {
|
||||
placeholder: options['placeholder'] || '',
|
||||
allowClear: !!options['allow_clear'],
|
||||
minimumInputLength: options['min_input_length'] || 0,
|
||||
@ -186,7 +192,7 @@ function addDataSourceOptions(target, options) {
|
||||
data: function (params) {
|
||||
return { q: params.term };
|
||||
},
|
||||
processResults: function (data, params) {
|
||||
processResults: function (data) {
|
||||
return { results: data };
|
||||
},
|
||||
cache: true
|
@ -1,4 +0,0 @@
|
||||
# stylelint ignore file
|
||||
select2.css
|
||||
*.map
|
||||
*.min.css
|
@ -227,7 +227,7 @@ module Additionals
|
||||
def additionals_load_select2
|
||||
additionals_include_css('select2') +
|
||||
additionals_include_js('select2.min') +
|
||||
additionals_include_js('select2_helper')
|
||||
additionals_include_js('select2_helpers')
|
||||
end
|
||||
|
||||
def additionals_load_clipboardjs
|
||||
|
7
package.json
Normal file
7
package.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"eslint": "^7.0.0",
|
||||
"stylelint": "^14.0.0"
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user