eslint-plugin-vuetify
Advanced tools
Comparing version 1.0.0-beta.6 to 1.0.0-beta.7
'use strict' | ||
const loadModule = require('../util/load-module') | ||
const { hyphenate, classify, isBuiltinAttribute } = require('../util/helpers') | ||
const { hyphenate, classify, getAttributes } = require('../util/helpers') | ||
const { isGridAttribute } = require('../util/grid-attributes') | ||
const { addClass, removeAttr } = require('../util/fixers') | ||
@@ -38,10 +39,4 @@ const VGrid = { | ||
const attributes = element.startTag.attributes.filter(node => { | ||
if (node.directive && (node.key.name !== 'bind' || !node.key.argument)) return | ||
const name = hyphenate(node.directive ? node.key.argument : node.key.rawName) | ||
return !isBuiltinAttribute(name) && | ||
!tags[tag].includes(name) && | ||
!isGridAttribute(tag, name) | ||
const attributes = getAttributes(element).filter(({ name }) => { | ||
return !tags[tag].includes(name) && !isGridAttribute(tag, name) | ||
}) | ||
@@ -53,8 +48,9 @@ | ||
loc: { | ||
start: attributes[0].loc.start, | ||
end: attributes[attributes.length - 1].loc.end | ||
start: attributes[0].node.loc.start, | ||
end: attributes[attributes.length - 1].node.loc.end | ||
}, | ||
message: 'Attributes are no longer converted into classes', | ||
fix (fixer) { | ||
const fixableAttrs = attributes.filter(attr => !attr.directive) | ||
const fixableAttrs = attributes.map(({ node }) => node) | ||
.filter(attr => !attr.directive) | ||
@@ -64,25 +60,6 @@ if (!fixableAttrs.length) return | ||
const className = fixableAttrs.map(node => node.key.rawName).join(' ') | ||
const source = context.getSourceCode().text | ||
const removeAttrs = fixableAttrs.map(node => { | ||
let [start, end] = node.range | ||
// Also remove whitespace after attributes | ||
if (/\s/.test(source[end])) ++end | ||
return fixer.removeRange([start, end]) | ||
}) | ||
const classNode = element.startTag.attributes.find(attr => attr.key.name === 'class') | ||
if (classNode) { | ||
return [ | ||
fixer.replaceText(classNode.value, `"${classNode.value.value} ${className}"`), | ||
...removeAttrs | ||
] | ||
} else { | ||
return [ | ||
fixer.insertTextAfter( | ||
context.parserServices.getTemplateBodyTokenStore().getFirstToken(element.startTag), | ||
` class="${className}"` | ||
), | ||
...removeAttrs | ||
] | ||
} | ||
return [ | ||
addClass(context, fixer, element, className), | ||
...fixableAttrs.map(removeAttr.bind(this, context, fixer)) | ||
] | ||
} | ||
@@ -89,0 +66,0 @@ }) |
'use strict' | ||
const { classify, getAttributes } = require('../util/helpers') | ||
const { removeAttr } = require('../util/fixers') | ||
@@ -101,9 +102,3 @@ // const spacers = { | ||
fix (fixer) { | ||
if (attr.node.directive) return | ||
const source = context.getSourceCode().text | ||
let [start, end] = attr.node.range | ||
// Also remove whitespace after attributes | ||
if (/\s/.test(source[end])) ++end | ||
return fixer.removeRange([start, end]) | ||
if (!attr.node.directive) return removeAttr(context, fixer, attr.node) | ||
} | ||
@@ -110,0 +105,0 @@ }) |
@@ -17,3 +17,3 @@ 'use strict' | ||
[/^justify-(start|center|end|space-around|space-between)$/, ([align]) => `justify="${align}"`], | ||
[/^justify-between$/, () => 'justify="space-between"'], | ||
[/^(justify-between)$/, () => 'justify="space-between"'], | ||
[/^(row)$/, () => ''], | ||
@@ -55,3 +55,3 @@ [/^(wrap)$/, () => ''], | ||
const tokens = context.parserServices.getTemplateBodyTokenStore() | ||
if (replacements.components.hasOwnProperty(tag)) { | ||
if (Object.prototype.hasOwnProperty.call(replacements.components, tag)) { | ||
const replacement = replacements.components[tag] | ||
@@ -95,3 +95,4 @@ context.report({ | ||
} | ||
context.report(Object.assign({}, message, { | ||
context.report({ | ||
...message, | ||
node: attr.node, | ||
@@ -102,3 +103,3 @@ fix (fixer) { | ||
} | ||
})) | ||
}) | ||
} | ||
@@ -105,0 +106,0 @@ } |
'use strict' | ||
function hyphenate (str = '') { | ||
function hyphenate ( | ||
/* istanbul ignore next */ | ||
str = '' | ||
) { | ||
return str.replace(/\B([A-Z])/g, '-$1').toLowerCase() | ||
@@ -27,9 +30,10 @@ } | ||
const attrs = [] | ||
element.startTag.attributes.forEach(node => { | ||
if (node.directive && (node.key.name !== 'bind' || !node.key.argument)) return | ||
if (node.directive && (node.key.name.name !== 'bind' || !node.key.argument)) return | ||
const name = hyphenate(node.directive ? node.key.argument : node.key.rawName) | ||
if (isBuiltinAttribute(name)) return | ||
attrs.push({ name, node }) | ||
const name = hyphenate(node.directive ? node.key.argument.name : node.key.rawName) | ||
if (!isBuiltinAttribute(name)) attrs.push({ name, node }) | ||
}) | ||
return attrs | ||
@@ -36,0 +40,0 @@ } |
{ | ||
"name": "eslint-plugin-vuetify", | ||
"version": "1.0.0-beta.6", | ||
"version": "1.0.0-beta.7", | ||
"description": "An eslint plugin for Vuetify", | ||
"main": "lib/index.js", | ||
@@ -8,6 +9,13 @@ "author": "Kael Watts-Deuchar <kaelwd@gmail.com>", | ||
"repository": "github:vuetifyjs/eslint-plugin-vuetify", | ||
"husky": { | ||
"hooks": { | ||
"commit-msg": "node scripts/lint-commit-message.js", | ||
"pre-commit": "node scripts/warn-npm-install.js && yarn run lint && yarn run test" | ||
} | ||
}, | ||
"scripts": { | ||
"test": "mocha tests --recursive --reporter dot", | ||
"test:coverage": "nyc mocha tests --recursive --reporter dot", | ||
"lint": "eslint ." | ||
"test:ci": "nyc --reporter=lcov mocha tests --recursive --reporter dot", | ||
"lint": "eslint lib tests" | ||
}, | ||
@@ -17,34 +25,24 @@ "files": [ | ||
], | ||
"homepage": "https://github.com/vuetifyjs/eslint-plugin-vuetify#readme", | ||
"dependencies": { | ||
"eslint-plugin-vue": "^6.0.0", | ||
"eslint-plugin-vue": "^6.2.2", | ||
"requireindex": "^1.2.0" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^6.0.1", | ||
"eslint-config-standard": "^12.0.0", | ||
"eslint-plugin-import": "^2.18.0", | ||
"eslint-plugin-node": "^9.1.0", | ||
"eslint": "^7.4.0", | ||
"eslint-config-standard": "^14.1.1", | ||
"eslint-plugin-import": "^2.22.0", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-promise": "^4.2.1", | ||
"eslint-plugin-standard": "^4.0.0", | ||
"mocha": "^6.1.4", | ||
"nyc": "^14.1.1", | ||
"vue": "^2.6.10", | ||
"vuetify": "^2.1.0" | ||
"eslint-plugin-standard": "^4.0.1", | ||
"husky": "^4.2.5", | ||
"mocha": "^8.0.1", | ||
"nyc": "^15.1.0", | ||
"vue": "^2.6.11", | ||
"vuetify": "^2.3.4" | ||
}, | ||
"peerDependencies": { | ||
"eslint": "^6.0.0", | ||
"eslint": "^6.0.0 | ^7.0.0", | ||
"vuetify": "^2.0.0" | ||
}, | ||
"release-it": { | ||
"git": { | ||
"commitMessage": "chore: release v%s", | ||
"tagName": "v%s" | ||
}, | ||
"npm": { | ||
"publish": true | ||
}, | ||
"github": { | ||
"release": true | ||
} | ||
} | ||
} |
@@ -17,2 +17,5 @@ # eslint-plugin-vuetify (WIP) | ||
### 💿 Install | ||
You should have [`eslint`](https://eslint.org/docs/user-guide/getting-started) and [`eslint-plugin-vue`](https://eslint.vuejs.org/user-guide/#installation) set up first. | ||
```bash | ||
@@ -27,2 +30,5 @@ yarn add eslint-plugin-vuetify -D | ||
module.exports = { | ||
extends: [ | ||
'plugin:vue/base' | ||
], | ||
plugins: [ | ||
@@ -29,0 +35,0 @@ 'vuetify' |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
19524
13
413
1
81
11
+ Added@eslint-community/eslint-utils@4.4.0(transitive)
+ Added@eslint-community/regexpp@4.11.1(transitive)
+ Added@eslint/config-array@0.18.0(transitive)
+ Added@eslint/core@0.6.0(transitive)
+ Added@eslint/eslintrc@3.1.0(transitive)
+ Added@eslint/js@9.11.1(transitive)
+ Added@eslint/object-schema@2.1.4(transitive)
+ Added@eslint/plugin-kit@0.2.0(transitive)
+ Added@humanwhocodes/module-importer@1.0.1(transitive)
+ Added@humanwhocodes/retry@0.3.0(transitive)
+ Added@nodelib/fs.scandir@2.1.5(transitive)
+ Added@nodelib/fs.stat@2.0.5(transitive)
+ Added@nodelib/fs.walk@1.2.8(transitive)
+ Added@types/estree@1.0.6(transitive)
+ Added@types/json-schema@7.0.15(transitive)
+ Addedacorn@8.12.1(transitive)
+ Addedargparse@2.0.1(transitive)
+ Addedcross-spawn@7.0.3(transitive)
+ Addedescape-string-regexp@4.0.0(transitive)
+ Addedeslint@9.11.1(transitive)
+ Addedeslint-scope@8.1.0(transitive)
+ Addedeslint-visitor-keys@3.4.34.1.0(transitive)
+ Addedespree@10.2.0(transitive)
+ Addedfastq@1.17.1(transitive)
+ Addedfile-entry-cache@8.0.0(transitive)
+ Addedfind-up@5.0.0(transitive)
+ Addedflat-cache@4.0.1(transitive)
+ Addedflatted@3.3.1(transitive)
+ Addedglob-parent@6.0.2(transitive)
+ Addedglobals@14.0.0(transitive)
+ Addedignore@5.3.2(transitive)
+ Addedis-path-inside@3.0.3(transitive)
+ Addedjs-yaml@4.1.0(transitive)
+ Addedjson-buffer@3.0.1(transitive)
+ Addedkeyv@4.5.4(transitive)
+ Addedlevn@0.4.1(transitive)
+ Addedlocate-path@6.0.0(transitive)
+ Addedlodash.merge@4.6.2(transitive)
+ Addedoptionator@0.9.4(transitive)
+ Addedp-limit@3.1.0(transitive)
+ Addedp-locate@5.0.0(transitive)
+ Addedpath-exists@4.0.0(transitive)
+ Addedpath-key@3.1.1(transitive)
+ Addedprelude-ls@1.2.1(transitive)
+ Addedqueue-microtask@1.2.3(transitive)
+ Addedreusify@1.0.4(transitive)
+ Addedrun-parallel@1.2.0(transitive)
+ Addedshebang-command@2.0.0(transitive)
+ Addedshebang-regex@3.0.0(transitive)
+ Addedtype-check@0.4.0(transitive)
+ Addedwhich@2.0.2(transitive)
+ Addedyocto-queue@0.1.0(transitive)
Updatedeslint-plugin-vue@^6.2.2