Skip to content

Commit

Permalink
Merge pull request #2279 from skaut/prefer-arrow
Browse files Browse the repository at this point in the history
Prefering arrow functions
  • Loading branch information
marekdedic authored Oct 26, 2023
2 parents 19c0d70 + dcba195 commit 773f1fd
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 65 deletions.
12 changes: 10 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"plugins": [
"compat",
"deprecation",
"prefer-arrow-functions",
"simple-import-sort",
"@typescript-eslint"
],
Expand All @@ -20,13 +21,20 @@
"plugin:@typescript-eslint/stylistic-type-checked"
],
"rules": {
"arrow-body-style": ["error", "as-needed"],
"camelcase": "error",
"no-warning-comments": "warn",
"strict": ["error", "never"],
"compat/compat": "warn",
"deprecation/deprecation": "warn",
"no-warning-comments": "warn",
"prefer-arrow-functions/prefer-arrow-functions": [
"error",
{
"allowNamedFunctions": true
}
],
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",
"strict": ["error", "never"],
"@typescript-eslint/array-type": ["error", {"default": "generic"}],
"@typescript-eslint/consistent-type-exports": "error",
"@typescript-eslint/consistent-type-imports": "error",
Expand Down
110 changes: 52 additions & 58 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ const replace = require('gulp-replace');
const shell = require('gulp-shell');
const webpack = require('webpack-stream');

gulp.task('build:css:admin', function () {
return gulp
gulp.task('build:css:admin', () =>
gulp
.src(['src/css/admin/*.css'])
.pipe(cleanCSS())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('dist/admin/css/'));
});
.pipe(gulp.dest('dist/admin/css/'))
);

gulp.task('build:css:frontend', function () {
return gulp
gulp.task('build:css:frontend', () =>
gulp
.src(['src/css/frontend/*.css'])
.pipe(cleanCSS())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('dist/frontend/css/'));
});
.pipe(gulp.dest('dist/frontend/css/'))
);

gulp.task('build:css', gulp.parallel('build:css:admin', 'build:css:frontend'));

Expand All @@ -41,8 +41,8 @@ gulp.task(
'composer dump-autoload --no-dev' +
(process.env.NODE_ENV === 'production' ? ' -o' : '')
),
function () {
return merge(
() =>
merge(
gulp.src([
'vendor/composer/autoload_classmap.php',
'vendor/composer/autoload_files.php',
Expand All @@ -63,8 +63,7 @@ gulp.task(
"'Sgdg\\\\Vendor\\\\$1\\\\' => \n"
)
)
).pipe(gulp.dest('dist/vendor/composer/'));
},
).pipe(gulp.dest('dist/vendor/composer/')),
shell.task('composer dump-autoload')
)
);
Expand All @@ -74,17 +73,17 @@ gulp.task(
gulp.series('build:deps:composer:scoper', 'build:deps:composer:autoloader')
);

gulp.task('build:deps:npm:imagelightbox', function () {
return gulp
gulp.task('build:deps:npm:imagelightbox', () =>
gulp
.src('node_modules/imagelightbox/dist/imagelightbox.min.*')
.pipe(gulp.dest('dist/bundled/'));
});
.pipe(gulp.dest('dist/bundled/'))
);

gulp.task('build:deps:npm:imagesloaded', function () {
return gulp
gulp.task('build:deps:npm:imagesloaded', () =>
gulp
.src('node_modules/imagesloaded/imagesloaded.pkgd.min.js')
.pipe(gulp.dest('dist/bundled/'));
});
.pipe(gulp.dest('dist/bundled/'))
);

gulp.task(
'build:deps:npm:justified-layout',
Expand All @@ -95,13 +94,12 @@ gulp.task(
shell.task(['npm run build'], {
cwd: 'node_modules/justified-layout',
}),
function () {
return gulp
() =>
gulp
.src(
'node_modules/justified-layout/dist/justified-layout.min.*'
)
.pipe(gulp.dest('dist/bundled/'));
}
.pipe(gulp.dest('dist/bundled/'))
)
);

