Skip to content

Commit

Permalink
Revise Ruff and Prettier formatting options; fix RQ job (#772)
Browse files Browse the repository at this point in the history
  • Loading branch information
jace authored Jun 7, 2024
1 parent d1a01db commit 720cd32
Show file tree
Hide file tree
Showing 14 changed files with 94 additions and 96 deletions.
26 changes: 26 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Hasgeek code style config
root = True

# For all files
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
max_line_length = 88
tab_width = 8
trim_trailing_whitespace = true

# Python code
[*.py]
indent_size = 4

# Makefile
[Makefile]
indent_style = tab
indent_size = tab

# Markdown
[*.{md,md.jinja2}]
trim_trailing_whitespace = false
17 changes: 3 additions & 14 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,7 @@ repos:
hooks:
- id: ruff
args: ['--fix', '--exit-non-zero-on-fix']
# Extra args, only after removing flake8 and yesqa: '--extend-select', 'RUF100'
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.2
hooks:
- id: pyupgrade
args:
['--keep-runtime-typing', '--py3-plus', '--py36-plus', '--py37-plus']
- id: ruff-format
- repo: https://github.com/asottile/yesqa
rev: v1.5.0
hooks:
Expand All @@ -43,10 +37,6 @@ repos:
- id: isort
additional_dependencies:
- toml
- repo: https://github.com/psf/black
rev: 24.4.2
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
rev: 7.0.0
hooks:
Expand All @@ -66,11 +56,10 @@ repos:
args: ['-c', 'pyproject.toml']
additional_dependencies:
- bandit[toml]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
- repo: https://github.com/pycontribs/mirrors-prettier
rev: v3.3.1
hooks:
- id: prettier
args: ['--single-quote', '--trailing-comma', 'es5']
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/*.md
4 changes: 0 additions & 4 deletions .prettierrc.js

This file was deleted.

3 changes: 3 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"singleQuote": true
}
67 changes: 24 additions & 43 deletions hasjob/assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,7 @@ window.Hasjob.JobPost = {
var outerTemplate = document.createElement('li');
var innerTemplate = document.createElement('a');
var node, outer, inner;
outerTemplate.setAttribute(
'class',
'col-xs-12 col-md-3 col-sm-4 animated shake'
);
outerTemplate.setAttribute('class', 'col-xs-12 col-md-3 col-sm-4 animated shake');
innerTemplate.setAttribute('class', 'stickie');
innerTemplate.setAttribute('rel', 'bookmark');
// replaces the group with individual stickies when clicked
Expand Down Expand Up @@ -119,9 +116,7 @@ window.Hasjob.StickieList = {
$('ul#stickie-area').append(data.trim());
stickielist.loadmoreRactive.set('loading', false);
stickielist.loadmoreRactive.set('error', false);
window.dispatchEvent(
Hasjob.Util.createCustomEvent('onStickiesPagination')
);
window.dispatchEvent(Hasjob.Util.createCustomEvent('onStickiesPagination'));
},
error: function () {
stickielist.loadmoreRactive.set('error', true);
Expand Down Expand Up @@ -170,8 +165,7 @@ window.Hasjob.StickieList = {
var filterParams = window.Hasjob.Filters.toParam();
var searchUrl = window.Hasjob.Config.baseURL;
if (filterParams.length) {
searchUrl =
window.Hasjob.Config.baseURL + '?' + window.Hasjob.Filters.toParam();
searchUrl = window.Hasjob.Config.baseURL + '?' + window.Hasjob.Filters.toParam();
}
$.ajax(searchUrl, {
method: 'POST',
Expand All @@ -182,9 +176,7 @@ window.Hasjob.StickieList = {
$('#main-content').html(data);
window.Hasjob.Filters.refresh();
NProgress.done();
window.dispatchEvent(
Hasjob.Util.createCustomEvent('onStickiesRefresh')
);
window.dispatchEvent(Hasjob.Util.createCustomEvent('onStickiesRefresh'));
},
});
history.replaceState({ reloadOnPop: true }, '', window.location.href);
Expand Down Expand Up @@ -237,7 +229,7 @@ window.Hasjob.StickieList = {
value,
1,
1,
1
1,
).data;
var colourHex;
if (rgba[0] > 255 || rgba[1] > 255 || rgba[2] > 255) {
Expand Down Expand Up @@ -265,27 +257,27 @@ window.Hasjob.StickieList = {
Hasjob.StickieList.setGradientColour(
$(this).data('funnel-name'),
$(this).data('funnel-value'),
$(this).attr('id')
$(this).attr('id'),
);
}
});
},
createGradientColour: function () {
Hasjob.StickieList.createGradientColourScale(
'impressions',
Hasjob.Config.MaxCounts.max_impressions
Hasjob.Config.MaxCounts.max_impressions,
);
Hasjob.StickieList.createGradientColourScale(
'views',
Hasjob.Config.MaxCounts.max_views
Hasjob.Config.MaxCounts.max_views,
);
Hasjob.StickieList.createGradientColourScale(
'opens',
Hasjob.Config.MaxCounts.max_opens
Hasjob.Config.MaxCounts.max_opens,
);
Hasjob.StickieList.createGradientColourScale(
'applied',
Hasjob.Config.MaxCounts.max_applied
Hasjob.Config.MaxCounts.max_applied,
);
},
initFunnelViz: function () {
Expand All @@ -299,7 +291,7 @@ window.Hasjob.StickieList = {
Hasjob.StickieList.renderGradientColour();
}
},
false
false,
);

window.addEventListener(
Expand All @@ -309,7 +301,7 @@ window.Hasjob.StickieList = {
Hasjob.StickieList.renderGradientColour();
}
},
false
false,
);

window.addEventListener(
Expand All @@ -319,15 +311,15 @@ window.Hasjob.StickieList = {
Hasjob.StickieList.renderGradientColour();
}
},
false
false,
);
},
};

window.Hasjob.Filters = {
toParam: function () {
var sortedFilterParams = this.formatFilterParams(
$('#js-job-filters').serializeArray()
$('#js-job-filters').serializeArray(),
);
if (sortedFilterParams.length) {
return $.param(sortedFilterParams);
Expand Down Expand Up @@ -452,10 +444,7 @@ window.Hasjob.Filters = {
if ($(this).val() !== lastKeyword) {
window.clearTimeout(keywordTimeout);
lastKeyword = $(this).val();
keywordTimeout = window.setTimeout(
window.Hasjob.StickieList.refresh,
1000
);
keywordTimeout = window.setTimeout(window.Hasjob.StickieList.refresh, 1000);
}
});

Expand Down Expand Up @@ -560,7 +549,7 @@ window.Hasjob.Filters = {
formParams[fpIndex].value = '';
} else {
formParams[fpIndex].value = Hasjob.PaySlider.toNumeric(
formParams[fpIndex].value
formParams[fpIndex].value,
);
if (formParams[fpIndex].value === '0') {
formParams[fpIndex].value = '';
Expand Down Expand Up @@ -616,10 +605,7 @@ window.Hasjob.Currency.indian_rupee_encoder = function (value) {
var otherNumbers = value.substring(0, value.length - 3);
if (otherNumbers !== '') lastThree = ',' + lastThree;
var res =
'₹' +
otherNumbers.replace(/\B(?=(\d{2})+(?!\d))/g, ',') +
lastThree +
afterPoint;
'₹' + otherNumbers.replace(/\B(?=(\d{2})+(?!\d))/g, ',') + lastThree + afterPoint;
return res;
};

Expand Down Expand Up @@ -747,7 +733,7 @@ window.Hasjob.PaySlider.prototype.resetSlider = function (currency) {
range: Hasjob.PaySlider.range(currency),
format: Hasjob.Currency.wNumbFormat(currency),
},
true
true,
);

this.slider.Link('lower').to($(this.minField));
Expand Down Expand Up @@ -808,16 +794,12 @@ $(function () {

// set initial value for the currency radio button
var presetCurrency =
(window.Hasjob.Config && window.Hasjob.Config.selectedFilters.currency) ||
'NA';
$.each(
$("input[type='radio'][name='currency']"),
function (index, currencyRadio) {
if ($(currencyRadio).val() === presetCurrency) {
$(currencyRadio).attr('checked', 'checked');
}
(window.Hasjob.Config && window.Hasjob.Config.selectedFilters.currency) || 'NA';
$.each($("input[type='radio'][name='currency']"), function (index, currencyRadio) {
if ($(currencyRadio).val() === presetCurrency) {
$(currencyRadio).attr('checked', 'checked');
}
);
});

// preset equity
if (window.Hasjob.Config && window.Hasjob.Config.selectedFilters.equity) {
Expand All @@ -844,8 +826,7 @@ $(function () {
};

var paySlider = new Hasjob.PaySlider({
start:
(window.Hasjob.Config && window.Hasjob.Config.selectedFilters.pay) || 0,
start: (window.Hasjob.Config && window.Hasjob.Config.selectedFilters.pay) || 0,
selector: '#pay-slider',
minField: '#job-filters-payval',
});
Expand Down
24 changes: 12 additions & 12 deletions hasjob/assets/service-worker-template.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
importScripts(
'https://unpkg.com/workbox-sw@2.1.2/build/importScripts/workbox-sw.prod.v2.1.2.js'
'https://unpkg.com/workbox-sw@2.1.2/build/importScripts/workbox-sw.prod.v2.1.2.js',
);

const workboxSW = new self.WorkboxSW({
Expand All @@ -15,7 +15,7 @@ workboxSW.router.registerRoute(
workboxSW.strategies.networkFirst({
cacheName: 'assets',
}),
'GET'
'GET',
);

//For development setup caching of assets
Expand All @@ -24,63 +24,63 @@ workboxSW.router.registerRoute(
workboxSW.strategies.networkFirst({
cacheName: 'baseframe-local',
}),
'GET'
'GET',
);

workboxSW.router.registerRoute(
/^https?\:\/\/ajax.googleapis.com\/*/,
workboxSW.strategies.networkFirst({
cacheName: 'cdn-libraries',
}),
'GET'
'GET',
);

