Skip to content

Commit 33c898d

Browse files
committed
Chores: Add JSDoc type checking with TypeScript
1 parent 6f8acee commit 33c898d

File tree

186 files changed

+5327
-2111
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

186 files changed

+5327
-2111
lines changed

Diff for: .eslintrc.js

-18
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,6 @@ module.exports = {
3737
'dot-notation': 'error'
3838
},
3939
overrides: [
40-
// Introduce prettier. but ignore files to avoid conflicts with PR.
41-
{
42-
files: [
43-
// https://github.com/vuejs/eslint-plugin-vue/pull/819
44-
'lib/rules/attributes-order.js',
45-
'tests/lib/rules/attributes-order.js'
46-
],
47-
extends: [
48-
'plugin:eslint-plugin/recommended',
49-
'plugin:vue-libs/recommended'
50-
],
51-
rules: {
52-
'prettier/prettier': 'off',
53-
54-
'rest-spread-spacing': 'error',
55-
'no-mixed-operators': 'error'
56-
}
57-
},
5840
{
5941
files: ['lib/rules/*.js'],
6042
rules: {

Diff for: .vscode/settings.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
"javascript",
88
"javascriptreact",
99
{ "language": "vue", "autoFix": true }
10-
]
10+
],
11+
"typescript.tsdk": "node_modules/typescript/lib"
1112
}

Diff for: lib/processor.js

+13-11
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
*/
1414

1515
module.exports = {
16+
/** @param {string} code */
1617
preprocess(code) {
1718
return [code]
1819
},
@@ -34,6 +35,7 @@ module.exports = {
3435
disableRuleKeys: new Map()
3536
}
3637
}
38+
/** @type {string[]} */
3739
const usedDisableDirectiveKeys = []
3840
/** @type {Map<string,LintMessage>} */
3941
const unusedDisableDirectiveReports = new Map()
@@ -88,15 +90,15 @@ module.exports = {
8890
if (state.line.disableAllKeys.size) {
8991
disableDirectiveKeys.push(...state.line.disableAllKeys)
9092
}
91-
if (state.block.disableRuleKeys.has(message.ruleId)) {
92-
disableDirectiveKeys.push(
93-
...state.block.disableRuleKeys.get(message.ruleId)
94-
)
95-
}
96-
if (state.line.disableRuleKeys.has(message.ruleId)) {
97-
disableDirectiveKeys.push(
98-
...state.line.disableRuleKeys.get(message.ruleId)
99-
)
93+
if (message.ruleId) {
94+
const block = state.block.disableRuleKeys.get(message.ruleId)
95+
if (block) {
96+
disableDirectiveKeys.push(...block)
97+
}
98+
const line = state.line.disableRuleKeys.get(message.ruleId)
99+
if (line) {
100+
disableDirectiveKeys.push(...line)
101+
}
100102
}
101103

102104
if (disableDirectiveKeys.length) {
@@ -153,8 +155,8 @@ function messageToKey(message) {
153155

154156
/**
155157
* Compares the locations of two objects in a source file
156-
* @param {{line: number, column: number}} itemA The first object
157-
* @param {{line: number, column: number}} itemB The second object
158+
* @param {Position} itemA The first object
159+
* @param {Position} itemB The second object
158160
* @returns {number} A value less than 1 if itemA appears before itemB in the source file, greater than 1 if
159161
* itemA appears after itemB in the source file, or 0 if itemA and itemB have the same location.
160162
*/

Diff for: lib/rules/array-bracket-spacing.js

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const { wrapCoreRule } = require('../utils')
77

88
// eslint-disable-next-line no-invalid-meta, no-invalid-meta-docs-categories
99
module.exports = wrapCoreRule(
10+
// @ts-ignore
1011
require('eslint/lib/rules/array-bracket-spacing'),
1112
{ skipDynamicArguments: true }
1213
)

Diff for: lib/rules/arrow-spacing.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@
66
const { wrapCoreRule } = require('../utils')
77

88
// eslint-disable-next-line
9-
module.exports = wrapCoreRule(require('eslint/lib/rules/arrow-spacing'))
9+
module.exports = wrapCoreRule(
10+
// @ts-ignore
11+
require('eslint/lib/rules/arrow-spacing')
12+
)

Diff for: lib/rules/attribute-hyphenation.js

+11-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ module.exports = {
4545
}
4646
]
4747
},
48-
48+
/** @param {RuleContext} context */
4949
create(context) {
5050
const sourceCode = context.getSourceCode()
5151
const option = context.options[0]
@@ -61,6 +61,10 @@ module.exports = {
6161
useHyphenated ? 'kebab-case' : 'camelCase'
6262
)
6363

64+
/**
65+
* @param {VDirective | VAttribute} node
66+
* @param {string} name
67+
*/
6468
function reportIssue(node, name) {
6569
const text = sourceCode.getText(node.key)
6670

@@ -78,6 +82,9 @@ module.exports = {
7882
})
7983
}
8084

85+
/**
86+
* @param {string} value
87+
*/
8188
function isIgnoredAttribute(value) {
8289
const isIgnored = ignoredAttributes.some((attr) => {
8390
return value.indexOf(attr) !== -1
@@ -101,7 +108,9 @@ module.exports = {
101108
const name = !node.directive
102109
? node.key.rawName
103110
: node.key.name.name === 'bind'
104-
? node.key.argument && node.key.argument.rawName
111+
? node.key.argument &&
112+
node.key.argument.type === 'VIdentifier' &&
113+
node.key.argument.rawName
105114
: /* otherwise */ false
106115
if (!name || isIgnoredAttribute(name)) return
107116

0 commit comments

Comments
 (0)