@sektek/eslint-plugin 2.0.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/configs/recommended.js +14 -2
- package/configs/typescript.js +3 -0
- package/package.json +3 -2
- package/test/require-jsdoc.spec.js +49 -0
package/configs/recommended.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
+
import checkFile from 'eslint-plugin-check-file';
|
|
1
2
|
import { globalIgnores } from 'eslint/config';
|
|
2
3
|
import globals from 'globals';
|
|
3
|
-
|
|
4
|
-
import checkFile from 'eslint-plugin-check-file';
|
|
5
4
|
import importPlugin from 'eslint-plugin-import';
|
|
6
5
|
import js from '@eslint/js';
|
|
7
6
|
import jsdoc from 'eslint-plugin-jsdoc';
|
|
@@ -48,6 +47,19 @@ export default [
|
|
|
48
47
|
{ '**/*\\.{js,ts}': 'KEBAB_CASE' },
|
|
49
48
|
],
|
|
50
49
|
'import/newline-after-import': 'error',
|
|
50
|
+
'import/order': [
|
|
51
|
+
'error',
|
|
52
|
+
{
|
|
53
|
+
groups: [
|
|
54
|
+
'builtin',
|
|
55
|
+
['external', 'internal'],
|
|
56
|
+
'parent',
|
|
57
|
+
['sibling', 'index'],
|
|
58
|
+
],
|
|
59
|
+
'newlines-between': 'always',
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
'jsdoc/require-jsdoc': ['error', { publicOnly: true }],
|
|
51
63
|
'jsdoc/tag-lines': ['error', 'any', { startLines: 1, maxBlockLines: 1 }],
|
|
52
64
|
'mocha/no-exclusive-tests': 'error',
|
|
53
65
|
'no-console': 'error',
|
package/configs/typescript.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sektek/eslint-plugin",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "Eslint configuration for all @sektek projects",
|
|
5
5
|
"author": "Edward Kelly <eddie@sektek.net>",
|
|
6
6
|
"repository": {
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
"type": "module",
|
|
13
13
|
"main": "index.js",
|
|
14
14
|
"scripts": {
|
|
15
|
-
"lint": "eslint ."
|
|
15
|
+
"lint": "eslint .",
|
|
16
|
+
"test": "node --test 'test/**/*.spec.js'"
|
|
16
17
|
},
|
|
17
18
|
"dependencies": {
|
|
18
19
|
"@sektek/prettier-config": "^2",
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { describe, it } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
|
|
4
|
+
import { ESLint } from 'eslint';
|
|
5
|
+
import { defineConfig } from 'eslint/config';
|
|
6
|
+
|
|
7
|
+
import sektek from '../index.js';
|
|
8
|
+
|
|
9
|
+
const lint = async (config, code, filePath) => {
|
|
10
|
+
const eslint = new ESLint({
|
|
11
|
+
overrideConfigFile: true,
|
|
12
|
+
overrideConfig: defineConfig(config),
|
|
13
|
+
cwd: process.cwd(),
|
|
14
|
+
});
|
|
15
|
+
const [result] = await eslint.lintText(code, { filePath });
|
|
16
|
+
return result.messages.filter(m => m.ruleId === 'jsdoc/require-jsdoc');
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const cases = [
|
|
20
|
+
{
|
|
21
|
+
name: 'recommended',
|
|
22
|
+
config: sektek.configs.recommended,
|
|
23
|
+
file: 'src/sample.js',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: 'typescript',
|
|
27
|
+
config: sektek.configs.typescript,
|
|
28
|
+
file: 'src/sample.ts',
|
|
29
|
+
},
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
for (const { name, config, file } of cases) {
|
|
33
|
+
describe(`${name} jsdoc/require-jsdoc`, () => {
|
|
34
|
+
it('allows an unexported function without JSDoc', async () => {
|
|
35
|
+
const messages = await lint(
|
|
36
|
+
config,
|
|
37
|
+
'function helper() {}\nhelper();\n',
|
|
38
|
+
file,
|
|
39
|
+
);
|
|
40
|
+
assert.deepEqual(messages, []);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('requires JSDoc on an exported function', async () => {
|
|
44
|
+
const messages = await lint(config, 'export function api() {}\n', file);
|
|
45
|
+
assert.equal(messages.length, 1);
|
|
46
|
+
assert.equal(messages[0].severity, 2);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
}
|