kyaido / eslint-plugin-literal-blacklist Goto Github PK
View Code? Open in Web Editor NEWAn ESLint micro plugin
An ESLint micro plugin
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.
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}[]
.
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
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
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.