[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/typescript-mode 2d382d8bfb 053/222: Support rule names and
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/typescript-mode 2d382d8bfb 053/222: Support rule names and severity in tslint reports. |
Date: |
Sun, 6 Feb 2022 16:59:13 -0500 (EST) |
branch: elpa/typescript-mode
commit 2d382d8bfb87155d1cbb7fe5337f32f4f0428309
Author: Louis-Dominique Dubeau <ldd@lddubeau.com>
Commit: Louis-Dominique Dubeau <ldd@lddubeau.com>
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..334a6fe090 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 3 (1))))
(add-to-list 'compilation-error-regexp-alist-alist regexp)
(add-to-list 'compilation-error-regexp-alist (car regexp)))
- [nongnu] elpa/typescript-mode 1bafd279cf 148/222: Enable more colors (#110), (continued)
- [nongnu] elpa/typescript-mode 1bafd279cf 148/222: Enable more colors (#110), ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 607897d583 151/222: Update Emacs Git to Xenial-build, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 42b366e669 153/222: Merge pull request #111 from tam5/master, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 2405090403 152/222: Handle CI-failures correctly., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 895cd7f425 173/222: Fix indentation infinite looping, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 9db704ec1f 185/222: Fix duplicate test name, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 4832652496 163/222: Support electric-layout-mode., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 710f5425a4 189/222: Add tests for typescript-indent-list-items option, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 1fd835e7f8 205/222: Fix typos in README, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 30391a518a 079/222: Fix indentation issue with conditional operators., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 2d382d8bfb 053/222: Support rule names and severity in tslint reports.,
ELPA Syncer <=
- [nongnu] elpa/typescript-mode 83579fac6e 070/222: Remove the explicit invocation of the mode hook., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode e700af4703 092/222: Use syntax-propertize-function to fontify regexps., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 1d32c6b3a8 066/222: Improve readability of the code., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 46e032e932 054/222: Fix list of values compilation mode should use., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 56a1ea861f 082/222: Merge pull request #55 from bkruczyk/fix-regex-font-locking, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 0353bd72f8 133/222: Add bigint, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 18dc5a36a6 140/222: Fixes typo in the README file., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 36105abbb1 141/222: Add 26.1 to the versions we test on., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 08ceb01ff3 142/222: We no longer support 24.3, fixes #100., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode f33751e98f 145/222: Fix a case of bad indentation., ELPA Syncer, 2022/02/06