Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add linting rules in JS and Ruby to encourage inclusive language #586

Merged
merged 9 commits into from
Dec 10, 2021
14 changes: 13 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,23 @@ module.exports = {
ecmaVersion: 2018,
sourceType: 'module'
},
plugins: ['react'],
plugins: ['react', 'inclusive-language'],
rules: {
'react/jsx-handler-names': 'off',
'react/prop-types': 'off',
'space-before-function-paren': ['error', 'never'],
'inclusive-language/use-inclusive-words': [
"error",
{
"words": [
{
"word": "blacklist",
"suggestions": ["denylist or blocklist"],
"explanation": "The usage of the non-inclusive word '{{word}}' is discouraged, use '{{suggestion}}' instead."
}
]
}
],

// next two rules are a workaround, see
// https://github.com/babel/babel-eslint/issues/681#issuecomment-420663038
Expand Down
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,13 @@ Metrics/BlockLength:
Rails/FilePath:
Enabled: false

Naming/InclusiveLanguage:
Enabled: true

AllCops:
Exclude:
- Gemfile
- vendor/**/*
- node_modules/**/*
- bin/webpack*
NewCops: enable
2 changes: 1 addition & 1 deletion Dangerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def warn_if_adding(term:, files:)
diff = git.diff_for_file(file)
next unless diff

added_lines = diff.patch.split(/\n/).select { |line| line =~ /^\+/ }
added_lines = diff.patch.split(/\n/).grep(/^\+/)
warn "Please think twice before adding #{term} to the project 😱 (#{file})" if added_lines.any? { |line| line =~ regexp }
end
end
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ group :development, :test do
gem 'danger'
gem 'pry-rails'
gem 'rspec-rails'
gem 'rubocop'
gem 'rubocop', '>=1.21'
gem 'rubocop-rails'
gem 'dotenv'
end
Expand Down
29 changes: 16 additions & 13 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ GEM
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
arel (9.0.0)
ast (2.4.0)
ast (2.4.2)
bindex (0.8.1)
builder (3.2.4)
capybara (3.30.0)
Expand Down Expand Up @@ -154,7 +154,6 @@ GEM
ruby_parser (~> 3.5)
i18n (1.7.1)
concurrent-ruby (~> 1.0)
jaro_winkler (1.5.4)
jbuilder (2.9.1)
activesupport (>= 4.2.0)
jwt (2.2.1)
Expand Down Expand Up @@ -202,9 +201,9 @@ GEM
oauth2 (~> 1.1)
omniauth (~> 1.9)
open4 (1.3.4)
parallel (1.19.1)
parser (2.7.0.1)
ast (~> 2.4.0)
parallel (1.21.0)
parser (3.0.3.1)
ast (~> 2.4.1)
pg (1.2.0)
pry (0.12.2)
coderay (~> 1.1.0)
Expand Down Expand Up @@ -252,7 +251,7 @@ GEM
rb-inotify (0.10.1)
ffi (~> 1.0)
redis (4.1.3)
regexp_parser (1.6.0)
regexp_parser (1.8.2)
responders (3.0.0)
actionpack (>= 5.0)
railties (>= 5.0)
Expand All @@ -274,19 +273,23 @@ GEM
rspec-mocks (~> 3.9.0)
rspec-support (~> 3.9.0)
rspec-support (3.9.2)
rubocop (0.78.0)
jaro_winkler (~> 1.5.1)
rubocop (1.23.0)
parallel (~> 1.10)
parser (>= 2.6)
parser (>= 3.0.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
rubocop-ast (>= 1.12.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.13.0)
parser (>= 3.0.1.1)
rubocop-rails (2.4.1)
rack (>= 1.1)
rubocop (>= 0.72.0)
ruby-enum (0.7.2)
i18n
ruby-progressbar (1.10.1)
ruby-progressbar (1.11.0)
ruby_parser (3.14.1)
sexp_processor (~> 4.9)
rubyzip (2.0.0)
Expand Down Expand Up @@ -339,7 +342,7 @@ GEM
thread_safe (~> 0.1)
uglifier (4.2.0)
execjs (>= 0.3.0, < 3)
unicode-display_width (1.6.0)
unicode-display_width (1.8.0)
web-console (3.7.0)
actionview (>= 5.0)
activemodel (>= 5.0)
Expand Down Expand Up @@ -385,7 +388,7 @@ DEPENDENCIES
puma
rails (~> 5.2)
rspec-rails
rubocop
rubocop (>= 1.21)
rubocop-rails
sassc-rails
sentry-raven
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ require_relative 'config/application'
Rails.application.load_tasks

task('default').clear
task default: 'test:all'.to_sym
task default: :'test:all'
2 changes: 1 addition & 1 deletion app/services/artwork_search_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def call(query:)

def api_url
"#{Rails.application.config_for(:elasticsearch)['url']}/#{Rails.application.config_for(:elasticsearch)['index']}" \
'/artwork/_search'
'/artwork/_search'
end

def basic_auth_credentials
Expand Down
2 changes: 1 addition & 1 deletion config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,5 @@
# routes, locales, etc. This feature depends on the listen gem.
config.file_watcher = ActiveSupport::EventedFileUpdateChecker

config.logger = ActiveSupport::TaggedLogging.new(Logger.new(STDOUT))
config.logger = ActiveSupport::TaggedLogging.new(Logger.new($stdout))
end
2 changes: 1 addition & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')

if ENV['RAILS_LOG_TO_STDOUT'].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger = ActiveSupport::Logger.new($stdout)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this here for a dependency update? This doesn't on a glance seem to do with the task at hand. I might prefer in such a case just a quick note about it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right — this is one of several changes that was made in order to placate Rubocop in 0521c3b

And that's a consequence of upgrading this project to a recent enough Rubocop to get the new settings.

logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end
Expand Down
2 changes: 2 additions & 0 deletions config/initializers/simple_form.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# rubocop:disable Lint/EmptyBlock
# simple_form complains if this file doesn't exist
SimpleForm.setup do |config|
end
# rubocop:enable Lint/EmptyBlock
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"eslint-config-standard": "14.1.0",
"eslint-config-standard-react": "9.2.0",
"eslint-plugin-import": "2.19.1",
"eslint-plugin-inclusive-language": "^2.1.1",
"eslint-plugin-node": "11.0.0",
"eslint-plugin-prettier": "3.1.2",
"eslint-plugin-promise": "4.2.1",
Expand Down
12 changes: 12 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7058,6 +7058,13 @@ eslint-plugin-import@2.19.1:
read-pkg-up "^2.0.0"
resolve "^1.12.0"

eslint-plugin-inclusive-language@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-inclusive-language/-/eslint-plugin-inclusive-language-2.1.1.tgz#74875a0a93da343587c735854c706cc22579fd4d"
integrity sha512-/dJC035CntrE7JpmQk0lId340iJZ3wUp22dUIy33CVSbO0t9jffeIe0lM0H9281ISdfB4oERvbq3iMK7f0YRDQ==
dependencies:
humps "^2.0.1"

eslint-plugin-node@11.0.0:
version "11.0.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-node/-/eslint-plugin-node-11.0.0.tgz#365944bb0804c5d1d501182a9bc41a0ffefed726"
Expand Down Expand Up @@ -8749,6 +8756,11 @@ https-browserify@^1.0.0:
resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-1.0.0.tgz#ec06c10e0a34c0f2faf199f7fd7fc78fffd03c73"
integrity sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=

humps@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/humps/-/humps-2.0.1.tgz#dd02ea6081bd0568dc5d073184463957ba9ef9aa"
integrity sha1-3QLqYIG9BWjcXQcxhEY5V7qe+ao=

husky@3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/husky/-/husky-3.1.0.tgz#5faad520ab860582ed94f0c1a77f0f04c90b57c0"
Expand Down