-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* code style: if * Function code style tracking * Type annotations linting
- Loading branch information
Philippe
authored
Feb 22, 2021
1 parent
a0493f4
commit 916e8cc
Showing
17 changed files
with
833 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { DiagnosticSeverity, Range } from 'brighterscript'; | ||
|
||
enum CodeStyleError { | ||
InlineIfFound = 'LINT3001', | ||
InlineIfThenMissing = 'LINT3002', | ||
InlineIfThenFound = 'LINT3003', | ||
BlockIfThenMissing = 'LINT3004', | ||
BlockIfThenFound = 'LINT3005', | ||
ConditionGroupMissing = 'LINT3006', | ||
ConditionGroupFound = 'LINT3007', | ||
SubKeywordExpected = 'LINT3008', | ||
FunctionKeywordExpected = 'LINT3009', | ||
ReturnTypeAnnotation = 'LINT3010', | ||
TypeAnnotation = 'LINT3011', | ||
} | ||
|
||
const CS = 'Code style:'; | ||
const ST = 'Strictness:'; | ||
|
||
const messages = { | ||
addBlockIfThenKeyword: (range: Range) => ({ | ||
severity: DiagnosticSeverity.Error, | ||
code: CodeStyleError.BlockIfThenMissing, | ||
message: `${CS} add 'then' keyword`, | ||
range | ||
}), | ||
removeBlockIfThenKeyword: (range: Range) => ({ | ||
severity: DiagnosticSeverity.Error, | ||
code: CodeStyleError.BlockIfThenFound, | ||
message: `${CS} remove 'then' keyword`, | ||
range | ||
}), | ||
inlineIfNotAllowed: (range: Range) => ({ | ||
severity: DiagnosticSeverity.Error, | ||
code: CodeStyleError.InlineIfFound, | ||
message: `${CS} no inline if statement allowed`, | ||
range | ||
}), | ||
addInlineIfThenKeyword: (range: Range) => ({ | ||
severity: DiagnosticSeverity.Error, | ||
code: CodeStyleError.InlineIfThenMissing, | ||
message: `${CS} add 'then' keyword`, | ||
range | ||
}), | ||
removeInlineIfThenKeyword: (range: Range) => ({ | ||
severity: DiagnosticSeverity.Error, | ||
code: CodeStyleError.InlineIfThenFound, | ||
message: `${CS} remove 'then' keyword`, | ||
range | ||
}), | ||
addParenthesisAroundCondition: (range: Range) => ({ | ||
severity: DiagnosticSeverity.Error, | ||
code: CodeStyleError.ConditionGroupMissing, | ||
message: `${CS} add parenthesis around condition`, | ||
range | ||
}), | ||
removeParenthesisAroundCondition: (range: Range) => ({ | ||
severity: DiagnosticSeverity.Error, | ||
code: CodeStyleError.ConditionGroupFound, | ||
message: `${CS} remove parenthesis around condition`, | ||
range | ||
}), | ||
expectedKeyword: (range: Range, keyword: string, reason: string) => ({ | ||
severity: DiagnosticSeverity.Error, | ||
code: CodeStyleError.SubKeywordExpected, | ||
message: `${CS} expected '${keyword}' keyword ${reason}`, | ||
range | ||
}), | ||
expectedReturnTypeAnnotation: (range: Range) => ({ | ||
severity: DiagnosticSeverity.Error, | ||
code: CodeStyleError.ReturnTypeAnnotation, | ||
message: `${ST} function should declare the return type`, | ||
range | ||
}), | ||
expectedTypeAnnotation: (range: Range) => ({ | ||
severity: DiagnosticSeverity.Error, | ||
code: CodeStyleError.TypeAnnotation, | ||
message: `${ST} type annotation required`, | ||
range | ||
}) | ||
}; | ||
|
||
export default messages; |
Oops, something went wrong.