Skip to content

Commit

Permalink
Adds base ESLint configuration to the wpcomsh plugin. (#39275)
Browse files Browse the repository at this point in the history
* Added a base JS eslint config.

* ESLint fixes for classic-background-stats.js

* Color.js fixes for eslint.

* Eslint fixes for colors-control-beta.js.

* Eslint fixes for colors-control.js.

* Eslint fixes for colors-theme-preview.js

* Eslint auto-fixes for customizer-labels-site-not-launched.js.

* Eslint auto-fixes for footer-credit control.js.

* Eslint auto-fixes for gifting-banner.js

* Eslint fixes for logo tool customizer JS.

* Adding eslintignore.

* Eslint fixes for music-player.js.

* Eslint fixes for tlkio.js

* Changeloge.

* Properly using ESLintrc file

* Update projects/plugins/wpcomsh/custom-colors/js/color.js

* Removed unused function, added URI component encoding.

* Update projects/plugins/wpcomsh/custom-colors/js/color.js
  • Loading branch information
zinigor authored and gogdzl committed Oct 25, 2024
1 parent 7644683 commit bdc64d4
Show file tree
Hide file tree
Showing 14 changed files with 525 additions and 514 deletions.
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
/custom-colors/js/jquery.spin.js
/custom-colors/js/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 =
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

0 comments on commit bdc64d4

Please sign in to comment.