Skip to content

Commit

Permalink
feat: Add command for elisp-lint (#79)
Browse files Browse the repository at this point in the history
* feat: Add command for elisp-lint

* Update todo list

* Provide better error result

* Add help for regexps command

* Add missing help elint

* update test

* Add doc

* changelog

* Add package metadata

* clean up doc
  • Loading branch information
jcs090218 authored Dec 18, 2022
1 parent d1f7ea3 commit bb18980
Show file tree
Hide file tree
Showing 41 changed files with 191 additions and 37 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
* Merge `clean` commands to one subcommand (#71)
* Fix void function `eask-source` to `eask-f-source` (#75)
* Fix upcoming breaking changes from `package-build` (#65)
* Add support for `elisp-lint` (#79)

## 0.7.x
> Released Sep 08, 2022
Expand Down
34 changes: 34 additions & 0 deletions cmds/lint/elisp-lint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* Copyright (C) 2022 Jen-Chieh Shen
*
* This program 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 program 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.
*/

"use strict";

exports.command = ['elisp-lint [files..]'];
exports.desc = 'run elisp-lint';
exports.builder = {
files: {
description: 'files you want elisp-lint to run on',
requiresArg: false,
type: 'array',
},
};

exports.handler = async (argv) => {
await UTIL.e_call(argv, 'lint/elisp-lint', argv.files);
};
2 changes: 1 addition & 1 deletion docs/content/en/Development API/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ Print buffer and highlight the `errors` and `warnings`.
Print help manual located under `lisp/help/` directory.

```elisp
(eask-help 'search)
(eask-help "core/search")
```

{{< hint info >}}
Expand Down
26 changes: 20 additions & 6 deletions docs/content/en/Getting Started/Commands and options.md
Original file line number Diff line number Diff line change
Expand Up @@ -383,31 +383,41 @@ Commands that lint your Emacs package.

## 🔍 eask lint package

Lint package using [package-lint](https://github.com/purcell/package-lint).
Run [package-lint](https://github.com/purcell/package-lint).

```sh
$ eask [GLOBAL-OPTIONS] lint package [FILES..]
```

## 🔍 eask lint checkdoc

Run checkdoc.
Run checkdoc (built-in).

```sh
$ eask [GLOBAL-OPTIONS] lint checkdoc [FILES..]
```

## 🔍 eask lint elint

Run elint.
Run elint (built-in).

```sh
$ eask [GLOBAL-OPTIONS] lint elint [FILES..]
```

## 🔍 eask lint elisp-lint

Run [elisp-lint](https://github.com/gonewest818/elisp-lint).

```sh
$ eask [GLOBAL-OPTIONS] lint elisp-lint [FILES..]
```

This does respect the `.dir-locals.el` file! 🎉

## 🔍 eask lint elsa

Run elsa.
Run [elsa](https://github.com/emacs-elsa/Elsa).

```sh
$ eask [GLOBAL-OPTIONS] lint lint elsa [FILES..]
Expand All @@ -423,26 +433,30 @@ $ eask [GLOBAL-OPTIONS] lint indent [FILES..]

## 🔍 eask lint keywords

Run keywords checker.
Run keywords checker (built-in).

```sh
$ eask [GLOBAL-OPTIONS] lint keywords
```

## 🔍 eask lint declare

Run check-declare (built-in).

```sh
$ eask [GLOBAL-OPTIONS] lint declare [FILES..]
```

## 🔍 eask lint regexps

Alias: `lint relint`
Run [relint](https://github.com/mattiase/relint).

```sh
$ eask [GLOBAL-OPTIONS] lint regexps [FILES..]
```

Alias: `lint relint`

# 🚩 Testing

## 🔍 eask test ert
Expand Down
4 changes: 0 additions & 4 deletions docs/content/en/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ but the author is not an expert on these tools. Corrections are welcome.

- [ ] [FEAT] Add `add-source` command

### Linter

- [ ] [FEAT] Add `elisp-lint` command

### Testing

- [ ] [FEAT] Add `ecukes` command
Expand Down
2 changes: 1 addition & 1 deletion lisp/_prepare.el
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ Eask file in the workspace."
(eask--silent (eask-setup-paths)))
(eask--with-hooks ,@body))
(eask-msg "✗ Loading Eask file... missing!")
(eask-help 'init)))))))))
(eask-help "core/init")))))))))

;;
;;; Eask file
Expand Down
2 changes: 1 addition & 1 deletion lisp/core/compile.el
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@
(eask-package-el-files))))
(eask--compile-files files)
(eask-info "(No files have been compiled)")
(eask-help 'compile)))
(eask-help "core/compile")))

;;; core/compile.el ends here
2 changes: 1 addition & 1 deletion lisp/core/exec.el
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@
(eask--export-env)
(ansi-green "done ✓")))
(eask-info "✗ (No exeuction output)")
(eask-help 'exec)))
(eask-help "core/exec")))

;;; core/exec.el ends here
2 changes: 1 addition & 1 deletion lisp/core/info.el
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@
(eask--print-deps "dependencies:" eask-depends-on)
(eask--print-deps "devDependencies:" eask-depends-on-dev))
(eask-info "(Eask file has no package information)")
(eask-help 'info)))
(eask-help "core/info")))

;;; core/info.el ends here
2 changes: 1 addition & 1 deletion lisp/core/install-deps.el
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
(eask-warn "No development dependencies found in your Eask file; but continue to install package dependencies"))
(eask-install-dependencies))
(eask-info "✗ (No dependencies found in your Eask file)")
(eask-help 'install-deps)))
(eask-help "core/install-deps")))

;;; core/install-deps.el ends here
2 changes: 1 addition & 1 deletion lisp/core/install.el
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@
(eask-info "(Installed in %s)"
(file-name-directory (locate-library name))))
(eask-info "✗ (No files have been intalled)")
(eask-help 'install)))))
(eask-help "core/install")))))

;;; core/install.el ends here
2 changes: 1 addition & 1 deletion lisp/core/recipe.el
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@
(eask-msg "Recipe: %s" (pp-to-string recipe))
(eask-msg ""))
(eask-info "(Repository URL is required to form a recipe)")
(eask-help 'recipe)))
(eask-help "core/recipe")))

;;; core/recipe.el ends here
2 changes: 1 addition & 1 deletion lisp/core/reinstall.el
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@
(eask-package-reinstall name)
(eask-info "(Reinstalled %s)" name))
(eask-info "✗ (No packages have been reintalled)")
(eask-help 'reinstall))))
(eask-help "core/reinstall"))))

;;; core/reinstall.el ends here
2 changes: 1 addition & 1 deletion lisp/core/run.el
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
(cond
((null eask-scripts)
(eask-info "✗ (No scripts specified)")
(eask-help 'run))
(eask-help "core/run"))
((eask-all-p) ; Run all scripts
(dolist (data (reverse eask-scripts))
(eask--export-command (cdr data))))
Expand Down
2 changes: 1 addition & 1 deletion lisp/core/search.el
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@
(eask-info "(Search result of %s package%s)" (length result)
(eask--sinr result "" "s")))
(eask-info "(No search operation; missing queries specification)")
(eask-help 'search)))
(eask-help "core/search")))

;;; core/search.el ends here
2 changes: 1 addition & 1 deletion lisp/core/uninstall.el
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@
(eask-package-delete name)
(eask-info "(Deleted %s)" name))
(eask-info "✗ (No packages have been unintalled)")
(eask-help 'uninstall))))
(eask-help "core/uninstall"))))

;;; core/uninstall.el ends here
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 13 additions & 0 deletions lisp/help/lint/elint
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

💡 You need to specify file(s) you want the elint to run

[+] (package-file "ENTRY") ; One argument with a string
[+] (files "FILE-1" "FILE-2" ...) ; All arguments are wildcard patterns

For example,

[+] (files "*.el")

💡 Tip: You can use the command [files] to show all selected files

$ eask files
13 changes: 13 additions & 0 deletions lisp/help/lint/elisp-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

💡 You need to specify file(s) you want the elisp-lint to run

[+] (package-file "ENTRY") ; One argument with a string
[+] (files "FILE-1" "FILE-2" ...) ; All arguments are wildcard patterns

For example,

[+] (files "*.el")

💡 Tip: You can use the command [files] to show all selected files

$ eask files
13 changes: 13 additions & 0 deletions lisp/help/lint/elsa
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

💡 You need to specify file(s) you want the elsa to run

[+] (package-file "ENTRY") ; One argument with a string
[+] (files "FILE-1" "FILE-2" ...) ; All arguments are wildcard patterns

For example,

[+] (files "*.el")

💡 Tip: You can use the command [files] to show all selected files

$ eask files
2 changes: 1 addition & 1 deletion lisp/help/lint/indent
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

💡 You need to specify file(s) you want the package-lint to run
💡 You need to specify file(s) you want the indent-lint to run

[+] (package-file "ENTRY") ; One argument with a string
[+] (files "FILE-1" "FILE-2" ...) ; All arguments are wildcard patterns
Expand Down
13 changes: 13 additions & 0 deletions lisp/help/lint/regexps
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

💡 You need to specify file(s) you want the relint to run

[+] (package-file "ENTRY") ; One argument with a string
[+] (files "FILE-1" "FILE-2" ...) ; All arguments are wildcard patterns

For example,

[+] (files "*.el")

💡 Tip: You can use the command [files] to show all selected files

$ eask files
2 changes: 1 addition & 1 deletion lisp/lint/elint.el
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@
(eask-info "(No files have been checked (elint))")
(if (eask-args)
(eask--print-no-matching-files)
(eask-help 'elint))))
(eask-help "lint/elint"))))

;;; lint/elint.el ends here
54 changes: 54 additions & 0 deletions lisp/lint/elisp-lint.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
;;; lint/elisp-lint.el --- Run elisp-lint -*- lexical-binding: t; -*-

;;; Commentary:
;;
;; Commmand use to run `elisp-lint' for all files
;;
;; $ eask lint elisp-lint [files..]
;;
;;
;; Initialization options:
;;
;; [files..] files you want elisp-lint to run on
;;

;;; Code:

(load (expand-file-name
"../_prepare.el"
(file-name-directory (nth 1 (member "-scriptload" command-line-args))))
nil t)

(defconst eask--elisp-lint-version nil
"`elisp-lint' version.")

(defun eask--elisp-lint-process-file (filename)
"Process FILENAME."
(let* ((filename (expand-file-name filename))
(file (eask-root-del filename))
success)
(eask-msg "")
(eask-msg "`%s` with elisp-lint (%s)" (ansi-green file) eask--elisp-lint-version)
(eask-with-verbosity 'debug
(setq success (elisp-lint-file filename)))
;; Report result!
(cond (success
(eask-msg "No issues found"))
((eask-strict-p)
(eask-error "Linting failed")))))

(eask-start
(eask-with-archives "melpa"
(eask-package-install 'elisp-lint))
(setq eask--elisp-lint-version (eask-package--version-string 'elisp-lint))
(require 'elisp-lint)
(if-let ((files (eask-args-or-package-el-files)))
(progn
(mapcar #'eask--elisp-lint-process-file files)
(eask-info "(Total of %s files linted)" (length files)))
(eask-info "(No files have been linted)")
(if (eask-args)
(eask--print-no-matching-files)
(eask-help "lint/elisp-lint"))))

;;; lint/elisp-lint.el ends here
4 changes: 2 additions & 2 deletions lisp/lint/elsa.el
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
;;
;; Initialization options:
;;
;; [files..] files you want elint to run on
;; [files..] files you want elsa to run on
;;

;;; Code:
Expand Down Expand Up @@ -51,6 +51,6 @@
(eask-info "(No files have been linted)")
(if (eask-args)
(eask--print-no-matching-files)
(eask-help 'elsa))))
(eask-help "lint/elsa"))))

;;; lint/elsa.el ends here
2 changes: 1 addition & 1 deletion lisp/lint/indent.el
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@
(eask-info "(No files have been linted)")
(if (eask-args)
(eask--print-no-matching-files)
(eask-help "package/indent"))))
(eask-help "lint/indent"))))

;;; lint/indent.el ends here
2 changes: 1 addition & 1 deletion lisp/lint/regexps.el
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@
(eask-info "(No files have been linted)")
(if (eask-args)
(eask--print-no-matching-files)
(eask-help 'regexps))))
(eask-help "lint/regexps"))))

;;; lint/regexps.el ends here
Loading

0 comments on commit bb18980

Please sign in to comment.