@@ -69,6 +69,43 @@ async function loadPluginImpl(path) {
6969 return JSON . stringify ( { Success : ret } ) ;
7070}
7171
72+ /**
73+ * Context class.
74+ *
75+ * Each rule has its own `Context` object. It is passed to that rule's `create` function.
76+ */
77+ class Context {
78+ // Rule ID. Index into `registeredRules` array.
79+ #ruleId;
80+ // Absolute path of file being linted. Set before calling `rule`'s `create` method.
81+ physicalFilename ;
82+
83+ /**
84+ * @constructor
85+ * @param {number } ruleId - Rule ID
86+ */
87+ constructor ( ruleId ) {
88+ this . #ruleId = ruleId ;
89+ }
90+
91+ /**
92+ * Report error.
93+ * @param {Object } diagnostic - Diagnostic object
94+ * @param {string } diagnostic.message - Error message
95+ * @param {Object } diagnostic.loc - Node or loc object
96+ * @param {number } diagnostic.loc.start - Start range of diagnostic
97+ * @param {number } diagnostic.loc.end - End range of diagnostic
98+ * @returns {undefined }
99+ */
100+ report ( diagnostic ) {
101+ diagnostics . push ( {
102+ message : diagnostic . message ,
103+ loc : { start : diagnostic . node . start , end : diagnostic . node . end } ,
104+ externalRuleId : this . #ruleId,
105+ } ) ;
106+ }
107+ }
108+
72109// --------------------
73110// Running rules
74111// --------------------
@@ -147,43 +184,6 @@ function lintFile([filePath, bufferId, buffer, ruleIds]) {
147184 return ret ;
148185}
149186
150- /**
151- * Context class.
152- *
153- * Each rule has its own `Context` object. It is passed to that rule's `create` function.
154- */
155- class Context {
156- // Rule ID. Index into `registeredRules` array.
157- #ruleId;
158- // Absolute path of file being linted. Set before calling `rule`'s `create` method.
159- physicalFilename ;
160-
161- /**
162- * @constructor
163- * @param {number } ruleId - Rule ID
164- */
165- constructor ( ruleId ) {
166- this . #ruleId = ruleId ;
167- }
168-
169- /**
170- * Report error.
171- * @param {Object } diagnostic - Diagnostic object
172- * @param {string } diagnostic.message - Error message
173- * @param {Object } diagnostic.loc - Node or loc object
174- * @param {number } diagnostic.loc.start - Start range of diagnostic
175- * @param {number } diagnostic.loc.end - End range of diagnostic
176- * @returns {undefined }
177- */
178- report ( diagnostic ) {
179- diagnostics . push ( {
180- message : diagnostic . message ,
181- loc : { start : diagnostic . node . start , end : diagnostic . node . end } ,
182- externalRuleId : this . #ruleId,
183- } ) ;
184- }
185- }
186-
187187// --------------------
188188// Run linter
189189// --------------------
0 commit comments