Giter Club home page Giter Club logo

eslint-plugin-literal-blacklist's People

Contributors

dependabot[bot] avatar kyaido avatar luqmanulkhair22 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

eslint-plugin-literal-blacklist's Issues

Add message to describe why a word is black-listed

We love this package in our project! Thank you!

It would be awesome to have the possibility to describe why a term is black-listed. So that the devs can see it when they hover over the black-listed word.

Possible implementation

In .eslintrc.json, there is a string[] inside of literal-blacklist/literal-blacklist. Change it to array of {term: string, message: string} instead of string.

"literal-blacklist/literal-blacklist": [
	"error", [
		{
			"term": "Teilnehmer",
			"message": "we use »Teilnehmende« to be gender-neutral",
		},
		{
			"term": "ebay",
			"message": "The brand is »eBay«, not »ebay« ;)",
		},
	],
],

Plugin code would change to something like this:

      options.forEach(option => {
        if(value.indexOf(option.term) !== -1) {
          message = `You should not use "${option.term}".\n${option.message}`;
          context.report({node: node, message: message});
        }
      });

PS:
Maybe there is a way to make it backwards compatible to still allow string[] AND {term: string, message: string}[] instead of only {term: string, message: string}[].

Release 1.2.0 broke term "..."

I saw you implemented support for RegEx in term. Nice one! But unfortunately it broke one of my terms. I had this one:

{ 
  "term": "...", 
  "message": "we use the ellipsis char `…` instead. On windows you get this with the following alt code: alt + 0133; on OSX: ⌥ ." 
},

The lint command in my pipeline seems to interpret this as RegEx ... which translates to 3 chars of any kind, which, as you might guess, happens a bazillion times in my project :D

new feature proposition

Hi , let's say that i have in my code the following snippet:

if (appearance === 'dark') {
     source = require('assets/darkModeAssetBlabla.something');
 }

and I would like to exclude the term "dark", so I implemented the following rule:

'literal-blacklist/literal-blacklist': [
      ERROR,
      [
        {
          term: "=== 'dark'",
          message: "use ThemeModes.DARK instead of 'dark'",
          ignoreCase: true,
        },
      ],
    ],

what will happens is that both 'dark' and 'darkModeAssetBlabla.something' will be underlined by eslint, while I want to target exclusively entire words.

Can you add the option, after ignoreCase, matchWholeWord?
I think it will make senses
thanks

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.