workboxSW.router.registerRoute(
/^https?:\/\/cdnjs.cloudflare.com\/*/,
workboxSW.strategies.networkFirst({
cacheName: 'cdn-libraries',
}),
'GET'
'GET',
);

workboxSW.router.registerRoute(
/^https?:\/\/images\.hasgeek\.com\/embed\/file\/*/,
workboxSW.strategies.networkFirst({
cacheName: 'images',
}),
'GET'
'GET',
);

workboxSW.router.registerRoute(
/^https?:\/\/hasgeek.com\/*/,
workboxSW.strategies.networkFirst({
cacheName: 'images',
}),
'GET'
'GET',
);

workboxSW.router.registerRoute(
/^https?:\/\/hasjob.co\/*/,
workboxSW.strategies.networkFirst({
cacheName: 'images',
}),
'GET'
'GET',
);

workboxSW.router.registerRoute(
/^https?:\/\/fonts.googleapis.com\/*/,
workboxSW.strategies.networkFirst({
cacheName: 'fonts',
}),
'GET'
'GET',
);

workboxSW.router.registerRoute(
/^https?:\/\/fonts.gstatic.com\/*/,
workboxSW.strategies.networkFirst({
cacheName: 'fonts',
}),
'GET'
'GET',
);

/* The service worker handles all fetch requests. If fetching of job post page or
Expand Down Expand Up @@ -122,7 +122,7 @@ self.addEventListener('install', (event) => {
return caches.open('hasjob-offline').then(function (cache) {
return cache.put('offline', response);
});
}
)
},
),
);
});
5 changes: 2 additions & 3 deletions hasjob/assets/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ ManifestPlugin.prototype.apply = function (compiler) {
});
require('fs').writeFileSync(
path.join(__dirname, this.manifestPath),
JSON.stringify(parsed_stats)
JSON.stringify(parsed_stats),
);
});
};
Expand Down Expand Up @@ -98,8 +98,7 @@ module.exports = {
return (
module.resource &&
/\.js$/.test(module.resource) &&
module.resource.indexOf(path.join(__dirname, '/node_modules')) ===
0
module.resource.indexOf(path.join(__dirname, '/node_modules')) === 0
);
},
}),
Expand Down
Loading

0 comments on commit 720cd32

Please sign in to comment.