Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
* fix(lisp/extern): Clean up `compat` (2b41f5db4b5bbe145c9671f95850f79a00dcbd48)
* fix(lisp): Paint keywords with nested ansi codes (#323)
* feat(create): Add new command for `el-project` (#325)
* feat(lint): Add command for `org-lint` (#328)

## 0.11.x
> Released Apr 03, 2025
Expand Down
31 changes: 31 additions & 0 deletions cmds/lint/org.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* Copyright (C) 2025 the Eask authors.
*
* 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 this program. If not, see <https://www.gnu.org/licenses/>.
*/

"use strict";

exports.command = ['org [files..]'];
exports.desc = `Run org-lint on Org files`;
exports.builder = yargs => yargs
.positional(
'[files..]', {
description: 'files you want org-lint to run on',
type: 'array',
});

exports.handler = async (argv) => {
await UTIL.e_call(argv, 'lint/org', argv.files);
};
34 changes: 21 additions & 13 deletions docs/content/Getting-Started/Commands-and-options/_index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -808,38 +808,46 @@ Run indent-lint.
eask [GLOBAL-OPTIONS] lint indent [FILES..]
```

## 🔍 eask lint keywords
## 🔍 eask lint declare

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

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

## 🔍 eask lint license
## 🔍 eask lint regexps

Run license check.
Run [relint](https://github.com/mattiase/relint).

Alias: `lint relint`

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

## 🔍 eask lint declare
## 🔍 eask lint keywords

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

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

## 🔍 eask lint regexps
## 🔍 eask lint license

Run [relint](https://github.com/mattiase/relint).
Run license check.

Alias: `lint relint`
```sh
eask [GLOBAL-OPTIONS] lint license
```

## 🔍 eask lint org

Run `org-lint` on Org files.

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

# 🚩 Testing
Expand Down
38 changes: 23 additions & 15 deletions docs/content/Getting-Started/Commands-and-options/_index.zh-tw.md
Original file line number Diff line number Diff line change
Expand Up @@ -754,15 +754,15 @@ eask [GLOBAL-OPTIONS] lint package [FILES..]

## 🔍 eask lint checkdoc

運行 checkdoc (自帶).
運行 checkdoc (自帶)

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

## 🔍 eask lint elint

運行 elint (自帶).
運行 elint (自帶)

```sh
eask [GLOBAL-OPTIONS] lint elint [FILES..]
Expand Down Expand Up @@ -794,38 +794,46 @@ eask [GLOBAL-OPTIONS] lint lint elsa [FILES..]
eask [GLOBAL-OPTIONS] lint indent [FILES..]
```

## 🔍 eask lint keywords
## 🔍 eask lint declare

運行 keywords checker (自帶).
運行 check-declare (自帶)

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

## 🔍 eask lint license
## 🔍 eask lint regexps

運行 license check.
Run [relint](https://github.com/mattiase/relint).

別名: `lint relint`

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

## 🔍 eask lint declare
## 🔍 eask lint keywords

運行 check-declare (自帶).
運行 keywords checker (自帶).

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

## 🔍 eask lint regexps
## 🔍 eask lint license

Run [relint](https://github.com/mattiase/relint).
運行 license 檢查器。

別名: `lint relint`
```sh
eask [GLOBAL-OPTIONS] lint license
```

## 🔍 eask lint org

在 Org 檔案上運行 `org-lint`。

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

# 🚩 測試框架
Expand Down
8 changes: 8 additions & 0 deletions lisp/help/lint/org
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

💡 You need to specify pattern(s) you want to check

$ eask lint org [FILES..]

For example,

$ eask lint org README.org docs/*.org
78 changes: 78 additions & 0 deletions lisp/lint/org.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
;;; lint/org.el --- Run org-lint on Org files -*- lexical-binding: t; -*-

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

;;; Code:

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

;;
;;; Flags

(advice-add #'eask-allow-error-p :override #'eask-always)

;;
;;; Core

(defun eask-lint-org--print-error (file result)
"Print the error RESULT from FILE."
(let* ((data (cl-second result))
(filename (file-name-nondirectory file))
(line (elt data 0))
(text (elt data 2))
(msg (concat filename ":" line ": " text)))
(if (eask-strict-p) (error msg) (warn msg))))

(defun eask-lint-org--file (file)
"Run `org-lint' on FILE."
(eask-msg "`%s` with org-lint" (ansi-green file))
(with-temp-buffer
(insert-file-contents file)
(org-mode)
(if-let* ((results (org-lint)))
(mapc (lambda (result)
(eask-lint-org--print-error file result))
results)
(eask-msg "No issues found"))))

(eask-start
;; Preparation
(eask-archive-install-packages '("gnu")
'org)

;; Start Linting
(require 'org-lint)
(let* ((patterns (eask-args))
(files (eask-expand-file-specs patterns)))
(cond
;; Files found, do the action!
(files
(mapcar #'eask-lint-org--file files)
(eask-msg "")
(eask-info "(Total of %s file%s linted)" (length files)
(eask--sinr files "" "s")))
;; Pattern defined, but no file found!
(patterns
(eask-msg "")
(eask-info "(No files match wildcard: %s)"
(mapconcat #'identity patterns " ")))
;; Default, print help!
(t
(eask-msg "")
(eask-info "(No files have been linted)")
(eask-help "lint/org")))))

;;; lint/org.el ends here
7 changes: 7 additions & 0 deletions test/jest/local.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ describe("local", () => {
describe("Linting", () => {
// some lint commands may fail if packages are missing
beforeAll(async () => await ctx.runEask("install-deps"));

it.each([
"lint checkdoc",
"lint declare",
Expand All @@ -210,15 +211,21 @@ describe("local", () => {
])("eask %s", async (cmd) => {
await ctx.runEask(cmd);
});

it("lint regexps", async () => {
if ((await emacsVersion()) >= "27.1") {
await ctx.runEask("lint regexps");
}
});

// XXX: Elsa is not stable, ignore it for now
test.skip("lint elsa", async () => {
await ctx.runEask("lint elsa");
});

it("lint org *.org", async () => {
await ctx.runEask("lint org *.org");
});
});

describe("Testing", () => {
Expand Down
2 changes: 1 addition & 1 deletion test/jest/local/Eask
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
;; -*- mode: eask; lexical-binding: t -*-

(package "mini.pkg.1"
"5.5.6"
"9.9.10"
"Minimal test package")

(website-url "https://github.com/emacs-eask/cli/tree/master/test/fixtures/mini.pkg.1")
Expand Down
19 changes: 19 additions & 0 deletions test/jest/local/README.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
* Test Org File
This is a test org file used for Emacs behavior checking.

** TODO Broken heading without space
***BROKEN Heading

** Code Block
#+BEGIN_SRC emacs-lisp
(message "Hello, Emacs!")
(1+ ) ; Intentional syntax error
#+END_SRC

** Bad Property
:PROPERTIES:
:WRONGPROP without value
:END:

** Notes
Unclosed *bold and /italic text.
2 changes: 1 addition & 1 deletion test/jest/local/mini.pkg.1.el
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

;; Author: Shen, Jen-Chieh <[email protected]>
;; URL: https://github.com/emacs-eask/cli/tree/master/test/fixtures/mini.pkg.1
;; Version: 5.5.6
;; Version: 9.9.10
;; Package-Requires: ((emacs "24.3") (s "1.12.0") (fringe-helper "1.0.1"))
;; Keywords: test local

Expand Down
Loading