Skip to content

Commit 2c3c649

Browse files
committed
fix: JS CI
1 parent 715197b commit 2c3c649

File tree

14 files changed

+252
-121
lines changed

14 files changed

+252
-121
lines changed

eslint.config.js

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,34 @@
11
export default [
2+
{
3+
ignores: [
4+
'**/dist/**',
5+
'**/node_modules/**',
6+
'**/*.min.js',
7+
'**/filer/static/filer/js/dist/**'
8+
]
9+
},
210
{
311
files: ['**/*.js'],
412
languageOptions: {
5-
ecmaVersion: 2015,
6-
sourceType: 'script',
13+
ecmaVersion: 2020,
14+
sourceType: 'module',
715
globals: {
816
// Browser globals
917
window: 'readonly',
1018
document: 'readonly',
1119
console: 'readonly',
1220
alert: 'readonly',
21+
Event: 'readonly',
22+
CustomEvent: 'readonly',
23+
MutationObserver: 'readonly',
24+
setTimeout: 'readonly',
25+
clearTimeout: 'readonly',
26+
setInterval: 'readonly',
27+
clearInterval: 'readonly',
28+
NodeList: 'readonly',
29+
HTMLCollection: 'readonly',
30+
URL: 'readonly',
31+
navigator: 'readonly',
1332
// Node.js globals
1433
require: 'readonly',
1534
module: 'readonly',
@@ -22,6 +41,11 @@ export default [
2241
Mediator: 'readonly',
2342
Class: 'readonly',
2443
opener: 'readonly',
44+
// Custom globals
45+
Cl: 'readonly',
46+
// jQuery (for legacy code/tests)
47+
$: 'readonly',
48+
jQuery: 'readonly',
2549
// Test globals
2650
jasmine: 'readonly',
2751
describe: 'readonly',
@@ -49,9 +73,26 @@ export default [
4973
'max-len': ['error', { 'code': 120, 'ignoreUrls': true, 'ignoreRegExpLiterals': true }],
5074

5175
// Best practices
52-
'strict': ['error', 'global'],
76+
'strict': 'off', // Not needed for ES6 modules
5377
'no-implied-eval': 'error',
5478
'no-new-func': 'error'
5579
}
80+
},
81+
{
82+
files: ['gulpfile.js', '**/karma.conf.js'],
83+
languageOptions: {
84+
ecmaVersion: 2020,
85+
sourceType: 'script',
86+
globals: {
87+
require: 'readonly',
88+
module: 'readonly',
89+
__dirname: 'readonly',
90+
process: 'readonly',
91+
console: 'readonly'
92+
}
93+
},
94+
rules: {
95+
'strict': ['error', 'global']
96+
}
5697
}
5798
];

filer/static/filer/css/admin_filer.cms.icons.css

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

filer/static/filer/css/admin_filer.css

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

filer/static/filer/css/admin_filer.fa.icons.css

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

filer/static/filer/js/addons/dropdown-menu.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
class Dropdown {
1818
constructor(element) {
1919
this.element = element;
20-
element.addEventListener('click', (e) => this.toggle(e));
20+
element.addEventListener('click', () => this.toggle());
2121
}
2222

23-
toggle(e) {
23+
toggle() {
2424
const element = this.element;
2525
const parent = getParent(element);
2626
const isActive = parent.classList.contains('open');

filer/static/filer/js/addons/dropzone.init.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ if (Dropzone) {
99
}
1010

1111
document.addEventListener('DOMContentLoaded', () => {
12-
const dropzoneTemplateSelector = '.js-filer-dropzone-template';
1312
const previewImageSelector = '.js-img-preview';
1413
const dropzoneSelector = '.js-filer-dropzone';
1514
const dropzones = document.querySelectorAll(dropzoneSelector);
@@ -41,7 +40,7 @@ document.addEventListener('DOMContentLoaded', () => {
4140
window.parent.CMS.API.Messages.open({
4241
message: message
4342
});
44-
} catch (e) {
43+
} catch {
4544
if (window.filerShowError) {
4645
window.filerShowError(message);
4746
} else {
@@ -99,7 +98,7 @@ document.addEventListener('DOMContentLoaded', () => {
9998
if (clearButton) {
10099
clearButton.addEventListener('click', () => {
101100
dropzone.classList.remove(objectAttachedClass);
102-
const changeEvent = new Event('change', { bubbles: true });
101+
// const changeEvent = new Event('change', { bubbles: true });
103102
// inputId?.dispatchEvent(changeEvent);
104103
});
105104
}

filer/static/filer/js/addons/focal-point.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ window.Cl = window.Cl || {};
104104
}
105105

106106
_makeDraggable() {
107-
if (!this.circle) return;
107+
if (!this.circle) {
108+
return;
109+
}
108110

109111
this.circle.classList.add(this.options.draggableClass);
110112
this.circle.addEventListener('mousedown', this._onMouseDown);
@@ -136,7 +138,9 @@ window.Cl = window.Cl || {};
136138
}
137139

138140
_onMouseMove(event) {
139-
if (!this.isDragging) return;
141+
if (!this.isDragging) {
142+
return;
143+
}
140144

141145
event.preventDefault();
142146

filer/static/filer/js/addons/upload-button.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ document.addEventListener('DOMContentLoaded', () => {
7676
autoProcessQueue: true
7777
});
7878

79-
dropzone.on('addedfile', (file) => {
79+
dropzone.on('addedfile', () => {
8080
Cl.mediator.remove('filer-upload-in-progress', removeButton);
8181
Cl.mediator.publish('filer-upload-in-progress');
8282
submitNum++;

gulpfile.js

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -105,28 +105,33 @@ gulp.task('icons', function () {
105105
normalize: true,
106106
formats: ['svg', 'ttf', 'eot', 'woff', 'woff2']
107107
}))
108-
.on('glyphs', function (glyphs, options) {
108+
.on('glyphs', function (glyphs) {
109109
log.info('Generated', glyphs.length, 'glyphs');
110110
})
111111
.pipe(gulp.dest(PROJECT_PATH.icons));
112112
});
113113

114114
// #############################################################################
115115
// LINTING
116-
gulp.task('eslint', function () {
117-
return gulp.src(PROJECT_PATTERNS.lint)
118-
.pipe(eslint())
119-
.pipe(eslint.format())
120-
.pipe(eslint.failAfterError());
121-
});
116+
gulp.task('lint', function () {
117+
var fix = process.argv.includes('--fix');
118+
var stream = gulp.src(PROJECT_PATTERNS.lint, { allowEmpty: true });
119+
120+
if (fix) {
121+
stream = stream
122+
.pipe(eslint({fix: true}))
123+
.pipe(eslint.format())
124+
.pipe(gulp.dest(function(file) {
125+
return file.base;
126+
}));
127+
} else {
128+
stream = stream
129+
.pipe(eslint())
130+
.pipe(eslint.format())
131+
.pipe(eslint.failAfterError());
132+
}
122133

123-
gulp.task('eslint:fix', function () {
124-
return gulp.src(PROJECT_PATTERNS.lint)
125-
.pipe(eslint({fix: true}))
126-
.pipe(eslint.format())
127-
.pipe(gulp.dest(function(file) {
128-
return file.base;
129-
}));
134+
return stream;
130135
});
131136

132137
// #############################################################################
@@ -144,14 +149,13 @@ gulp.task('tests:watch', function () {
144149
// #############################################################################
145150
// TASKS
146151
gulp.task('build', gulp.series('sass', 'bundle'));
147-
gulp.task('js', gulp.series('eslint' /* ,'tests:unit'*/));
152+
gulp.task('js', gulp.series('lint' /* ,'tests:unit'*/));
148153
gulp.task('js:watch', function () {
149154
gulp.watch(PROJECT_PATTERNS.lint, gulp.series('js'));
150155
});
151156
gulp.task('watch', gulp.parallel('sass:watch', 'js:watch'));
152-
gulp.task('lint', gulp.series('eslint'));
153157
gulp.task('lint:watch', function () {
154158
gulp.watch(PROJECT_PATTERNS.lint, gulp.series('lint'));
155159
});
156-
gulp.task('ci', gulp.series('sass', 'bundle', 'eslint', 'lint', 'tests:unit'));
160+
gulp.task('ci', gulp.series('sass', 'bundle', 'lint', 'tests:unit'));
157161
gulp.task('default', gulp.parallel('sass:watch', 'js:watch', 'lint:watch'));

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"gulp-sass": "^5.1.0",
2828
"gulp-sourcemaps": "^3.0.0",
2929
"jasmine-core": "^5.9.0",
30+
"jquery": "^3.7.1",
3031
"karma": "^6.4.4",
3132
"karma-chrome-launcher": "^3.2.0",
3233
"karma-fixture": "^0.2.6",

0 commit comments

Comments
 (0)