@lntvow/eslint-plugin 8.5.0 → 9.3.7
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/dist/index.cjs +16 -0
- package/dist/index.d.cts +5 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.mjs +14 -0
- package/dist/package.json.cjs +7 -0
- package/dist/package.json.mjs +4 -0
- package/dist/src/rules/newline-before.cjs +52 -0
- package/dist/src/rules/newline-before.mjs +50 -0
- package/dist/src/utils/index.cjs +7 -0
- package/dist/src/utils/index.mjs +5 -0
- package/package.json +22 -8
- package/index.js +0 -5
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const _package = require('./package.json.cjs');
|
|
4
|
+
const newlineBefore = require('./src/rules/newline-before.cjs');
|
|
5
|
+
|
|
6
|
+
const plugin = {
|
|
7
|
+
meta: {
|
|
8
|
+
name: _package.name,
|
|
9
|
+
version: _package.version
|
|
10
|
+
},
|
|
11
|
+
rules: {
|
|
12
|
+
"newline-before": newlineBefore
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
module.exports = plugin;
|
package/dist/index.d.cts
ADDED
package/dist/index.d.mts
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { name, version } from './package.json.mjs';
|
|
2
|
+
import newlineBefore from './src/rules/newline-before.mjs';
|
|
3
|
+
|
|
4
|
+
const plugin = {
|
|
5
|
+
meta: {
|
|
6
|
+
name,
|
|
7
|
+
version
|
|
8
|
+
},
|
|
9
|
+
rules: {
|
|
10
|
+
"newline-before": newlineBefore
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { plugin as default };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const index = require('../utils/index.cjs');
|
|
4
|
+
|
|
5
|
+
const newlineBefore = index.createEslintRule({
|
|
6
|
+
meta: {
|
|
7
|
+
type: "layout",
|
|
8
|
+
docs: {
|
|
9
|
+
description: "Enforce newline before specified keywords",
|
|
10
|
+
category: "Stylistic Issues",
|
|
11
|
+
recommended: true,
|
|
12
|
+
url: "https://eslint.org/docs/rules/newline-before"
|
|
13
|
+
},
|
|
14
|
+
messages: {
|
|
15
|
+
newlineBefore: 'Expected newline before "{{ keyword }}"'
|
|
16
|
+
},
|
|
17
|
+
fixable: "whitespace",
|
|
18
|
+
schema: []
|
|
19
|
+
},
|
|
20
|
+
create(context) {
|
|
21
|
+
const { sourceCode } = context;
|
|
22
|
+
function checkNewLineBefore(node) {
|
|
23
|
+
const tokenBefore = sourceCode.getTokenBefore(node);
|
|
24
|
+
if (!tokenBefore)
|
|
25
|
+
return;
|
|
26
|
+
if (tokenBefore.type === "Punctuator" && tokenBefore.value === "{") {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (tokenBefore && tokenBefore.loc.end.line === node.loc.start.line - 1) {
|
|
30
|
+
context.report({
|
|
31
|
+
node,
|
|
32
|
+
message: "Expected at least one empty line before function call.",
|
|
33
|
+
fix(fixer) {
|
|
34
|
+
return fixer.insertTextBefore(node, "\n");
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
CallExpression(node) {
|
|
41
|
+
if (node.callee.type === "Identifier") {
|
|
42
|
+
const calleeName = node.callee.name;
|
|
43
|
+
if (calleeName === "test" || calleeName === "describe") {
|
|
44
|
+
checkNewLineBefore(node);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
module.exports = newlineBefore;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { createEslintRule } from '../utils/index.mjs';
|
|
2
|
+
|
|
3
|
+
const newlineBefore = createEslintRule({
|
|
4
|
+
meta: {
|
|
5
|
+
type: "layout",
|
|
6
|
+
docs: {
|
|
7
|
+
description: "Enforce newline before specified keywords",
|
|
8
|
+
category: "Stylistic Issues",
|
|
9
|
+
recommended: true,
|
|
10
|
+
url: "https://eslint.org/docs/rules/newline-before"
|
|
11
|
+
},
|
|
12
|
+
messages: {
|
|
13
|
+
newlineBefore: 'Expected newline before "{{ keyword }}"'
|
|
14
|
+
},
|
|
15
|
+
fixable: "whitespace",
|
|
16
|
+
schema: []
|
|
17
|
+
},
|
|
18
|
+
create(context) {
|
|
19
|
+
const { sourceCode } = context;
|
|
20
|
+
function checkNewLineBefore(node) {
|
|
21
|
+
const tokenBefore = sourceCode.getTokenBefore(node);
|
|
22
|
+
if (!tokenBefore)
|
|
23
|
+
return;
|
|
24
|
+
if (tokenBefore.type === "Punctuator" && tokenBefore.value === "{") {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (tokenBefore && tokenBefore.loc.end.line === node.loc.start.line - 1) {
|
|
28
|
+
context.report({
|
|
29
|
+
node,
|
|
30
|
+
message: "Expected at least one empty line before function call.",
|
|
31
|
+
fix(fixer) {
|
|
32
|
+
return fixer.insertTextBefore(node, "\n");
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
CallExpression(node) {
|
|
39
|
+
if (node.callee.type === "Identifier") {
|
|
40
|
+
const calleeName = node.callee.name;
|
|
41
|
+
if (calleeName === "test" || calleeName === "describe") {
|
|
42
|
+
checkNewLineBefore(node);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
export { newlineBefore as default };
|
package/package.json
CHANGED
|
@@ -1,16 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lntvow/eslint-plugin",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "eslint
|
|
5
|
-
"
|
|
6
|
-
"keywords": [],
|
|
3
|
+
"version": "9.3.7",
|
|
4
|
+
"description": "eslint-plugin",
|
|
5
|
+
"type": "module",
|
|
7
6
|
"author": "lntvow",
|
|
8
7
|
"license": "MIT",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"eslint",
|
|
10
|
+
"eslint-plugin"
|
|
11
|
+
],
|
|
9
12
|
"files": [
|
|
10
|
-
"
|
|
13
|
+
"dist"
|
|
11
14
|
],
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
+
"main": "./dist/index.cjs",
|
|
16
|
+
"module": "./dist/index.mjs",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"eslint": "^9.0.0"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"unbuild": "^2.0.0"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"dev": "pnpm unbuild --format esm --watch",
|
|
26
|
+
"build": "unbuild",
|
|
27
|
+
"rimraf": "rimraf ./node_modules/",
|
|
28
|
+
"release": "git add . && bumpp package.json --all --commit --no-tag --push"
|
|
15
29
|
}
|
|
16
30
|
}
|