Skip to content

Commit bd2376c

Browse files
committed
Simplify javascript-lint module definition and ensure proper types
1 parent a722b50 commit bd2376c

File tree

3 files changed

+28
-18
lines changed

3 files changed

+28
-18
lines changed

package-lock.json

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"@lodder/grunt-postcss": "^3.1.1",
3131
"@playwright/test": "1.56.1",
3232
"@pmmmwh/react-refresh-webpack-plugin": "0.6.1",
33+
"@types/codemirror": "5.60.17",
3334
"@wordpress/e2e-test-utils-playwright": "1.33.2",
3435
"@wordpress/prettier-config": "4.33.1",
3536
"@wordpress/scripts": "30.26.2",

src/js/_enqueues/vendor/codemirror/javascript-lint.js

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,9 @@
1-
/* globals define, CodeMirror */
21
/* jshint devel: true */
32

43
// CodeMirror, copyright (c) by Marijn Haverbeke and others
54
// Distributed under an MIT license: https://codemirror.net/5/LICENSE
65

7-
( function ( mod ) {
8-
if ( typeof exports === 'object' && typeof module === 'object' ) {
9-
// CommonJS
10-
mod( require( 'codemirror' ) );
11-
} else if ( typeof define === 'function' && define.amd ) {
12-
// AMD
13-
define( [ 'codemirror' ], mod );
14-
// Plain browser env
15-
} else {
16-
mod( CodeMirror );
17-
}
18-
} )( function ( CodeMirror ) {
6+
( ( CodeMirror ) => {
197
'use strict';
208

219
/**
@@ -26,8 +14,8 @@
2614
* @typedef {Object} CodeMirrorLintError
2715
* @property {string} message - Error message.
2816
* @property {'error'} severity - Severity.
29-
* @property {{line: number, ch: number}} from - From position.
30-
* @property {{line: number, ch: number}} to - To position.
17+
* @property {CodeMirror.Position} from - From position.
18+
* @property {CodeMirror.Position} to - To position.
3119
*/
3220

3321
/**
@@ -70,8 +58,8 @@
7058
errors.push( {
7159
message: error.message,
7260
severity: 'error',
73-
from: { line, ch: error.column - 1 },
74-
to: { line, ch: error.column },
61+
from: CodeMirror.Pos( line, error.column - 1 ),
62+
to: CodeMirror.Pos( line, error.column ),
7563
} );
7664
} else {
7765
console.warn( '[CodeMirror] Unable to lint JavaScript:', error );
@@ -125,4 +113,4 @@
125113
}
126114
return 'latest';
127115
}
128-
} );
116+
} )( require( 'codemirror' ) );

0 commit comments

Comments
 (0)