@dataport/eslint-config-geodev 0.3.1 → 0.3.3
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/json.js +21 -0
- package/configs/markdown.js +16 -0
- package/configs/node.js +1 -1
- package/configs/typescript.js +11 -1
- package/configs/vue-pug.js +5 -0
- package/configs/vue.js +14 -0
- package/package.json +10 -2
- package/rules/index.js +7 -0
- package/rules/json-indent.js +115 -0
package/configs/json.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import json from '@eslint/json'
|
|
2
|
+
import dataportGeodev from '../rules/index.js'
|
|
3
|
+
|
|
4
|
+
export default [
|
|
5
|
+
{
|
|
6
|
+
plugins: {
|
|
7
|
+
json,
|
|
8
|
+
},
|
|
9
|
+
language: 'json/json',
|
|
10
|
+
...json.configs.recommended,
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
plugins: {
|
|
14
|
+
'dataport-geodev': dataportGeodev,
|
|
15
|
+
},
|
|
16
|
+
rules: {
|
|
17
|
+
'json/top-level-interop': 'error',
|
|
18
|
+
'dataport-geodev/json-indent': 'error',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
]
|
package/configs/node.js
CHANGED
package/configs/typescript.js
CHANGED
|
@@ -2,8 +2,18 @@ import tseslint from 'typescript-eslint'
|
|
|
2
2
|
import tsdoc from 'eslint-plugin-tsdoc'
|
|
3
3
|
|
|
4
4
|
export default [
|
|
5
|
-
...tseslint.configs.
|
|
5
|
+
...tseslint.configs.strictTypeChecked,
|
|
6
6
|
{
|
|
7
|
+
languageOptions: {
|
|
8
|
+
parserOptions: {
|
|
9
|
+
projectService: true,
|
|
10
|
+
ecmaVersion: 2021,
|
|
11
|
+
sourceType: 'module',
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
files: ['**/*.ts'],
|
|
7
17
|
plugins: {
|
|
8
18
|
tsdoc,
|
|
9
19
|
},
|
package/configs/vue.js
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
import vue from 'eslint-plugin-vue'
|
|
2
|
+
import vueParser from 'vue-eslint-parser'
|
|
3
|
+
import tsParser from '@typescript-eslint/parser'
|
|
2
4
|
|
|
3
5
|
export default [
|
|
4
6
|
...vue.configs['flat/recommended'],
|
|
7
|
+
{
|
|
8
|
+
languageOptions: {
|
|
9
|
+
parser: vueParser,
|
|
10
|
+
parserOptions: {
|
|
11
|
+
parser: {
|
|
12
|
+
js: 'espree',
|
|
13
|
+
ts: tsParser,
|
|
14
|
+
},
|
|
15
|
+
extraFileExtensions: ['.vue'],
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
5
19
|
]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dataport/eslint-config-geodev",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "Generic ESLint configuration for geo development projects at Dataport",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "configs/index.js",
|
|
@@ -9,7 +9,10 @@
|
|
|
9
9
|
"./node": "./configs/node.js",
|
|
10
10
|
"./browser": "./configs/browser.js",
|
|
11
11
|
"./typescript": "./configs/typescript.js",
|
|
12
|
+
"./json": "./configs/json.js",
|
|
13
|
+
"./markdown": "./configs/markdown.js",
|
|
12
14
|
"./vue": "./configs/vue.js",
|
|
15
|
+
"./vue-pug": "./configs/vue-pug.js",
|
|
13
16
|
"./vue2": "./configs/vue2.js"
|
|
14
17
|
},
|
|
15
18
|
"scripts": {
|
|
@@ -28,11 +31,16 @@
|
|
|
28
31
|
"homepage": "https://github.com/Dataport/eslint-config-geodev#readme",
|
|
29
32
|
"dependencies": {
|
|
30
33
|
"@eslint/js": "^9.25.1",
|
|
34
|
+
"@eslint/json": "^0.12.0",
|
|
35
|
+
"@eslint/markdown": "^6.6.0",
|
|
36
|
+
"@typescript-eslint/parser": "^8.34.1",
|
|
31
37
|
"eslint-plugin-tsdoc": "^0.4.0",
|
|
32
38
|
"eslint-plugin-vue": "^10.0.0",
|
|
39
|
+
"eslint-plugin-vue-pug": "^1.0.0-alpha.3",
|
|
33
40
|
"globals": "^16.0.0",
|
|
34
41
|
"neostandard": "^0.12.1",
|
|
35
|
-
"typescript-eslint": "^8.31.0"
|
|
42
|
+
"typescript-eslint": "^8.31.0",
|
|
43
|
+
"vue-eslint-parser": "^10.1.3"
|
|
36
44
|
},
|
|
37
45
|
"devDependencies": {
|
|
38
46
|
"eslint": "^9.25.1"
|
package/rules/index.js
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
meta: {
|
|
3
|
+
type: 'layout',
|
|
4
|
+
docs: {
|
|
5
|
+
description: 'Require proper indentation with tabs in JSON files.',
|
|
6
|
+
},
|
|
7
|
+
fixable: 'whitespace',
|
|
8
|
+
schema: [],
|
|
9
|
+
messages: {
|
|
10
|
+
mixedSpaces: 'Invalid indentation, expected {{ expected }} tabs but found {{ found }} tabs and {{ foundSpaces }} spaces',
|
|
11
|
+
invalidSpaces: 'Invalid indentation, expected {{ expected }} tabs but found {{ found }} spaces',
|
|
12
|
+
invalidDepth: 'Invalid indentation, expected {{ expected }} tabs but found {{ found }} tabs',
|
|
13
|
+
inLine: 'Indentation started within a line?',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
create (context) {
|
|
18
|
+
const text = context.sourceCode.getText()
|
|
19
|
+
let level = 0
|
|
20
|
+
let checkedLine = -1
|
|
21
|
+
|
|
22
|
+
function checkIndentLevel (pos, expected, node) {
|
|
23
|
+
let found = 0
|
|
24
|
+
let foundSpaces = 0
|
|
25
|
+
let x = pos - 1
|
|
26
|
+
for (;; x--) {
|
|
27
|
+
if (x < 0) break
|
|
28
|
+
if (text[x] === '\t') {
|
|
29
|
+
found++
|
|
30
|
+
} else if (text[x] === ' ') {
|
|
31
|
+
foundSpaces++
|
|
32
|
+
} else break
|
|
33
|
+
}
|
|
34
|
+
if (x > -1 && text[x] !== '\n') {
|
|
35
|
+
context.report({
|
|
36
|
+
loc: node.loc,
|
|
37
|
+
messageId: 'inLine',
|
|
38
|
+
})
|
|
39
|
+
return
|
|
40
|
+
}
|
|
41
|
+
function fix (fixer) {
|
|
42
|
+
return fixer.replaceTextRange([x + 1, pos], '\t'.repeat(expected))
|
|
43
|
+
}
|
|
44
|
+
if (foundSpaces > 0 && found > 0) {
|
|
45
|
+
context.report({
|
|
46
|
+
loc: node.loc,
|
|
47
|
+
messageId: 'mixedSpaces',
|
|
48
|
+
data: {
|
|
49
|
+
expected,
|
|
50
|
+
found,
|
|
51
|
+
foundSpaces,
|
|
52
|
+
},
|
|
53
|
+
fix,
|
|
54
|
+
})
|
|
55
|
+
} else if (foundSpaces > 0) {
|
|
56
|
+
context.report({
|
|
57
|
+
loc: node.loc,
|
|
58
|
+
messageId: 'invalidSpaces',
|
|
59
|
+
data: {
|
|
60
|
+
expected,
|
|
61
|
+
found: foundSpaces,
|
|
62
|
+
},
|
|
63
|
+
fix,
|
|
64
|
+
})
|
|
65
|
+
} else if (expected !== found) {
|
|
66
|
+
context.report({
|
|
67
|
+
loc: node.loc,
|
|
68
|
+
messageId: 'invalidDepth',
|
|
69
|
+
data: {
|
|
70
|
+
expected,
|
|
71
|
+
found,
|
|
72
|
+
},
|
|
73
|
+
fix,
|
|
74
|
+
})
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return {
|
|
79
|
+
Object (node) {
|
|
80
|
+
level++
|
|
81
|
+
checkedLine = node.loc.start.line
|
|
82
|
+
},
|
|
83
|
+
'Object:exit' (node) {
|
|
84
|
+
level--
|
|
85
|
+
},
|
|
86
|
+
Member (node) {
|
|
87
|
+
if (checkedLine === node.loc.start.line) return
|
|
88
|
+
checkIndentLevel(node.range[0], level, node)
|
|
89
|
+
checkedLine = node.loc.start.line
|
|
90
|
+
},
|
|
91
|
+
'Member:exit' (node) {
|
|
92
|
+
if (checkedLine === node.loc.end.line) return
|
|
93
|
+
checkIndentLevel(node.range[1] - 1, level, node)
|
|
94
|
+
checkedLine = node.loc.end.line
|
|
95
|
+
},
|
|
96
|
+
Array (node) {
|
|
97
|
+
level++
|
|
98
|
+
checkedLine = node.loc.start.line
|
|
99
|
+
},
|
|
100
|
+
'Array:exit' (node) {
|
|
101
|
+
level--
|
|
102
|
+
},
|
|
103
|
+
Element (node) {
|
|
104
|
+
if (checkedLine === node.loc.start.line) return
|
|
105
|
+
checkIndentLevel(node.value.range[0], level, node)
|
|
106
|
+
checkedLine = node.loc.start.line
|
|
107
|
+
},
|
|
108
|
+
'Element:exit' (node) {
|
|
109
|
+
if (checkedLine === node.loc.end.line) return
|
|
110
|
+
checkIndentLevel(node.value.range[1] - 1, level, node)
|
|
111
|
+
checkedLine = node.loc.end.line
|
|
112
|
+
},
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
}
|