[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/typescript-mode e0b4a6cb31 055/222: Merge pull request #36
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/typescript-mode e0b4a6cb31 055/222: Merge pull request #36 from lddubeau/feature/improved-tslint-regex |
Date: |
Sun, 6 Feb 2022 16:59:14 -0500 (EST) |
branch: elpa/typescript-mode
commit e0b4a6cb31750314e827bbc57de9a35558b34fd9
Merge: f25f4751fe 46e032e932
Author: Jostein Kjønigsen <jostein@kjonigsen.net>
Commit: GitHub <noreply@github.com>
Merge pull request #36 from lddubeau/feature/improved-tslint-regex
Support rule names and severity in tslint reports.
---
typescript-mode-tests.el | 70 ++++++++++++++++++++++++++++++++++++++++++++++++
typescript-mode.el | 38 +++++++++++++++++++-------
2 files changed, 99 insertions(+), 9 deletions(-)
diff --git a/typescript-mode-tests.el b/typescript-mode-tests.el
index fb40785094..0c8fec5076 100644
--- a/typescript-mode-tests.el
+++ b/typescript-mode-tests.el
@@ -29,6 +29,76 @@
(kill-buffer buffer)))
+(defun get-all-matched-strings (to-match)
+ (let (result)
+ (dotimes (x (/ (length (match-data)) 2))
+ (setq result (nconc result (list (match-string x to-match)))))
+ result))
+
+(ert-deftest typescript-tslint-report-regexp-matches ()
+ "typescript-tslint-report-regexp matches a line that does not
+have a rule name or a severity."
+ (let* ((to-match
+ "src/modules/authenticator.ts[1, 83]: ' should be \"")
+ (match (string-match typescript-tslint-report-regexp
+ to-match))
+ (matches (and match (get-all-matched-strings to-match))))
+ (should match)
+ (should (not (nth 1 matches)))
+ (should (not (nth 2 matches)))
+ (should (string-equal (nth 3 matches)
+ "src/modules/authenticator.ts"))
+ (should (string-equal (nth 4 matches) "1"))
+ (should (string-equal (nth 5 matches) "83"))))
+
+(ert-deftest typescript-tslint-report-regexp-matches-with-name ()
+ "typescript-tslint-report-regexp matches a line that has
+a rule name, no severity."
+ (let* ((to-match
+ "(quotemark) src/modules/authenticator.ts[1, 83]: ' should be \"")
+ (match (string-match typescript-tslint-report-regexp
+ to-match))
+ (matches (and match (get-all-matched-strings to-match))))
+ (should match)
+ (should (not (nth 1 matches)))
+ (should (string-equal (nth 2 matches) "(quotemark) "))
+ (should (string-equal (nth 3 matches)
+ "src/modules/authenticator.ts"))
+ (should (string-equal (nth 4 matches) "1"))
+ (should (string-equal (nth 5 matches) "83"))))
+
+(ert-deftest typescript-tslint-report-regexp-matches-with-error ()
+ "typescript-tslint-report-regexp matches a line that has
+a severity set to ERROR, no rule name."
+ (let* ((to-match
+ "ERROR: src/modules/authenticator.ts[1, 83]: ' should be \"")
+ (match (string-match typescript-tslint-report-regexp
+ to-match))
+ (matches (and match (get-all-matched-strings to-match))))
+ (should match)
+ (should (not (nth 1 matches)))
+ (should (not (nth 2 matches)))
+ (should (string-equal (nth 3 matches)
+ "src/modules/authenticator.ts"))
+ (should (string-equal (nth 4 matches) "1"))
+ (should (string-equal (nth 5 matches) "83"))))
+
+(ert-deftest typescript-tslint-report-regexp-matches-with-warning ()
+ "typescript-tslint-report-regexp matches a line that has
+a severity set to WARNING, no rule name."
+ (let* ((to-match
+ "WARNING: src/modules/authenticator.ts[1, 83]: ' should be \"")
+ (match (string-match typescript-tslint-report-regexp
+ to-match))
+ (matches (and match (get-all-matched-strings to-match))))
+ (should match)
+ (should (string-equal (nth 1 matches) "WARNING"))
+ (should (not (nth 2 matches)))
+ (should (string-equal (nth 3 matches)
+ "src/modules/authenticator.ts"))
+ (should (string-equal (nth 4 matches) "1"))
+ (should (string-equal (nth 5 matches) "83"))))
+
(provide 'typescript-mode-tests)
;;; typescript-mode-tests.el ends here
diff --git a/typescript-mode.el b/typescript-mode.el
index 5de10fb9a6..12c71a9897 100644
--- a/typescript-mode.el
+++ b/typescript-mode.el
@@ -2027,21 +2027,41 @@ the broken-down class name of the item to insert."
"error [[:alnum:]]+: [^\r\n]+$")
"Regexp to match errors generated by tsc.")
+;;
;; Should handle output like:
;; src/modules/authenticator.ts[1, 83]: ' should be "
-;; src/modules/authenticator.ts[2, 26]: ' should be "
-(defconst typescript-tslint-warning-regexp
+;; (quotemarks) src/modules/authenticator.ts[2, 26]: ' should be "
+;; ERROR: (quotemarks) src/modules/authenticator.ts[2, 26]: ' should be "
+;; WARNING: src/modules/authenticator.ts[2, 26]: ' should be "
+;;
+;; "(quotemarks)" it the rule name. It is produced when using the
+;; "verbose" formatter. The "verbose" formatter is identical to the
+;; default ("prose") formatter, except for the additional rule name.
+;;
+;; "ERROR:" and "WARNING:" are the severity. This was added in tslint
+;; 5.0. Prior versions have no notion of severity and simply omit this
+;; part.
+;;
+(defconst typescript-tslint-report-regexp
(concat
"^[[:blank:]]*"
- "\\([^(\r\n)]+\\)" ;; filename
+ ;; severity ("type" in Emacs' parlance)
+ "\\(?:\\(?:ERROR\\|\\(WARNING\\)\\):[[:blank:]]+\\)?"
+ ;; rule name
+ "\\((.*)[[:blank:]]+\\)?"
+ ;; filename
+ "\\([^(\r\n)]+\\)"
"\\["
- "\\([[:digit:]]+\\)" ; line
+ ;; line
+ "\\([[:digit:]]+\\)"
", "
- "\\([[:digit:]]+\\)" ; column
+ ;; column
+ "\\([[:digit:]]+\\)"
"\\]: "
- ".*$" ;; type of warnings
+ ;; message
+ ".*$"
)
- "Regexp to match warnings generated by tslint.")
+ "Regexp to match reports generated by tslint.")
(dolist
(regexp
@@ -2050,8 +2070,8 @@ the broken-down class name of the item to insert."
1 2 3 2)
(typescript-tslint
- ,typescript-tslint-warning-regexp
- 1 2 3 1)))
+ ,typescript-tslint-report-regexp
+ 3 4 5 (1))))
(add-to-list 'compilation-error-regexp-alist-alist regexp)
(add-to-list 'compilation-error-regexp-alist (car regexp)))
- [nongnu] elpa/typescript-mode 5bf30fe8d6 175/222: Add member expressions tests involving type parameters., (continued)
- [nongnu] elpa/typescript-mode 5bf30fe8d6 175/222: Add member expressions tests involving type parameters., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 1c27fb09ed 220/222: Fix cl deprecation warning, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode dd832751ab 217/222: Merge pull request #156 from zkry/fix-dot-after-exclamation-indentation, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 4249a20d6d 187/222: Added file for indent test case, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode c5e7788ce9 044/222: Merge pull request #28 from ananthakumaran/testing, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 99c2b74ac3 059/222: Make current-column function internal., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 89d22c4e18 051/222: Don't interpret forward slash in list as operator., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 393ac6db0f 081/222: add tests for regexp font locking, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 361564c4a9 057/222: typescript-current-column: Dont cause side-effects., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode d155a4b623 063/222: Revert indent of complex parameters., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode e0b4a6cb31 055/222: Merge pull request #36 from lddubeau/feature/improved-tslint-regex,
ELPA Syncer <=
- [nongnu] elpa/typescript-mode bce2e73cf2 107/222: Remove unused dependencies, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 7172a23d86 072/222: Add a custom predicate for flyspell-prog-mode., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode d8501770f6 103/222: Fix indentation of multiple curly braces in sequence., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode a09e9c78f9 108/222: Highlight class names., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 7c6fd0f4a8 115/222: Document how to handle ANSI codes in error messages., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 9796425fdb 113/222: Add support for new type "unknown"., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 39b7ba9e54 117/222: Distinguish type arguments from lesser/greater than. (Fixes #81), ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 30f8b8feb4 122/222: Merge pull request #87 from Ailrun/add-jsdoc-tags, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 29282a32b7 124/222: add never type, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 8910e12525 129/222: Add autoload cookie with safe-local-var for typescript-indent-level, ELPA Syncer, 2022/02/06