Skip to content
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

Add more rules #3

Closed
27 of 32 tasks
benedfit opened this issue Jul 9, 2015 · 4 comments
Closed
27 of 32 tasks

Add more rules #3

benedfit opened this issue Jul 9, 2015 · 4 comments

Comments

@benedfit
Copy link
Contributor

benedfit commented Jul 9, 2015

Definite:

  • attributeSeparator: " " / "," / ", " / " ," / " , "
  • spaceAfterCodeOperator: require/disallow (now 2 rules)
  • idLiterals: require/disallow (now 2 disallow rules for ID literals and class literals)
  • quoteMarks: single/double/first one found
  • disallowDuplicateAttributes: true
  • disallowBlockExpansion: true
  • disallowTagInterpolation: true
  • disallowHtmlText: true
  • literalsBeforeAttributes: require/disallow (has been refactored into multiple rules for class>attr, id>attr & class>id)
  • disallowStringInterpolation: true
  • disallowStringConcatenation: true
  • requireLineFeedAtFileEnd: true
  • disallow[Class/Id]AtributeWithStaticValue: true
  • maximumLineLength: int
  • maximumNumberOfLines: int
  • disallowImplicitDiv: true
  • validateIndentation: number, "\t"
  • validateLineBreaks: "CR", "LF", "CRLF"
  • lint/check style of JS using: jshint, jscs, eslint, etc
  • requireLowerCaseTags: true
  • requireLowerCaseAttributes: true
  • validateSelfClosingTags: true
  • disallowMultipleLineBreaks: true
  • disallowSpecifcTags: array of tag names
  • disallowSpecificAttributes: array of tag names and attrs that should not exist
  • requireSpecificAttributes: array of tag names and attrs that must exist
  • validateAttributeValue: array of tag names and attrs to validate, accept string or regex as validator
  • require/disallow spaces inside attribute brackets e.g.: (blah='blah')
  • require/disallow spaces inside attribute value array brackets e.g.: class=['a', 'b']
  • require/disallow spaces inside attribute value object brackets e.g.: class={active: true }
  • disallowMultipleAttributeBlocks: true
  • disallowEmptyMixinParenthasis: true

Suggestions:

  • quotation marks
  • no whitespace between attribute pairs
  • block expansion
  • id as literal/attribute
  • require space after buffered code
  • no duplicate attributes or attribute blocks
  • allow html in jade
  • no divs
  • classes proceed attributes
  • tag interpolation ???
  • prefer variable interpolation
  • line feed at end of file
  • don't use class attribute when literal will do
  • line length of attributes
  • require var
  • no unnecessary closing tags
  • remove redundant whitespace
  • required attributes for certain tags (e.g. img must have alt)
  • disallow certain tags
  • validate boolean attributes
  • style attributes use JSON (formatting rules for these)
  • class attributes Array and/or JSON (formatting rules for these)
  • multi-line unbuffered code format
  • no unnecessary string interpolation (e.g. h1 #{thing} should be h1= thing)
  • no unnecessary string concat (e.g. h1= thing + 'blah' should be h1 #{thing} blah)
  • comment type (when to use block comments over multiple single line, space after operator)
  • prefer built-in jade conditions and iteration
  • some how validate if versionPath is being used ???
  • slim line ifs (no brackets)
  • validate inheritance (does layout exist, do blocks exist) ???
  • class naming convention (BEM etc, match stylint ???)
  • attribute ordering ???
  • &attributes (formatting rules for these)
  • validate filters
  • validate include paths
  • validate mixins for unused/undefined variables
  • check for deprecated way of calling mixins
  • validate deprecated literals such as old doctype or previous way of writing conditional comments
  • space before/after attribute brackets and equals
  • disallow specific empty attribute
@benedfit benedfit added this to the v1 milestone Jul 16, 2015
@ForbesLindesay
Copy link
Member

A couple of suggestions for useful rules

  • disallow attribute interpolation (i.e. input(value="Hi #{name}") would be invalid but input(value="Hi " + name) would be valid). Attribute interpolation is something I am considering deprecating.
  • Only allow statements in - code. i.e. the following code would be invalid
//- invalid
- var n = 0;
- while (n < 10)
  - n++
  li= n

Pretty much all uses for doing this have builtins that can replace them, and it makes it very hard to provide useful line numbers in errors. If you force all lines starting with - to be valid statements, the problem is easy. e.g.

//- valid
- var n = 0;
while (n < 10)
  - n++
  li= n

@benedfit
Copy link
Contributor Author

@ForbesLindesay thanks for your thoughts. It's interesting to here that attribute interpolation is considered for deprecation, as our internal style preference was leaning towards it, is this the plan for all string interpolation?

@benedfit benedfit removed this from the v1 milestone Jul 30, 2015
@kevin-smets
Copy link

May I ask why are you thinking of deprecating interpolation? I love using it, just like string substitution the template strings in ES6/ES2015, so I'd hate to see it go :).

@benedfit
Copy link
Contributor Author

benedfit commented Nov 4, 2015

@kevin-smets pugjs/pug#2095 details the reasoning, and in Jade 2, attribute interpolation will be deprecated. I'm still leaving the tests for it in place for now, but have changed the Clock preset to disallow them by default

adrienverge added a commit to adrienverge/pug-lint that referenced this issue Apr 13, 2017
This rule reports lines in Pug file that exceed the specified length.

Related to pugjs#3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants