From c7295c8589ebd0d01714b5674db268fc9cfa981c Mon Sep 17 00:00:00 2001 From: Andreas Gerler Date: Tue, 22 Jan 2019 16:54:01 +0100 Subject: [PATCH] Update package-lint. Signed-off-by: Andreas Gerler --- .../package-lint-flymake.el | 66 ----------------- .../package-lint-pkg.el | 14 ---- .../package-lint-autoloads.el | 17 ----- .../package-lint-pkg.el | 2 + .../package-lint.el | 74 ++++++++++++++++--- elpa/package-lint-readme.txt | 7 -- 6 files changed, 66 insertions(+), 114 deletions(-) delete mode 100644 elpa/package-lint-20181017.623/package-lint-flymake.el delete mode 100644 elpa/package-lint-20181017.623/package-lint-pkg.el rename elpa/{package-lint-20181017.623 => package-lint-20190112.510}/package-lint-autoloads.el (75%) create mode 100644 elpa/package-lint-20190112.510/package-lint-pkg.el rename elpa/{package-lint-20181017.623 => package-lint-20190112.510}/package-lint.el (93%) delete mode 100644 elpa/package-lint-readme.txt diff --git a/elpa/package-lint-20181017.623/package-lint-flymake.el b/elpa/package-lint-20181017.623/package-lint-flymake.el deleted file mode 100644 index e9550bbd..00000000 --- a/elpa/package-lint-20181017.623/package-lint-flymake.el +++ /dev/null @@ -1,66 +0,0 @@ -;;; package-lint-flymake.el --- A package-lint Flymake backend -*- lexical-binding: t; -*- -;; -;; Copyright (C) 2018 J. Alexander Branham (alex DOT branham AT gmail DOT com) -;; -;; This file is not part of GNU Emacs. -;; -;; This is free software; you can redistribute it and/or modify it under -;; the terms of the GNU General Public License as published by the Free -;; Software Foundation; either version 3, or (at your option) any later -;; version. -;; -;; This is distributed in the hope that it will be useful, but WITHOUT -;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -;; for more details. -;; -;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -;; MA 02110-1301 USA. -;; -;;; Commentary: -;; -;; Flymake is the built-in Emacs package to support on-the-fly syntax -;; checking. This file adds support for flymake to `package-lint'. -;; Enable it by calling `package-lint-setup-flymake' from a -;; file-visiting buffer. To enable in all `emacs-lisp-mode' buffers: -;; -;; (add-hook 'emacs-lisp-mode-hook #'package-lint-setup-flymake) -;; -;;; Code: -(eval-when-compile - (require 'cl-lib)) -(require 'flymake) -(require 'package-lint) - -(defvar-local package-lint--flymake-proc nil) - -(defun package-lint-flymake (report-fn &rest _args) - "A Flymake backend for `package-lint'. -Use `package-lint-setup-flymake' to add this to -`flymake-diagnostic-functions'. Calls REPORT-FN directly." - (let ((collection (package-lint-buffer))) - (cl-loop for (line col type message) in - collection - for (beg . end) = (flymake-diag-region (current-buffer) line col) - collect - (flymake-make-diagnostic - (current-buffer) - beg end - (if (eq type 'warning) :warning :error) - message) - into diags - finally (funcall report-fn diags)))) - -;;;###autoload -(defun package-lint-setup-flymake () - "Setup package-lint integration with Flymake." - (if (< emacs-major-version 26) - (error "Package-lint-flymake requires Emacs 26 or later") - (add-hook 'flymake-diagnostic-functions #'package-lint-flymake nil t) - (flymake-mode))) - -(provide 'package-lint-flymake) - -;;; package-lint-flymake.el ends here diff --git a/elpa/package-lint-20181017.623/package-lint-pkg.el b/elpa/package-lint-20181017.623/package-lint-pkg.el deleted file mode 100644 index d5ad3928..00000000 --- a/elpa/package-lint-20181017.623/package-lint-pkg.el +++ /dev/null @@ -1,14 +0,0 @@ -(define-package "package-lint" "20181017.623" "A linting library for elisp package authors" - '((cl-lib "0.5") - (emacs "24")) - :keywords - '("lisp") - :authors - '(("Steve Purcell" . "steve@sanityinc.com") - ("Fanael Linithien" . "fanael4@gmail.com")) - :maintainer - '("Steve Purcell" . "steve@sanityinc.com") - :url "https://github.com/purcell/package-lint") -;; Local Variables: -;; no-byte-compile: t -;; End: diff --git a/elpa/package-lint-20181017.623/package-lint-autoloads.el b/elpa/package-lint-20190112.510/package-lint-autoloads.el similarity index 75% rename from elpa/package-lint-20181017.623/package-lint-autoloads.el rename to elpa/package-lint-20190112.510/package-lint-autoloads.el index 8a3ad307..e7c6ad9d 100644 --- a/elpa/package-lint-20181017.623/package-lint-autoloads.el +++ b/elpa/package-lint-20190112.510/package-lint-autoloads.el @@ -43,23 +43,6 @@ Return non-nil if the current buffer appears to be intended as a package. (if (fboundp 'register-definition-prefixes) (register-definition-prefixes "package-lint" '("package-lint--"))) -;;;*** - -;;;### (autoloads nil "package-lint-flymake" "package-lint-flymake.el" -;;;;;; (0 0 0 0)) -;;; Generated autoloads from package-lint-flymake.el - -(autoload 'package-lint-setup-flymake "package-lint-flymake" "\ -Setup package-lint integration with Flymake. - -\(fn)" nil nil) - -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "package-lint-flymake" '("package-lint-"))) - -;;;*** - -;;;### (autoloads nil nil ("package-lint-pkg.el") (0 0 0 0)) - ;;;*** ;; Local Variables: diff --git a/elpa/package-lint-20190112.510/package-lint-pkg.el b/elpa/package-lint-20190112.510/package-lint-pkg.el new file mode 100644 index 00000000..24a41555 --- /dev/null +++ b/elpa/package-lint-20190112.510/package-lint-pkg.el @@ -0,0 +1,2 @@ +;;; -*- no-byte-compile: t -*- +(define-package "package-lint" "20190112.510" "A linting library for elisp package authors" '((cl-lib "0.5") (emacs "24")) :commit "9a5b92cfa675323891d7297cce34b568db2759d2" :keywords '("lisp") :authors '(("Steve Purcell" . "steve@sanityinc.com") ("Fanael Linithien" . "fanael4@gmail.com")) :maintainer '("Steve Purcell" . "steve@sanityinc.com") :url "https://github.com/purcell/package-lint") diff --git a/elpa/package-lint-20181017.623/package-lint.el b/elpa/package-lint-20190112.510/package-lint.el similarity index 93% rename from elpa/package-lint-20181017.623/package-lint.el rename to elpa/package-lint-20190112.510/package-lint.el index 48d357a2..a2586cf4 100644 --- a/elpa/package-lint-20181017.623/package-lint.el +++ b/elpa/package-lint-20190112.510/package-lint.el @@ -5,6 +5,7 @@ ;; Author: Steve Purcell ;; Fanael Linithien ;; URL: https://github.com/purcell/package-lint +;; Package-Version: 20190112.510 ;; Keywords: lisp ;; Version: 0 ;; Package-Requires: ((cl-lib "0.5") (emacs "24")) @@ -263,6 +264,9 @@ This is bound dynamically while the checks run.") (when desc (package-lint--check-package-summary desc) (package-lint--check-provide-form desc))) + (package-lint--check-no-use-of-cl) + (package-lint--check-no-use-of-cl-lib-sublibraries) + (package-lint--check-eval-after-load) (let ((deps (package-lint--check-dependency-list))) (package-lint--check-lexical-binding-requires-emacs-24 deps) (package-lint--check-libraries-available-in-emacs deps) @@ -533,6 +537,36 @@ REGEXP is (concat RX-START REGEXP* RX-END) for each REGEXP*." (mapconcat #'number-to-string added-in-version ".") sym))))))))))) +(defun package-lint--check-eval-after-load () + "Warn about use of `eval-after-load' and co." + (save-excursion + (save-match-data + (goto-char (point-min)) + (when (re-search-forward "(\\s-*?\\(\\(?:with-\\)?eval-after-load\\)\\_>" nil t) + (package-lint--error-at-point + 'warning + (format "`%s' is for use in configurations, and should rarely be used in packages." (match-string 1))))))) + +(defun package-lint--check-no-use-of-cl () + "Warn about use of deprecated `cl' library." + (save-excursion + (save-match-data + (goto-char (point-min)) + (when (re-search-forward "(\\s-*?require\\s-*?'cl\\_>" nil t) + (package-lint--error-at-point + 'warning + "Replace deprecated `cl' with `cl-lib'. The `cl-libify' package can help with this."))))) + +(defun package-lint--check-no-use-of-cl-lib-sublibraries () + "Warn about use of `cl-macs', `cl-seq' etc." + (save-excursion + (save-match-data + (goto-char (point-min)) + (when (re-search-forward "(\\s-*?require\\s-*?'cl-\\(?:macs\\|seq\\)\\_>" nil t) + (package-lint--error-at-point + 'warning + "This file is not in the `cl-lib' ELPA compatibility package: require `cl-lib' instead."))))) + (defun package-lint--check-libraries-available-in-emacs (valid-deps) "Warn about use of libraries that are not available in the Emacs version in VALID-DEPS." (package-lint--check-version-regexp-list @@ -648,11 +682,11 @@ DESC is a struct as returned by `package-buffer-info'." 1 1 'warning "Package should have a non-empty summary.")) - ((> (length summary) 50) + ((> (length summary) 60) (package-lint--error 1 1 'warning - "The package summary is too long. It should be at most 50 characters."))) + "The package summary is too long. It should be at most 60 characters."))) (when (save-match-data (let ((case-fold-search t)) (and (string-match "[^.]\\" summary) @@ -688,6 +722,25 @@ DESC is a struct as returned by `package-buffer-info'." (format "`%s' contains a non-standard separator `%s', use hyphens instead (see Elisp Coding Conventions)." name (substring-no-properties name match-pos (1+ match-pos))))))))) +(defun package-lint--valid-definition-name-p (name prefix-re position) + "Return non-nil if NAME denotes a valid definition name. + +Valid definition names are: + +- a NAME starting with PREFIX-RE, a regular expression + representing the current package prefix, + +- a NAME matching `package-lint--sane-prefixes', or + +- a NAME whose POSITION in the buffer denotes a global definition." + (or (string-match-p prefix-re name) + (string-match-p package-lint--sane-prefixes name) + (progn + (goto-char position) + (looking-at-p (rx (*? space) "(" (*? space) + (or "defadvice" "cl-defmethod") + symbol-end))))) + (defun package-lint--check-defs-prefix (definitions) "Verify that symbol DEFINITIONS start with package prefix." (let ((prefix (package-lint--get-package-prefix))) @@ -702,11 +755,7 @@ DESC is a struct as returned by `package-buffer-info'." (seq "-" (* any) "-mode")) string-end)))))) (pcase-dolist (`(,name . ,position) definitions) - (unless (or (string-match-p prefix-re name) - (string-match-p package-lint--sane-prefixes name) - (progn - (goto-char position) - (looking-at-p (rx (*? space) "(" (*? space) "defadvice" symbol-end)))) + (unless (package-lint--valid-definition-name-p name prefix-re position) (let ((line-no (line-number-at-pos position))) (package-lint--error line-no 1 'error @@ -720,12 +769,17 @@ DESC is a struct as returned by `package-buffer-info'." (defun package-lint--check-globalized-minor-mode (def) "Offer up concerns about the global minor mode definition DEF." - (let ((feature (intern (package-lint--provided-feature)))) - (unless (cl-search `(:require ',feature) def :test #'equal) + (let ((feature (intern (package-lint--provided-feature))) + (autoloaded (save-excursion + (forward-line -1) + (beginning-of-line) + (looking-at ";;;###autoload")))) + (unless (or autoloaded + (cl-search `(:require ',feature) def :test #'equal)) (package-lint--error-at-point 'error (format - "Global minor modes must `:require' their defining file (i.e. \":require '%s\"), to support the customization variable of the same name." feature))))) + "Global minor modes should be autoloaded or, rarely, `:require' their defining file (i.e. \":require '%s\"), to support the customization variable of the same name." feature))))) (defun package-lint--check-defgroup (def) "Offer up concerns about the customization group definition DEF." diff --git a/elpa/package-lint-readme.txt b/elpa/package-lint-readme.txt deleted file mode 100644 index 18c99eb9..00000000 --- a/elpa/package-lint-readme.txt +++ /dev/null @@ -1,7 +0,0 @@ -Provides a list of issues with the package metadata of a file, -e.g. the package dependencies it requires. - -See function `package-lint-buffer'. - -Checks will currently be enabled only if a "Package-Requires:" or -"Package-Version:" header is present in the file. -- 2.47.3