Skip to content

Commit

Permalink
Linter cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
worksofliam committed Jan 24, 2022
1 parent 0125d51 commit 173cdb5
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/language/linter.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,12 @@ module.exports = class Linter {
/** @type {string[]} */
const lines = content.replace(new RegExp(`\\\r`, `g`), ``).split(`\n`);

const indentEnabled = rules.indent !== undefined;
const indent = rules.indent || 2;

// Excluding indent
const ruleCount = Object.keys(rules).length - (rules.indent ? 1 : 0);

/** @type {string[]} */
let scopeNames = []

/** @type {Declaration[]} */
let scopeVariables = [];

let globalProcs = [];

if (globalScope) {
Expand All @@ -101,12 +96,12 @@ module.exports = class Linter {
let lineNumber = -1;

/** @type {{line: number, expectedIndent: number, currentIndent: number}[]} */
let indentErrors = [];
const indentErrors = [];

// Offset is always the offset within the range

/** @type {IssueRange[]} */
let errors = [];
const errors = [];

/** @type {Number} */
let expectedIndent = 0;
Expand All @@ -115,19 +110,22 @@ module.exports = class Linter {
/** @type {string[]} */
let pieces;

let continuedStatement = false, isLineComment = false, skipIndentCheck = false;
let continuedStatement = false;
let isLineComment = false;
let skipIndentCheck = false;

let currentStatement = ``, opcode;
let currentStatement = ``;
let opcode;

/** @type {vscode.Position} */
let statementStart;
/** @type {vscode.Position} */
let statementEnd;

/** @type {{value: string, definition?: string, list: {range: vscode.Range, offset: {position: number, length: number}}[]}[]} */
let stringLiterals = [];
const stringLiterals = [];

for (let currentLine of lines) {
for (const currentLine of lines) {
currentIndent = currentLine.search(/\S/);
let line = currentLine.trimEnd();

Expand Down Expand Up @@ -732,7 +730,7 @@ module.exports = class Linter {

// Next, check for indentation errors

if (!skipIndentCheck) {
if (indentEnabled && skipIndentCheck === false) {
pieces = upperLine.split(` `).filter(piece => piece !== ``);
opcode = pieces[0];

Expand Down

0 comments on commit 173cdb5

Please sign in to comment.