Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

Commit

Permalink
Add linting for insensitive and inconsiderate language (#2223)
Browse files Browse the repository at this point in the history
Summary:
**Summary**

This PR, similarly to facebook/react-native-website#1337, adds [alexjs](https://alexjs.com/) linting to Draft.js in order to identify and prevent insensitive and inconsiderate language from landing on master.

- Adds Alex
- Configures Alex rules
- **TODO:** Run Alex in Travis CI

**Test Plan**

- Run `yarn lint-docs`
- Verify there are no lint violations
Pull Request resolved: #2223

Differential Revision: D18046996

Pulled By: claudiopro

fbshipit-source-id: 66ac935720a0b13576e9a133a3d5f8e98cc539cf
  • Loading branch information
Claudio Procida authored and facebook-github-bot committed Oct 22, 2019
1 parent 778e88d commit 5dd99d3
Show file tree
Hide file tree
Showing 24 changed files with 1,504 additions and 71 deletions.
12 changes: 12 additions & 0 deletions .alexignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# The Code of Conduct calls out language that can't be used so it's not linted.
CODE_OF_CONDUCT.md

# The CHANGELOG contains references to commit messages.
CHANGELOG.md

# We will handle meeting notes and roadmap documents after the main docs are linted.
meta/meeting-notes/**/*.md
meta/roadmaps/*.md

# This README contains some domain specific language that fails validation.
examples/draft-0-10-0/playground/README.md
18 changes: 18 additions & 0 deletions .alexrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

exports.allow = [
// We frequently refer to form props by their name "disabled".
// Ideally we would alex-ignore only the valid uses (PRs accepted).
"invalid",

// Unfortunately "watchman" is a library name that we depend on.
"watchman-watchwoman"
];

// Use a "maybe" level of profanity instead of the default "unlikely".
exports.profanitySureness = 1;
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Contributing to Draft.js
We want to make contributing to this project as easy and transparent as
We want to make contributing to this project as approachable and transparent as
possible.

## Code of Conduct
Expand Down Expand Up @@ -65,7 +65,7 @@ Our philosophy regarding API changes is as follows:
* In order to avoid stagnation we will allow for API changes in cases where
there is no other way to achieve a high priority bug fix or improvement.
* When there is an API change:
* Changes will have a clearly documented reason and migration path
* Changes will have a well documented reason and migration path
* When deprecating a pattern, these steps will be followed:
* We will test the change internally first at FB
* A version will be released that supports both, with deprecation warnings
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ backed by an immutable model.

- **Extensible and Customizable:** We provide the building blocks to enable
the creation of a broad variety of rich text composition experiences, from
simple text styles to embedded media.
basic text styles to embedded media.
- **Declarative Rich Text:** Draft.js fits seamlessly into
[React](http://facebook.github.io/react/) applications,
abstracting away the details of rendering, selection, and input behavior with a
Expand Down Expand Up @@ -138,7 +138,7 @@ Further examples of how Draft.js can be used are provided below.

### Examples

Visit http://draftjs.org/ to try out a simple rich editor example.
Visit http://draftjs.org/ to try out a basic rich editor example.

The repository includes a variety of different editor examples to demonstrate
some of the features offered by the framework.
Expand Down
2 changes: 1 addition & 1 deletion docs/APIReference-Editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ disabled.

This is useful when supporting interaction within
[custom block components](/docs/advanced-topics-block-components.html)
or if you just want to display content for a static use case.
or if you only want to display content for a static use case.

Default is `false`.

Expand Down
2 changes: 1 addition & 1 deletion docs/APIReference-EditorState.md
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ operations.
When performing operations that modify contents, we determine whether the
current `ContentState` should be regarded as a "boundary" state that the user
can reach by performing an undo operation. If so, the `ContentState` is pushed
onto the `undoStack`. If not, the outgoing `ContentState` is simply discarded.
onto the `undoStack`. If not, the outgoing `ContentState` is discarded.

You should not manage this property manually. If you would like to disable
undo/redo behavior, use the `allowUndo` property.
Expand Down
2 changes: 1 addition & 1 deletion docs/APIReference-Entity.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ for details on updating your application
[see our v0.10 API Migration Guide](/docs/v0-10-api-migration.html#content).

Entity objects returned by `Entity` methods are represented as
[DraftEntityInstance](https://github.com/facebook/draft-js/blob/master/src/model/entity/DraftEntityInstance.js) immutable records. These have a simple set of getter functions and should
[DraftEntityInstance](https://github.com/facebook/draft-js/blob/master/src/model/entity/DraftEntityInstance.js) immutable records. These have a small set of getter functions and should
be used only for retrieval.

## Overview
Expand Down
4 changes: 2 additions & 2 deletions docs/APIReference-Modifier.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ insertText(
): ContentState
```
Identical to `replaceText`, but enforces that the target range is collapsed
so that no characters are replaced. This is just for convenience, since text
so that no characters are replaced. This is only for convenience, since text
edits are so often insertions rather than replacements.

### moveText
Expand All @@ -136,7 +136,7 @@ replaceWithFragment(
fragment: BlockMap
): ContentState
```
A "fragment" is a section of a block map, effectively just an
A "fragment" is a section of a block map, effectively only an
`OrderedMap<string, ContentBlock>` much the same as the full block map of a
`ContentState` object.

Expand Down
2 changes: 1 addition & 1 deletion docs/Advanced-Topics-Block-Components.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ The recommendation above is especially important for custom block renderers
that involve text input, like the TeX editor example.

It is also worth noting that within the Facebook Notes editor, we have not
tried to perform any special SelectionState rendering or management on embedded
tried to perform any specific SelectionState rendering or management on embedded
media, such as rendering a highlight on an embedded photo when selecting it.
This is in part because of the rich interaction provided on the media
itself, with resize handles and other controls exposed to mouse behavior.
Expand Down
2 changes: 1 addition & 1 deletion docs/Advanced-Topics-Custom-Block-Render.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class RichEditor extends React.Component {
}
```

There are cases where instead of overwriting the defaults, we just want to add new block types.
There are cases where instead of overwriting the defaults, we only want to add new block types.
This can be done by using the DefaultDraftBlockRenderMap reference to create a new blockRenderMap

*example of extending default block render map:*
Expand Down
6 changes: 3 additions & 3 deletions docs/Advanced-Topics-Decorators.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ The strategy functions execute the provided callback with the `start` and
## Decorator Components

For your decorated ranges of text, you must define a React component to use
to render them. These tend to be simple `span` elements with CSS classes or
to render them. These tend to be plain `span` elements with CSS classes or
styles applied to them.

In our current example, the `CompositeDecorator` object names `HandleSpan` and
`HashtagSpan` as the components to use for decoration. These are just basic
`HashtagSpan` as the components to use for decoration. These are basic
stateless components:

```js
Expand Down Expand Up @@ -124,7 +124,7 @@ you wish, as long as they match the expected type -- you are not bound by
## Setting new decorators

Further, it is acceptable to set a new `decorator` value on the `EditorState`
on the fly, during normal state propagation -- through immutable means, of course.
on the fly, during normal state propagation, through immutable means.

This means that during your app workflow, if your decorator becomes invalid or
requires a modification, you can create a new decorator object (or use
Expand Down
2 changes: 1 addition & 1 deletion docs/Advanced-Topics-EditorState-Race-Conditions.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ this.handlePastedText = (text, styles, editorState) => {
```
With `handlePastedText` you can implement the paste behavior by yourself.

NOTE: If you need to have this behavior in your Editor there is a much easier way to achieve this. Just set the `Editor`'s `stripPastedStyles` property to `true`.
NOTE: If you need to have this behavior in your Editor, you can achieve it by setting the `Editor`'s `stripPastedStyles` property to `true`.
2 changes: 1 addition & 1 deletion docs/Advanced-Topics-Inline-Styles.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ together in styled `span` nodes.
## Mapping a style string to CSS

By default, `Editor` provides support for a basic list of inline styles:
`'BOLD'`, `'ITALIC'`, `'UNDERLINE'`, and `'CODE'`. These are mapped to simple CSS
`'BOLD'`, `'ITALIC'`, `'UNDERLINE'`, and `'CODE'`. These are mapped to plain CSS
style objects, which are used to apply styles to the relevant ranges.

For your editor, you may define custom style strings to include with these
Expand Down
2 changes: 1 addition & 1 deletion docs/Advanced-Topics-Text-Direction.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ This may be useful, for instance, if an editor requires strictly centered
contents, or needs to keep text aligned flush against another UI element.

The `Editor` component therefore provides a `textAlignment` prop, with a
simple set of values: `'left'`, `'center'`, and `'right'`. Using these values,
small set of values: `'left'`, `'center'`, and `'right'`. Using these values,
the contents of your editor will be aligned to the specified direction regardless
of language and character set.
2 changes: 1 addition & 1 deletion docs/Overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ onPageNav: 'none'

Draft.js is a framework for building rich text editors in React, powered by an immutable model and abstracting over cross-browser differences.

Draft.js makes it easy to build any type of rich text input, whether you're just looking to support a few inline text styles or building a complex text editor for composing long-form articles.
Draft.js allows you to build any type of rich text input, whether you're only looking to support a few inline text styles or building a complex text editor for composing long-form articles.

Draft.js was introduced at [React.js Conf](https://conf2016.reactjs.org/schedule.html#rich-text-editing-with-react) in February 2016.

Expand Down
Loading

0 comments on commit 5dd99d3

Please sign in to comment.