npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

eslint-plugin-react-i18next-prettier-ignore

v1.1.0

Published

Plugin resolves a conflict between a component <Tras><Trans> and prettier(max length) adding /*prettier-ignore*/ before the component.

Downloads

7

Readme

eslint-plugin-react-i18next-prettier-ignore · GitHub license

Description

It is quite common to use auto formatting tools like "Prettier" in IDEs or autofix by Node commands. Unfortunately those tools tend to reformat these JSX code parts as soon as they become too complex. It will always break the component.

Plugin resolves a problem between a component <Tras></Trans>and prettier(max length) adding /*prettier-ignore*/ before the component.

/*
  <0/> is <b>bold</b>
  <1/> is ' unbolded '
  <2/> is <i>italicized</i>
 */
<Trans>
  <span>
    <b>bold</b> unbolded <i>italicized</i>
  </span>
</Trans>

/*
  <0/> is <b>bold</b>
  <1/> is ' '
  <2/> is 'unbolded'
  <3/> is ' '
  <4/> is <i>italicized</i>

  Prettier will insert the spaces if these strings are very long.
 */
<Trans>
  <span>
    <b>bold</b>
    {' '}unbolded{' '}
    <i>italicized</i>
  </span>
</Trans>

Installation

npm install eslint-plugin-react-i18next-prettier-ignore -D

yarn add eslint-plugin-react-i18next-prettier-ignore -D

Usage:

The most important need to use a plugin eslint-plugin-prettier and should keep a order of rules.

.eslintrc.js

module.export = {
    plugin: ['another-plugin', 'prettier', 'react-i18next-prettier-ignore'],
    rules: {
        'react-i18next-prettier-ignore/no-trans-without-prettier-ignore': 'error',
        "prettier/prettier": "error"
    }
}

Examples

JS/Typescript code:

const fn = () => {
  return (<Trans>Test <span>span element</span></Trans>)
}

const fn = () => () =>  <Trans>Test <span>span element</span></Trans>;                 

const fn = () => <Trans>Test <span>span element</span></Trans>

(() => <Trans>Test <span>span element</span></Trans>)()

const fn = (testArg, testArg2 = <Trans>Test <span>span element</span></Trans>, testArg3) => {}

const Obj = {
  '2':23,
  "test": <Trans>Test <span>span element</span></Trans>,
  "3": 'sdfsdf'
}

const value = 343,  value2 = <Trans>Test <span>span element</span></Trans>

const value = <Trans>Test <span>span element</span></Trans>

const boleanExpression = true ? null : <Trans>Test <span>span element</span></Trans>

const array = [1, 2, <Trans>Test <span>span element</Trans>, 3 ]

<div>
    <Trans></Trans>
    
    <Component attr={<Trans>Test <span>span element</Trans>}></Test>
    
    {true ? null : (<Trans>Test <span>span element</Trans>)}
    
    {true && 1 &&  <Trans>Test <span>span element</Trans>}
</div>

// RESULT

const fn = () => {
  /* prettier-ignore */
  return (<Trans>Test <span>span element</span></Trans>)
}

/* prettier-ignore */
const fn = () => () =>  <Trans>Test <span>span element</span></Trans>;

/* prettier-ignore */
const fn = () => <Trans>Test <span>span element</span></Trans>

/* prettier-ignore */
(() => <Trans>Test <span>span element</span></Trans>)()

const fn = (testArg, /* prettier-ignore */ testArg2 = <Trans>, testArg3) => {}

const TestObj = {
  '2': 23,
  /* prettier-ignore */
  "test": <Trans>Test <span>span element</span></Trans>,
  "3": 'sdfsdf'
}

const value = 343, /* prettier-ignore */ value2 = <Trans>Test <span>span element</span></Trans>

/* prettier-ignore */
const value = <Trans>Test <span>span element</span></Trans>

const Test2 = true ? null : /* prettier-ignore */ <Trans>Test <span>span element</span></Trans>

const array = [1, 2, /* prettier-ignore */ <Trans>Test <span>span element</span></Trans>, 3 ]

<div>
    {/* prettier-ignore */}
    <Trans></Trans>
    
    <Component attr={/* prettier-ignore */ <Trans>Test <span>span element</span></Trans>}></Test>
    
    {true ? null : (/* prettier-ignore */ <Trans>Test <span>span element</span></Trans>)}
    
    {true && 1 &&  /* prettier-ignore */ <Trans>Test <span>span element</span></Trans>}
</div>