@hireupau/eslint-plugin-hu-vue
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -1,2 +0,2 @@ | ||
const configs = require('./config'); | ||
const configs = require('./configs'); | ||
const rules = require('./rules'); | ||
@@ -3,0 +3,0 @@ |
{ | ||
"name": "@hireupau/eslint-plugin-hu-vue", | ||
"version": "0.0.5", | ||
"description": "Hireups vue eslint rules", | ||
"version": "0.0.6", | ||
"description": "Hireup's vue eslint rules", | ||
"main": "index.js", | ||
@@ -6,0 +6,0 @@ "scripts": { |
@@ -0,5 +1,7 @@ | ||
const sortComponentRegistrations = require('./sort-component-registrations'); | ||
const sortPropDefinitions = require('./sort-prop-definitions'); | ||
module.exports = { | ||
'sort-component-registrations': sortComponentRegistrations, | ||
'sort-prop-definitions': sortPropDefinitions, | ||
}; |
@@ -14,11 +14,6 @@ /** | ||
const propsAreSortedCorrectly = (props) => { | ||
const propsAreSortedCorrectly = (obj) => { | ||
const props = utils.getComponentProps(obj); | ||
const propNames = utils.getPropNames(props); | ||
const sortedPropNames = Array.from(propNames).sort((a, b) => a.localeCompare(b)); | ||
for(let i = 0; i < propNames.length; i++) { | ||
if (propNames[i] !== sortedPropNames[i]) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
return utils.areStringsSortedAlphabetically(propNames); | ||
}; | ||
@@ -34,12 +29,5 @@ | ||
return utils.executeOnVue(context, function(obj) { | ||
const props = utils.getComponentProps(obj); | ||
if (!propsAreSortedCorrectly(props)) { | ||
const propsNode = obj.properties | ||
.find(p => | ||
p.type === 'Property' && | ||
p.key.type === 'Identifier' && | ||
p.key.name === 'props' && | ||
(p.value.type === 'ObjectExpression' || p.value.type === 'ArrayExpression') | ||
); | ||
if (!propsAreSortedCorrectly(obj)) { | ||
const propsNode = utils | ||
.findNode(obj, 'props', ['ObjectExpression', 'ArrayExpression']); | ||
context.report({ | ||
@@ -46,0 +34,0 @@ node: propsNode, |
const vueUtils = require('eslint-plugin-vue/lib/utils'); | ||
const areStringsSortedAlphabetically = values => { | ||
if (values && values.length) { | ||
const sortedValues = Array.from(values) | ||
.sort((a, b) => a.localeCompare(b)); | ||
for(let i = 0; i < values.length; i++) { | ||
if (values[i] !== sortedValues[i]) { | ||
return false; | ||
} | ||
} | ||
} | ||
return true; | ||
}; | ||
const findNode = (node, name, type) => ( | ||
node.properties.find(p => | ||
p.type === 'Property' && | ||
p.key.type === 'Identifier' && | ||
p.key.name === name && | ||
((type.length && type.includes(p.value.type)) || p.value.type === type) | ||
) | ||
); | ||
const getPropNames = props => ( | ||
@@ -13,3 +36,5 @@ props.map( | ||
...vueUtils, | ||
areStringsSortedAlphabetically, | ||
findNode, | ||
getPropNames, | ||
}; |
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
7669
10
278