fostimus / eslint-plugin-svg-jsx Goto Github PK
View Code? Open in Web Editor NEWAutomatically get your inline SVGs ready for production in React.
License: MIT License
Automatically get your inline SVGs ready for production in React.
License: MIT License
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.
Something like Menu.Item
as the component name isn't properly parsed.
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)
})
}
Right now, a custom HTML element is determined only if there's a '-' in the element name.
A better solution would be to check the element name against a list of all valid HTML element names, as a custom HTML element could be something like <heynow />
.
Unit tests would be nice to have, especially as we add more special cases to this rule
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.