Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds base ESLint configuration to the wpcomsh plugin. #39275

Merged
merged 20 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions projects/plugins/wpcomsh/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Not loaded by default eslint, but we use tools/js-tools/load-eslint-ignore.js in .eslintrc to pull it in.

/tests/e2e
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventually we probably should lint this, but OK with me if we do that as a followup.

/custom-colors/js/jquery.spin.js
/custom-colors/js/spin.js
Comment on lines +4 to +5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we get around to setting up a webpack build for the scripts here in some future PR, we could also look at whether there's an npm package we could use instead of copy-pasting these in.

The spin.js looks like it's probably an old version of https://www.npmjs.com/package/spin.js.

1 change: 1 addition & 0 deletions projects/plugins/wpcomsh/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const loadIgnorePatterns = require( 'jetpack-js-tools/load-eslint-ignore.js' );
module.exports = {
root: true,
anomiex marked this conversation as resolved.
Show resolved Hide resolved
extends: [
require.resolve( 'jetpack-js-tools/eslintrc/base' ),
require.resolve( 'jetpack-js-tools/eslintrc/jest' ),
require.resolve( 'jetpack-js-tools/eslintrc/prettier' ),
],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

Introduced ESLint base config and fixed errors.
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/* global jQuery, _ */ ( function ( $, _ ) {
var processEvent,
sendClientSideStat,
statBucket = 'classic-custom-background';
/* global _ */
( function ( $, _ ) {
const statBucket = 'classic-custom-background';

sendClientSideStat = function ( eventName ) {
var url =
const sendClientSideStat = function ( eventName ) {
anomiex marked this conversation as resolved.
Show resolved Hide resolved
const url =
document.location.protocol +
'//pixel.wp.com/g.gif?v=wpcom-no-pv&x_' +
statBucket +
Expand All @@ -15,22 +14,20 @@
new Image().src = url;
};

processEvent = function ( e ) {
var target = $( e.target ),
const processEvent = function ( e ) {
const target = $( e.target ),
eventName = target.data( 'event' );

return sendClientSideStat( eventName );
};

$( function () {
var colorChange, oldColorChange;

oldColorChange = $( '#background-color' ).iris( 'option', 'change' );
const oldColorChange = $( '#background-color' ).iris( 'option', 'change' );

// Replace the Iris change handler
// Debounce so we don't get too many colour change events from users
// trying to find the perfect colour
colorChange = _.debounce(
const colorChange = _.debounce(
function () {
$( '#background-color' ).trigger( 'custom-bg-color-change' );
oldColorChange.apply( null, arguments );
Expand Down
Loading