Expand All @@ -116,53 +114,49 @@ gulp.task(

gulp.task('build:deps', gulp.parallel('build:deps:composer', 'build:deps:npm'));

gulp.task('build:js:admin', function () {
return gulp
gulp.task('build:js:admin', () =>
gulp
.src(['src/ts/admin/root_selection.ts', 'src/ts/admin/tinymce.ts'])
.pipe(named((file) => file.stem + '.min'))
.pipe(webpack(require('./webpack.config.js')))
.pipe(inject.prepend('jQuery( function( $ ) {\n'))
.pipe(inject.append('} );\n'))
.pipe(gulp.dest('dist/admin/js/'));
});
.pipe(gulp.dest('dist/admin/js/'))
);

gulp.task('build:js:frontend', function () {
return gulp
gulp.task('build:js:frontend', () =>
gulp
.src(['src/ts/frontend/block.ts', 'src/ts/frontend/shortcode.ts'])
.pipe(named((file) => file.stem + '.min'))
.pipe(webpack(require('./webpack.config.js')))
.pipe(inject.prepend('jQuery( function( $ ) {\n'))
.pipe(inject.append('} );\n'))
.pipe(gulp.dest('dist/frontend/js/'));
});
.pipe(gulp.dest('dist/frontend/js/'))
);

gulp.task('build:js', gulp.parallel('build:js:admin', 'build:js:frontend'));

gulp.task('build:php:admin', function () {
return gulp.src(['src/php/admin/**/*.php']).pipe(gulp.dest('dist/admin/'));
});
gulp.task('build:php:admin', () =>
gulp.src(['src/php/admin/**/*.php']).pipe(gulp.dest('dist/admin/'))
);

gulp.task('build:php:base', function () {
return gulp.src(['src/php/*.php']).pipe(gulp.dest('dist/'));
});
gulp.task('build:php:base', () =>
gulp.src(['src/php/*.php']).pipe(gulp.dest('dist/'))
);

gulp.task('build:php:exceptions', function () {
return gulp
gulp.task('build:php:exceptions', () =>
gulp
.src(['src/php/exceptions/**/*.php'])
.pipe(gulp.dest('dist/exceptions/'));
});
.pipe(gulp.dest('dist/exceptions/'))
);

gulp.task('build:php:frontend', function () {
return gulp
.src(['src/php/frontend/**/*.php'])
.pipe(gulp.dest('dist/frontend/'));
});
gulp.task('build:php:frontend', () =>
gulp.src(['src/php/frontend/**/*.php']).pipe(gulp.dest('dist/frontend/'))
);

gulp.task('build:php:helpers', function () {
return gulp
.src(['src/php/helpers/**/*.php'])
.pipe(gulp.dest('dist/helpers/'));
});
gulp.task('build:php:helpers', () =>
gulp.src(['src/php/helpers/**/*.php']).pipe(gulp.dest('dist/helpers/'))
);

gulp.task(
'build:php',
Expand All @@ -175,13 +169,13 @@ gulp.task(
)
);

gulp.task('build:png', function () {
return gulp.src(['src/png/icon.png']).pipe(gulp.dest('dist/admin/'));
});
gulp.task('build:png', () =>
gulp.src(['src/png/icon.png']).pipe(gulp.dest('dist/admin/'))
);

gulp.task('build:txt', function () {
return gulp.src(['src/txt/*.txt']).pipe(gulp.dest('dist/'));
});
gulp.task('build:txt', () =>
gulp.src(['src/txt/*.txt']).pipe(gulp.dest('dist/'))
);

gulp.task(
'build',
Expand Down
10 changes: 10 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"eslint": "^8.52.0",
"eslint-plugin-compat": "^4.2.0",
"eslint-plugin-deprecation": "^2.0.0",
"eslint-plugin-prefer-arrow-functions": "^3.2.4",
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-simple-import-sort": "^10.0.0",
"gulp": "^4.0.2",
Expand Down
2 changes: 1 addition & 1 deletion src/ts/admin/root_selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function listGdriveDir(): void {
action: 'list_gdrive_dir',
path,
},
function (data: ListGdriveDirResponse) {
(data: ListGdriveDirResponse) => {
if (isError(data)) {
$('.sgdg_root_selection').replaceWith(
printError(data, sgdgRootpathLocalize)
Expand Down
4 changes: 2 additions & 2 deletions src/ts/admin/tinymce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function tinymceHtml(): void {
'</a>' +
'</div>';
$('#sgdg-tinymce-modal').html(html);
$('#sgdg-tinymce-insert').on('click', function () {
$('#sgdg-tinymce-insert').on('click', () => {
tinymceSubmit();
});
}
Expand Down Expand Up @@ -112,7 +112,7 @@ function ajaxQuery(): void {
action: 'list_gallery_dir',
path,
},
function (data: ListGalleryDirResponse) {
(data: ListGalleryDirResponse) => {
if (isError(data)) {
$('#TB_ajaxContent').html(
printError(data, sgdgTinymceLocalize)
Expand Down
4 changes: 2 additions & 2 deletions src/ts/frontend/shortcode/ShortcodeRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const ShortcodeRegistry: ShortcodeRegistry = {
},

reflowAll(): void {
$.each(this.shortcodes, function (_, shortcode) {
$.each(this.shortcodes, (_, shortcode) => {
shortcode.reflow();
});
},
Expand All @@ -42,7 +42,7 @@ export const ShortcodeRegistry: ShortcodeRegistry = {
},

onLightboxQuit(): void {
$.each(this.shortcodes, function (_, shortcode) {
$.each(this.shortcodes, (_, shortcode) => {
shortcode.onLightboxQuit();
});
},
Expand Down

0 comments on commit 773f1fd

Please sign in to comment.