Skip to content
This repository was archived by the owner on Mar 23, 2024. It is now read-only.

Commit d480c30

Browse files
committed
[Fix] Remove unused tokenBefore / noTokenBefore
1 parent 0e9f4fa commit d480c30

File tree

1 file changed

+0
-93
lines changed

1 file changed

+0
-93
lines changed

lib/token-assert.js

Lines changed: 0 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -416,97 +416,4 @@ TokenAssert.prototype._augmentLineCount = function(options, lineCount) {
416416
});
417417
};
418418

419-
/**
420-
* Requires specific token before given.
421-
*
422-
* @param {Object} options
423-
* @param {Object} options.token
424-
* @param {Object} options.expectedTokenBefore
425-
* @param {String} [options.message]
426-
*/
427-
TokenAssert.prototype.tokenBefore = function(options) {
428-
var token = options.token;
429-
var actualTokenBefore = this._file.getPrevToken(token);
430-
var expectedTokenBefore = options.expectedTokenBefore;
431-
432-
if (!actualTokenBefore) {
433-
var loc = token.getLoc();
434-
this.emit('error', {
435-
message: expectedTokenBefore.value + ' was expected before ' + token.value + ' but document start found',
436-
line: loc.start.line,
437-
column: loc.start.column
438-
});
439-
return;
440-
}
441-
442-
// Only attempt to remove or add lines if there are no comments between the two nodes
443-
// as this prevents accidentally moving a valid token onto a line comment ed line
444-
var fixed = this._file.getPrevToken(options.token, {includeComments: true}) === actualTokenBefore;
445-
446-
if (
447-
actualTokenBefore.type !== expectedTokenBefore.type ||
448-
actualTokenBefore.value !== expectedTokenBefore.value
449-
) {
450-
451-
if (fixed) {
452-
this._file.setWhitespaceBefore(token, expectedTokenBefore.value + this._file.getWhitespaceBefore(token));
453-
}
454-
455-
var message = options.message;
456-
if (!message) {
457-
var showTypes = expectedTokenBefore.value === actualTokenBefore.value;
458-
message =
459-
expectedTokenBefore.value + (showTypes ? ' (' + expectedTokenBefore.type + ')' : '') +
460-
' was expected before ' + token.value +
461-
' but ' + actualTokenBefore.value + (showTypes ? ' (' + actualTokenBefore.type + ')' : '') + ' found';
462-
}
463-
464-
var actualTokenBeforeLoc = actualTokenBefore.getLoc();
465-
this.emit('error', {
466-
message: message,
467-
line: actualTokenBeforeLoc.end.line,
468-
column: actualTokenBeforeLoc.end.column,
469-
fixed: fixed
470-
});
471-
}
472-
};
473-
/**
474-
* Disallows specific token before given.
475-
*
476-
* @param {Object} options
477-
* @param {Object} options.token
478-
* @param {Object} options.expectedTokenBefore
479-
* @param {String} [options.message]
480-
*/
481-
TokenAssert.prototype.noTokenBefore = function(options) {
482-
var token = options.token;
483-
var actualTokenBefore = this._file.getPrevToken(token);
484-
if (!actualTokenBefore) {
485-
// document start
486-
return;
487-
}
488-
489-
var fixed = this._file.getPrevToken(options.token, {
490-
includeComments: true
491-
}) === actualTokenBefore;
492-
493-
var expectedTokenBefore = options.expectedTokenBefore;
494-
if (actualTokenBefore.type === expectedTokenBefore.type &&
495-
actualTokenBefore.value === expectedTokenBefore.value
496-
) {
497-
498-
if (fixed) {
499-
actualTokenBefore.value = '';
500-
}
501-
502-
var loc = actualTokenBefore.getLoc();
503-
this.emit('error', {
504-
message: options.message || 'Illegal ' + expectedTokenBefore.value + ' was found before ' + token.value,
505-
line: loc.end.line,
506-
column: loc.end.column,
507-
fixed: fixed
508-
});
509-
}
510-
};
511-
512419
module.exports = TokenAssert;

0 commit comments

Comments
 (0)