From 3ee3c7547941de971e4feea9ec7f59acfa430e94 Mon Sep 17 00:00:00 2001 From: Scott McIntyre Date: Fri, 23 Apr 2021 12:08:53 -0400 Subject: [PATCH 1/3] feat(eslint): add inclusive-language rule --- index.js | 28 ++++++++++++++++++++++++++++ package-lock.json | 13 +++++++++++++ package.json | 1 + 3 files changed, 42 insertions(+) diff --git a/index.js b/index.js index 6eda077..6b0dbae 100644 --- a/index.js +++ b/index.js @@ -1,3 +1,4 @@ +/* eslint-disable inclusive-language/use-inclusive-words */ /* * Copyright (c) 2017 American Express Travel Related Services Company, Inc. * @@ -58,6 +59,7 @@ module.exports = { 'react', 'react-hooks', 'you-dont-need-lodash-underscore', + 'inclusive-language', ], rules: { // open a PR per rule change @@ -219,6 +221,32 @@ module.exports = { // reduces the unnecessary boilerplate of explicitly setting props to `undefined` // prevent false-confidence for those less experienced with how default props work 'react/require-default-props': 'off', + + // encourage the use of inclusive language + 'inclusive-language/use-inclusive-words': [ + 'warn', + { + words: [ + { + word: 'blacklist', + suggestions: ['blocklist', 'denylist', 'deny', 'block', 'unapproved'], + }, + { + word: 'whitelist', + suggestions: ['allowlist', 'passlist', 'allow', 'permit', 'approved'], + }, + { + word: 'master', + suggestions: ['main', 'primary', 'host', 'leader'], + }, + { + word: 'slave', + suggestions: ['secondary', 'replica', 'client', 'follower'], + }, + ], + lintStrings: true, + }, + ], }, overrides: [{ // Certain rules need to be disabled when we are linting markdown files, diff --git a/package-lock.json b/package-lock.json index 875ad55..2121470 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3770,6 +3770,14 @@ } } }, + "eslint-plugin-inclusive-language": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-inclusive-language/-/eslint-plugin-inclusive-language-2.1.1.tgz", + "integrity": "sha512-/dJC035CntrE7JpmQk0lId340iJZ3wUp22dUIy33CVSbO0t9jffeIe0lM0H9281ISdfB4oERvbq3iMK7f0YRDQ==", + "requires": { + "humps": "^2.0.1" + } + }, "eslint-plugin-jest": { "version": "24.1.3", "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-24.1.3.tgz", @@ -4830,6 +4838,11 @@ "integrity": "sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw==", "dev": true }, + "humps": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/humps/-/humps-2.0.1.tgz", + "integrity": "sha1-3QLqYIG9BWjcXQcxhEY5V7qe+ao=" + }, "husky": { "version": "4.3.5", "resolved": "https://registry.npmjs.org/husky/-/husky-4.3.5.tgz", diff --git a/package.json b/package.json index 3ab1cb2..bf8ce40 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ "eslint-config-airbnb": "^18.2.1", "eslint-config-prettier": "^7.0.0", "eslint-plugin-import": "^2.22.1", + "eslint-plugin-inclusive-language": "^2.1.1", "eslint-plugin-jsx-a11y": "^6.4.1", "eslint-plugin-markdown": "^1.0.2", "eslint-plugin-react": "^7.21.5", From c8c7ddafed3adcccf5e364e33139c933b894b6f9 Mon Sep 17 00:00:00 2001 From: Scott McIntyre Date: Tue, 4 May 2021 13:25:23 -0400 Subject: [PATCH 2/3] fix(index): alphabetize plugins --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index d0cbd96..f182085 100644 --- a/index.js +++ b/index.js @@ -54,12 +54,12 @@ module.exports = { }, plugins: [ 'import', + 'inclusive-language', 'jsx-a11y', 'markdown', 'react', 'react-hooks', 'you-dont-need-lodash-underscore', - 'inclusive-language', ], rules: { // open a PR per rule change From ec5a6efcd991f88849c888bc6d0c3b8200eb8ecc Mon Sep 17 00:00:00 2001 From: Scott McIntyre Date: Thu, 6 May 2021 15:12:27 -0400 Subject: [PATCH 3/3] fix(index): make use-inclusive-words an error instead of warn --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index f182085..c179773 100644 --- a/index.js +++ b/index.js @@ -224,7 +224,7 @@ module.exports = { // encourage the use of inclusive language 'inclusive-language/use-inclusive-words': [ - 'warn', + 'error', { words: [ {