Skip to content

Commit 62d97bf

Browse files
mysticateamichalsnik
authored andcommitted
Fix: don't use internal APIs of ESLint (fixes #171) (#172)
* Fix: don't use internal APIs of ESLint (fixes #171) * Chore: add tests with old ESLint
1 parent 85137c9 commit 62d97bf

Some content is hidden

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

45 files changed

+54
-137
lines changed

circle.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ machine:
44

55
dependencies:
66
pre:
7-
- nvm install 7
7+
- nvm install 6
88
- nvm install 8
99

1010
test:
1111
override:
12-
- npm test
12+
- nvm use 4 && npm test
1313
- nvm use 6 && npm test
14-
- nvm use 7 && npm test
1514
- nvm use 8 && npm test
15+
- nvm use 8 && npm i [email protected] --no-save && npm run -s test:base

lib/rules/attribute-hyphenation.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function create (context) {
4343
// Public
4444
// ----------------------------------------------------------------------
4545

46-
utils.registerTemplateBodyVisitor(context, {
46+
return utils.defineTemplateBodyVisitor(context, {
4747
VAttribute (node) {
4848
if (!utils.isCustomComponent(node.parent.parent)) return
4949

@@ -53,8 +53,6 @@ function create (context) {
5353
reportIssue(node, name)
5454
}
5555
})
56-
57-
return {}
5856
}
5957

6058
module.exports = {

lib/rules/html-end-tags.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const utils = require('../utils')
2222
* @returns {Object} AST event handlers.
2323
*/
2424
function create (context) {
25-
utils.registerTemplateBodyVisitor(context, {
25+
return utils.defineTemplateBodyVisitor(context, {
2626
VElement (node) {
2727
const name = node.name
2828
const isVoid = utils.isHtmlVoidElementName(name)
@@ -48,8 +48,6 @@ function create (context) {
4848
}
4949
}
5050
})
51-
52-
return {}
5351
}
5452

5553
// ------------------------------------------------------------------------------

lib/rules/html-no-self-closing.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const utils = require('../utils')
2222
* @returns {Object} AST event handlers.
2323
*/
2424
function create (context) {
25-
utils.registerTemplateBodyVisitor(context, {
25+
return utils.defineTemplateBodyVisitor(context, {
2626
'VElement' (node) {
2727
if (utils.isSvgElementNode(node)) {
2828
return
@@ -42,8 +42,6 @@ function create (context) {
4242
})
4343
}
4444
})
45-
46-
return {}
4745
}
4846

4947
// ------------------------------------------------------------------------------

lib/rules/html-quotes.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function create (context) {
2727
const quoteChar = double ? '"' : "'"
2828
const quoteName = double ? 'double quotes' : 'single quotes'
2929

30-
utils.registerTemplateBodyVisitor(context, {
30+
return utils.defineTemplateBodyVisitor(context, {
3131
'VAttribute[value!=null]' (node) {
3232
const text = sourceCode.getText(node.value)
3333
const firstChar = text[0]
@@ -41,8 +41,6 @@ function create (context) {
4141
}
4242
}
4343
})
44-
45-
return {}
4644
}
4745

4846
// ------------------------------------------------------------------------------

lib/rules/html-self-closing.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ function create (context) {
8989
const sourceCode = context.getSourceCode()
9090
const options = parseOptions(context.options[0])
9191

92-
utils.registerTemplateBodyVisitor(context, {
92+
return utils.defineTemplateBodyVisitor(context, {
9393
'VElement' (node) {
9494
const elementType = getElementType(node)
9595
const mode = options[elementType]
@@ -132,8 +132,6 @@ function create (context) {
132132
}
133133
}
134134
})
135-
136-
return {}
137135
}
138136

139137
// ------------------------------------------------------------------------------

lib/rules/max-attributes-per-line.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ module.exports = {
7171
const singlelinemMaximum = configuration.singleline
7272
const canHaveFirstLine = configuration.allowFirstLine
7373

74-
utils.registerTemplateBodyVisitor(context, {
74+
return utils.defineTemplateBodyVisitor(context, {
7575
'VStartTag' (node) {
7676
const numberOfAttributes = node.attributes.length
7777

@@ -155,7 +155,5 @@ module.exports = {
155155

156156
return propsPerLine
157157
}
158-
159-
return {}
160158
}
161159
}

lib/rules/mustache-interpolation-spacing.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ module.exports = {
6565
// Public
6666
// ----------------------------------------------------------------------
6767

68-
utils.registerTemplateBodyVisitor(context, {
68+
return utils.defineTemplateBodyVisitor(context, {
6969
'VExpressionContainer[expression!=null]' (node) {
7070
const tokens = template.getTokens(node, {
7171
includeComments: true,
@@ -85,7 +85,5 @@ module.exports = {
8585
}
8686
}
8787
})
88-
89-
return { }
9088
}
9189
}

lib/rules/no-confusing-v-for-v-if.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function isUsingIterationVar (vIf) {
3737
* @returns {Object} AST event handlers.
3838
*/
3939
function create (context) {
40-
utils.registerTemplateBodyVisitor(context, {
40+
return utils.defineTemplateBodyVisitor(context, {
4141
"VAttribute[directive=true][key.name='if']" (node) {
4242
const element = node.parent.parent
4343

@@ -50,8 +50,6 @@ function create (context) {
5050
}
5151
}
5252
})
53-
54-
return {}
5553
}
5654

5755
// ------------------------------------------------------------------------------

lib/rules/no-duplicate-attributes.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function create (context) {
5151
return directiveNames.has(name) || attributeNames.has(name)
5252
}
5353

54-
utils.registerTemplateBodyVisitor(context, {
54+
return utils.defineTemplateBodyVisitor(context, {
5555
'VStartTag' () {
5656
directiveNames.clear()
5757
attributeNames.clear()
@@ -78,8 +78,6 @@ function create (context) {
7878
}
7979
}
8080
})
81-
82-
return {}
8381
}
8482

8583
// ------------------------------------------------------------------------------

lib/rules/no-invalid-v-bind.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const VALID_MODIFIERS = new Set(['prop', 'camel', 'sync'])
2424
* @returns {Object} AST event handlers.
2525
*/
2626
function create (context) {
27-
utils.registerTemplateBodyVisitor(context, {
27+
return utils.defineTemplateBodyVisitor(context, {
2828
"VAttribute[directive=true][key.name='bind']" (node) {
2929
for (const modifier of node.key.modifiers) {
3030
if (!VALID_MODIFIERS.has(modifier)) {
@@ -46,8 +46,6 @@ function create (context) {
4646
}
4747
}
4848
})
49-
50-
return {}
5149
}
5250

5351
// ------------------------------------------------------------------------------

lib/rules/no-invalid-v-cloak.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const utils = require('../utils')
2222
* @returns {Object} AST event handlers.
2323
*/
2424
function create (context) {
25-
utils.registerTemplateBodyVisitor(context, {
25+
return utils.defineTemplateBodyVisitor(context, {
2626
"VAttribute[directive=true][key.name='cloak']" (node) {
2727
if (node.key.argument) {
2828
context.report({
@@ -47,8 +47,6 @@ function create (context) {
4747
}
4848
}
4949
})
50-
51-
return {}
5250
}
5351

5452
// ------------------------------------------------------------------------------

lib/rules/no-invalid-v-else-if.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const utils = require('../utils')
2222
* @returns {Object} AST event handlers.
2323
*/
2424
function create (context) {
25-
utils.registerTemplateBodyVisitor(context, {
25+
return utils.defineTemplateBodyVisitor(context, {
2626
"VAttribute[directive=true][key.name='else-if']" (node) {
2727
const element = node.parent.parent
2828

@@ -70,8 +70,6 @@ function create (context) {
7070
}
7171
}
7272
})
73-
74-
return {}
7573
}
7674

7775
// ------------------------------------------------------------------------------

lib/rules/no-invalid-v-else.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const utils = require('../utils')
2222
* @returns {Object} AST event handlers.
2323
*/
2424
function create (context) {
25-
utils.registerTemplateBodyVisitor(context, {
25+
return utils.defineTemplateBodyVisitor(context, {
2626
"VAttribute[directive=true][key.name='else']" (node) {
2727
const element = node.parent.parent
2828

@@ -70,8 +70,6 @@ function create (context) {
7070
}
7171
}
7272
})
73-
74-
return {}
7573
}
7674

7775
// ------------------------------------------------------------------------------

lib/rules/no-invalid-v-for.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ function checkKey (context, vFor, element) {
7979
function create (context) {
8080
const sourceCode = context.getSourceCode()
8181

82-
utils.registerTemplateBodyVisitor(context, {
82+
return utils.defineTemplateBodyVisitor(context, {
8383
"VAttribute[directive=true][key.name='for']" (node) {
8484
const element = node.parent.parent
8585

@@ -151,8 +151,6 @@ function create (context) {
151151
}
152152
}
153153
})
154-
155-
return {}
156154
}
157155

158156
// ------------------------------------------------------------------------------

lib/rules/no-invalid-v-html.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const utils = require('../utils')
2222
* @returns {Object} AST event handlers.
2323
*/
2424
function create (context) {
25-
utils.registerTemplateBodyVisitor(context, {
25+
return utils.defineTemplateBodyVisitor(context, {
2626
"VAttribute[directive=true][key.name='html']" (node) {
2727
if (node.key.argument) {
2828
context.report({
@@ -47,8 +47,6 @@ function create (context) {
4747
}
4848
}
4949
})
50-
51-
return {}
5250
}
5351

5452
// ------------------------------------------------------------------------------

lib/rules/no-invalid-v-if.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const utils = require('../utils')
2222
* @returns {Object} AST event handlers.
2323
*/
2424
function create (context) {
25-
utils.registerTemplateBodyVisitor(context, {
25+
return utils.defineTemplateBodyVisitor(context, {
2626
"VAttribute[directive=true][key.name='if']" (node) {
2727
const element = node.parent.parent
2828

@@ -63,8 +63,6 @@ function create (context) {
6363
}
6464
}
6565
})
66-
67-
return {}
6866
}
6967

7068
// ------------------------------------------------------------------------------

lib/rules/no-invalid-v-model.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ function getVariable (name, leafNode) {
8080
* @returns {Object} AST event handlers.
8181
*/
8282
function create (context) {
83-
utils.registerTemplateBodyVisitor(context, {
83+
return utils.defineTemplateBodyVisitor(context, {
8484
"VAttribute[directive=true][key.name='model']" (node) {
8585
const element = node.parent.parent
8686
const name = element.name
@@ -164,8 +164,6 @@ function create (context) {
164164
}
165165
}
166166
})
167-
168-
return {}
169167
}
170168

171169
// ------------------------------------------------------------------------------

lib/rules/no-invalid-v-on.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const VERB_MODIFIERS = new Set([
3131
* @returns {Object} AST event handlers.
3232
*/
3333
function create (context) {
34-
utils.registerTemplateBodyVisitor(context, {
34+
return utils.defineTemplateBodyVisitor(context, {
3535
"VAttribute[directive=true][key.name='on']" (node) {
3636
for (const modifier of node.key.modifiers) {
3737
if (!VALID_MODIFIERS.has(modifier) && !Number.isInteger(parseInt(modifier, 10))) {
@@ -52,8 +52,6 @@ function create (context) {
5252
}
5353
}
5454
})
55-
56-
return {}
5755
}
5856

5957
// ------------------------------------------------------------------------------

lib/rules/no-invalid-v-once.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const utils = require('../utils')
2222
* @returns {Object} AST event handlers.
2323
*/
2424
function create (context) {
25-
utils.registerTemplateBodyVisitor(context, {
25+
return utils.defineTemplateBodyVisitor(context, {
2626
"VAttribute[directive=true][key.name='once']" (node) {
2727
if (node.key.argument) {
2828
context.report({
@@ -47,8 +47,6 @@ function create (context) {
4747
}
4848
}
4949
})
50-
51-
return {}
5250
}
5351

5452
// ------------------------------------------------------------------------------

lib/rules/no-invalid-v-pre.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const utils = require('../utils')
2222
* @returns {Object} AST event handlers.
2323
*/
2424
function create (context) {
25-
utils.registerTemplateBodyVisitor(context, {
25+
return utils.defineTemplateBodyVisitor(context, {
2626
"VAttribute[directive=true][key.name='pre']" (node) {
2727
if (node.key.argument) {
2828
context.report({
@@ -47,8 +47,6 @@ function create (context) {
4747
}
4848
}
4949
})
50-
51-
return {}
5250
}
5351

5452
// ------------------------------------------------------------------------------

lib/rules/no-invalid-v-show.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const utils = require('../utils')
2222
* @returns {Object} AST event handlers.
2323
*/
2424
function create (context) {
25-
utils.registerTemplateBodyVisitor(context, {
25+
return utils.defineTemplateBodyVisitor(context, {
2626
"VAttribute[directive=true][key.name='show']" (node) {
2727
if (node.key.argument) {
2828
context.report({
@@ -47,8 +47,6 @@ function create (context) {
4747
}
4848
}
4949
})
50-
51-
return {}
5250
}
5351

5452
// ------------------------------------------------------------------------------

0 commit comments

Comments
 (0)