Git Product home page Git Product logo

Comments (11)

hudochenkov avatar hudochenkov commented on June 18, 2024 1

I'm not a fan of max-len rules in linters, but I get your frustration.

I think we could split long if statements in value-keyword-case and other files.

Before:

if (node.type !== "word" || !isStandardSyntaxValue(node.value) || value.indexOf("#") !== -1 || ignoredCharacters.has(keyword) || getUnitFromValueNode(node)) {
  return
}

if (prop === "animation" && !keywordSets.animationShorthandKeywords.has(valueLowerCase) && !keywordSets.animationNameKeywords.has(valueLowerCase)) {
  return
}

After:

if (
	node.type !== "word" 
	|| !isStandardSyntaxValue(node.value) 
	|| value.indexOf("#") !== -1 
	|| ignoredCharacters.has(keyword) 
	|| getUnitFromValueNode(node)
) {
  return
}

if (
	prop === "animation" 
	&& !keywordSets.animationShorthandKeywords.has(valueLowerCase) 
	&& !keywordSets.animationNameKeywords.has(valueLowerCase)
) {
  return
}

Also value-keyword-case has this lines:

        if (expectation === "lower" && mapLowercaseKeywordsToCamelCase.has(keywordLowerCase)) {
          expectedKeyword = mapLowercaseKeywordsToCamelCase.get(keywordLowerCase)
        }

They are 95 and 81 characters long. max-len: 80 is too short.

from eslint-config-stylelint.

hudochenkov avatar hudochenkov commented on June 18, 2024 1

I think we could add more options:

"ignoreComments": true
"ignoreUrls": true
"ignoreStrings": true
"ignoreTemplateLiterals": true

We have long quoted lines in tests. And for messages.

from eslint-config-stylelint.

alexander-akait avatar alexander-akait commented on June 18, 2024

@hudochenkov sgtm to me for split long if statements, but good have lint errors or warnings to never forget it, the only solution I see setting rules on the length of the line.

from eslint-config-stylelint.

jeddy3 avatar jeddy3 commented on June 18, 2024

I'm indifferent to whether this is included or not.

You both make good points either way. Would max-len: 120 be an acceptable compromise?

It flags 192 warnings. It seems a lot of them are from conditionals in the rule code as exampled above, so it would be good at catching those:

if (node.type !== "word" || !isStandardSyntaxValue(node.value) || value.indexOf("#") !== -1 || ignoredCharacters.has(keyword) || getUnitFromValueNode(node)) {
  return
}

from eslint-config-stylelint.

alexander-akait avatar alexander-akait commented on June 18, 2024

@jeddy3 good for me

from eslint-config-stylelint.

hudochenkov avatar hudochenkov commented on June 18, 2024

max-len: 120 looks good for me.

It would throw a warning on a legit lines:

const isBlocklessAtRuleAfterSameNameBlocklessAtRule = require("../../utils/isBlocklessAtRuleAfterSameNameBlocklessAtRule")

This name 😂

But will help make the code more clear:

before = before[before.length - 1] === "*" || before[before.length - 1] === "_" ? before.slice(0, before.length - 1) : before

Source.

from eslint-config-stylelint.

alexander-akait avatar alexander-akait commented on June 18, 2024

@hudochenkov we can think about rename to more simple name or

const someLongLongLongLongVartiables 
  = require('some-long-module-name-more-than-120-characters-in-line')

from eslint-config-stylelint.

hudochenkov avatar hudochenkov commented on June 18, 2024

Or just add // eslint-disable-line max-len :)

from eslint-config-stylelint.

jeddy3 avatar jeddy3 commented on June 18, 2024

@davidtheclark Any objections to max-len: [2, 120]? If not, we can PR this before the next release of the config.

from eslint-config-stylelint.

davidtheclark avatar davidtheclark commented on June 18, 2024

I'm fine what whatever you all want.

from eslint-config-stylelint.

jeddy3 avatar jeddy3 commented on June 18, 2024

Done in #24

from eslint-config-stylelint.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.