Giter VIP home page Giter VIP logo

eslint-plugin-svg-jsx's People

Contributors

fostimus avatar hanayashiki avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

hanayashiki

eslint-plugin-svg-jsx's Issues

Add a case for attributes like `xlink:href`

React also does not like xlink:href, instead it should be xlinkHref. Changing props that use colons to camel case should work, but there might be caveats or special exceptions to the rule.

TypeError: Cannot read properties of undefined (reading 'range')

Hi, I got the following exception when linting my react/typescript project:

pnpm eslint --ext .ts,.tsx .

Oops! Something went wrong! :(

ESLint: 8.56.0

TypeError: Cannot read properties of undefined (reading 'range')
Occurred while linting /Users/chenyuwang/pawpawmall/packages/store/src/routes/_root.my-page.mail-settings.tsx:167
Rule: "svg-jsx/camel-case-dash"
    at Object.replaceText (/Users/chenyuwang/pawpawmall/node_modules/.pnpm/eslint@8.56.0/node_modules/eslint/lib/linter/rule-fixer.js:95:50)
    at Object.fix (/Users/chenyuwang/pawpawmall/node_modules/.pnpm/eslint-plugin-svg-jsx@1.2.2/node_modules/eslint-plugin-svg-jsx/rules/camel-case-dash.js:61:29)
    at normalizeFixes (/Users/chenyuwang/pawpawmall/node_modules/.pnpm/eslint@8.56.0/node_modules/eslint/lib/linter/report-translator.js:194:28)
    at /Users/chenyuwang/pawpawmall/node_modules/.pnpm/eslint@8.56.0/node_modules/eslint/lib/linter/report-translator.js:365:49
    at Object.report (/Users/chenyuwang/pawpawmall/node_modules/.pnpm/eslint@8.56.0/node_modules/eslint/lib/linter/linter.js:1047:41)
    at validateAndFixProp (/Users/chenyuwang/pawpawmall/node_modules/.pnpm/eslint-plugin-svg-jsx@1.2.2/node_modules/eslint-plugin-svg-jsx/rules/camel-case-dash.js:51:23)
    at /Users/chenyuwang/pawpawmall/node_modules/.pnpm/eslint-plugin-svg-jsx@1.2.2/node_modules/eslint-plugin-svg-jsx/rules/camel-case-dash.js:79:13
    at Array.forEach (<anonymous>)
    at handleSpreadOperator (/Users/chenyuwang/pawpawmall/node_modules/.pnpm/[email protected]/node_modules/eslint-plugin-svg-jsx/rules/camel-case-dash.js:74:17)
    at /Users/chenyuwang/pawpawmall/node_modules/.pnpm/[email protected]/node_modules/eslint-plugin-svg-jsx/rules/camel-case-dash.js:94:15

The code to lint is:

<MyPageForm
  {...emailForm.bindForm({
    async onSubmit(body) {},
  })}
>
  {...}
</MyPageForm>

Although I'm not quite understanding this library, the problem seems to be that nodeToFix is possibly undefined.

        function handleSpreadOperator(attr, charDelimtiter) {
          const props = getPropsFromObjectString(getPropIdentifier(attr, context))
          props.forEach((prop) => {
            const nodeToFix = attr?.argument?.properties?.find((node) => {
              return node?.key?.value === prop
            })?.key

            validateAndFixProp(prop, nodeToFix, charDelimtiter)
          })
        }

Add tests

Unit tests would be nice to have, especially as we add more special cases to this rule

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.