Skip to content

Add rule max-attributes-per-line (resolves #47) #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Aug 15, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/rules/max-attributes-per-line.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ module.exports = {
context.report({
node,
loc: node.loc,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think better if this rule reports the violated attributes instead of elements which have the violated attributes.
This is consistent with the core rules which have similar functionally.

/*eslint 
    max-statements-per-line: error,
    newline-per-chained-call: error,
    object-property-newline: error,
    array-element-newline: error
 */

aaa(); bbb(); ccc();
test.aaa().bbb().ccc().ddd()
var obj = {aaa:1, bbb:2, ccc:3}
var ary = [1, 2, 3]

image

message: 'It has more than {{singlelinemMaximum}} attributes per line.',
message: 'There are {{numberOfAttributes}} in this line, but the maximum is {{singlelinemMaximum}}.',
data: {
numberOfAttributes,
singlelinemMaximum
}
})
Expand Down
4 changes: 2 additions & 2 deletions tests/lib/rules/max-attributes-per-line.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ ruleTester.run('max-attributes-per-line', rule, {
invalid: [
{
code: `<template><component name="John Doe" age="30" job="Vet" petname="Snoopy"></component></template>`,
errors: ['It has more than 3 attributes per line.']
errors: ['There are 4 in this line, but the maximum is 3.']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add attributes keyword to the message :) So it says:
There are 4 attributes in this line, but the maximum is 3.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦‍♀️

},
{
code: `<template><component job="Vet"
Expand All @@ -84,7 +84,7 @@ ruleTester.run('max-attributes-per-line', rule, {
{
code: `<template><component name="John Doe" age="30" job="Vet"></component></template>`,
options: [{ singleline: 1, multiline: { max: 1, allowFirstLine: false }}],
errors: ['It has more than 1 attributes per line.']
errors: ['There are 3 in this line, but the maximum is 1.']
},
{
code: `<template><component name="John Doe"
Expand Down