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 all 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.

31 changes: 8 additions & 23 deletions projects/plugins/wpcomsh/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,13 @@
const loadIgnorePatterns = require( 'jetpack-js-tools/load-eslint-ignore.js' );

module.exports = {
root: true,
extends: [
require.resolve( 'jetpack-js-tools/eslintrc/jest' ),
require.resolve( 'jetpack-js-tools/eslintrc/prettier' ),
],
ignorePatterns: loadIgnorePatterns( __dirname ),
overrides: [],
env: {
browser: true,
jest: true,
node: true,
},
parserOptions: {
ecmaVersion: 2020,
},
globals: {},
settings: {},
rules: {
// Enforce use of the correct textdomain.
'@wordpress/i18n-text-domain': [
'error',
{
allowedTextDomain: 'wpcomsh',
},
],

'jest/no-disabled-tests': 'warn',
'jest/no-focused-tests': 'error',
'jest/no-identical-title': 'error',
'jest/prefer-to-have-length': 'warn',
'jest/valid-expect': 'error',
},
};
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 =
anomiex marked this conversation as resolved.
Show resolved Hide resolved
const sendClientSideStat = function ( eventName ) {
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