Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/fostimus/eslint-plugin-svg-jsx

Automatically get your inline SVGs ready for production in React.
https://github.com/fostimus/eslint-plugin-svg-jsx

Last synced: 22 days ago
JSON representation

Automatically get your inline SVGs ready for production in React.

Awesome Lists containing this project

README

        

# eslint-plugin-svg-jsx

Enforce camelCased props instead of dashed props.

NPM package: https://www.npmjs.com/package/eslint-plugin-svg-jsx

## Add to your project

1. Add the dependency: `yarn add -D eslint-plugin-svg-jsx` or `npm install --save-dev eslint-plugin-svg-jsx`
2. In your .eslintrc.js:
1. Add `svg-jsx` to your plugins
2. Add the `svg-jsx` rules:
```
'svg-jsx/camel-case-dash': 'error',
'svg-jsx/camel-case-colon': 'error',
'svg-jsx/no-style-string': 'error',
```

Final .eslintrc.js should look something like:

```js
module.exports = {
parser: "@babel/eslint-parser",
extends: ["standard", "standard-jsx", "plugin:prettier/recommended"],
plugins: ["no-only-tests", "prettier", "svg-jsx"],
rules: {
"svg-jsx/camel-case-dash": "error",
"svg-jsx/camel-case-colon": "error",
"svg-jsx/no-style-string": "error",
},
}
```

## Code examples

Case #1: Dashes in props.

```js
// invalid

// valid

```

Case #2: Colons in props.

```js
// invalid

// valid

```

Case #3: string style attributes
```js
// invalid

// valid

```

## Contributing

Pull requests are welcome. Please checkout the [open issues](https://github.com/fostimus/eslint-plugin-svg-jsx/issues) we have if you'd like to help out. Bugfixes and related features are also welcome.