From 2578bd1685a11028023e124cd9fe06a084be52df Mon Sep 17 00:00:00 2001 From: Jeremy Wiebe Date: Thu, 26 May 2022 11:52:13 -0700 Subject: [PATCH] Rename Gorgon -> PerseusLinter, NotGorgon -> TranslationLinter (#251) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary: Perseus ships with two different linters named Gorgon and NotGorgon. These names are not very approachable for folks who aren't familiar with the origin of the names. This PR renames: * `Gorgon` -> `PerseusLinter` * `NotGorgon` -> `TranslationLinter` This will make the Perseus codebase a little bit more approachable and understandable for myself and future engineers working with and on Perseus. Note: This change will require associated changes in Webapp as well as updates to docs in confluence/Gdocs. I'll do those in the same PR as we update the Perseus npm module in webapp. Issue: "none" ## Test plan: Review that there aren't any remaining references to `gorgon` or `not-gorgon` (including variations in casgin and with/without dashes). Author: jeremywiebe Reviewers: kevinbarabash, mpolyak, aberkan, BrianGenisio, nbagdia Required Reviewers: Approved By: kevinbarabash, mpolyak Checks: ❌ gerald, ❌ codecov/project, ✅ Lint, Flow, and Test (ubuntu-latest, 16.x), ✅ Test Coverage (ubuntu-latest, 16.x), ✅ Extract i18n strings (ubuntu-latest, 16.x), ✅ Check builds for changes in size (ubuntu-latest, 16.x), ✅ gerald, ✅ Check for .changeset file (ubuntu-latest, 16.x), ✅ Lint, Flow, and Test (ubuntu-latest, 16.x), ✅ Extract i18n strings (ubuntu-latest, 16.x), ✅ Test Coverage (ubuntu-latest, 16.x), ✅ Check builds for changes in size (ubuntu-latest, 16.x), ✅ Check for .changeset file (ubuntu-latest, 16.x), ✅ gerald Pull Request URL: https://github.com/Khan/perseus/pull/251 --- .changeset/breezy-moons-approve.md | 6 ++ .changeset/chilly-shirts-crash.md | 6 ++ .../src/__tests__/matcher_test.js | 2 +- .../perseus-linter/src/__tests__/rule_test.js | 2 +- .../src/__tests__/selector-parser_test.js | 2 +- .../src/__tests__/tree-transformer_test.js | 2 +- packages/perseus-linter/src/index.js | 2 +- packages/perseus-linter/src/rule.js | 6 +- .../src/__tests__/perseus-markdown_test.jsx | 10 +-- .../perseus/src/__tests__/renderer_test.jsx | 18 +++--- packages/perseus/src/article-renderer.jsx | 8 +-- .../src/components/input-with-examples.jsx | 8 +-- packages/perseus/src/components/lint.jsx | 3 +- packages/perseus/src/components/sortable.jsx | 12 ++-- packages/perseus/src/hint-renderer.jsx | 6 +- packages/perseus/src/hints-renderer.jsx | 6 +- packages/perseus/src/item-renderer.jsx | 8 +-- packages/perseus/src/perseus-markdown.jsx | 3 +- packages/perseus/src/renderer.jsx | 63 +++++++++---------- .../{not-gorgon.js => translation-linter.js} | 21 +++---- 20 files changed, 102 insertions(+), 92 deletions(-) create mode 100644 .changeset/breezy-moons-approve.md create mode 100644 .changeset/chilly-shirts-crash.md rename packages/perseus/src/{not-gorgon.js => translation-linter.js} (88%) diff --git a/.changeset/breezy-moons-approve.md b/.changeset/breezy-moons-approve.md new file mode 100644 index 0000000000..5ebcccc14c --- /dev/null +++ b/.changeset/breezy-moons-approve.md @@ -0,0 +1,6 @@ +--- +"@khanacademy/perseus": minor +"@khanacademy/perseus-linter": minor +--- + +Rename NotGorgon to TranslationLinter diff --git a/.changeset/chilly-shirts-crash.md b/.changeset/chilly-shirts-crash.md new file mode 100644 index 0000000000..4e3d9b324c --- /dev/null +++ b/.changeset/chilly-shirts-crash.md @@ -0,0 +1,6 @@ +--- +"@khanacademy/perseus": minor +"@khanacademy/perseus-linter": minor +--- + +Rename Gorgon to PerseusLinter diff --git a/packages/perseus-linter/src/__tests__/matcher_test.js b/packages/perseus-linter/src/__tests__/matcher_test.js index 319e61807e..54d8c773c2 100644 --- a/packages/perseus-linter/src/__tests__/matcher_test.js +++ b/packages/perseus-linter/src/__tests__/matcher_test.js @@ -8,7 +8,7 @@ import * as PureMarkdown from "@khanacademy/pure-markdown"; import Selector from "../selector.js"; import TreeTransformer from "../tree-transformer.js"; -describe("Gorgon selector matching:", () => { +describe("PerseusLinter selector matching:", () => { const markdown = ` ### A diff --git a/packages/perseus-linter/src/__tests__/rule_test.js b/packages/perseus-linter/src/__tests__/rule_test.js index 9417c9e1d0..a104f768dc 100644 --- a/packages/perseus-linter/src/__tests__/rule_test.js +++ b/packages/perseus-linter/src/__tests__/rule_test.js @@ -4,7 +4,7 @@ import * as PureMarkdown from "@khanacademy/pure-markdown"; import Rule from "../rule.js"; import TreeTransformer from "../tree-transformer.js"; -describe("Gorgon lint Rules class", () => { +describe("PerseusLinter lint Rules class", () => { const markdown = ` ## This Heading is in Title Case diff --git a/packages/perseus-linter/src/__tests__/selector-parser_test.js b/packages/perseus-linter/src/__tests__/selector-parser_test.js index 42819b4273..249b2eca10 100644 --- a/packages/perseus-linter/src/__tests__/selector-parser_test.js +++ b/packages/perseus-linter/src/__tests__/selector-parser_test.js @@ -1,7 +1,7 @@ // @flow import Selector from "../selector.js"; -describe("gorgon selector parser", () => { +describe("PerseusLinter selector parser", () => { const validExpressions = [ "*", " * ", diff --git a/packages/perseus-linter/src/__tests__/tree-transformer_test.js b/packages/perseus-linter/src/__tests__/tree-transformer_test.js index 97741106c5..e0c086a6bf 100644 --- a/packages/perseus-linter/src/__tests__/tree-transformer_test.js +++ b/packages/perseus-linter/src/__tests__/tree-transformer_test.js @@ -1,7 +1,7 @@ // @flow import TreeTransformer from "../tree-transformer.js"; -describe("gorgon tree transformer", () => { +describe("PerseusLinter tree transformer", () => { function clone(o) { return JSON.parse(JSON.stringify(o)); } diff --git a/packages/perseus-linter/src/index.js b/packages/perseus-linter/src/index.js index b597c077ff..f4bf897cf7 100644 --- a/packages/perseus-linter/src/index.js +++ b/packages/perseus-linter/src/index.js @@ -13,7 +13,7 @@ const allLintRules: $ReadOnlyArray<$FlowFixMe> = AllRules.filter( export {Rule, allLintRules as rules}; // -// Run the Gorgon linter over the specified markdown parse tree, +// Run the Perseus linter over the specified markdown parse tree, // with the specified context object, and // return a (possibly empty) array of lint warning objects. If the // highlight argument is true, this function also modifies the parse diff --git a/packages/perseus-linter/src/rule.js b/packages/perseus-linter/src/rule.js index 97ff6bd85a..33a2c6c10d 100644 --- a/packages/perseus-linter/src/rule.js +++ b/packages/perseus-linter/src/rule.js @@ -1,6 +1,6 @@ // @flow /** - * The Rule class represents a Gorgon lint rule. A Rule instance has a check() + * The Rule class represents a Perseus lint rule. A Rule instance has a check() * method that takes the same (node, state, content) arguments that a * TreeTransformer traversal callback function does. Call the check() method * during a tree traversal to determine whether the current node of the tree @@ -9,7 +9,7 @@ * an error message, and the start and end positions within the node's content * string of the lint. * - * A Gorgon lint rule consists of a name, a severity, a selector, a pattern + * A Perseus lint rule consists of a name, a severity, a selector, a pattern * (RegExp) and two functions. The check() method uses the selector, pattern, * and functions as follows: * @@ -178,7 +178,7 @@ export type LintTester = ( export type AppliesTester = (context: LintRuleContextObject) => boolean; /** - * A Rule object describes a Gorgon lint rule. See the comment at the top of + * A Rule object describes a Perseus lint rule. See the comment at the top of * this file for detailed description. */ export default class Rule { diff --git a/packages/perseus/src/__tests__/perseus-markdown_test.jsx b/packages/perseus/src/__tests__/perseus-markdown_test.jsx index 220ab82e3d..ccb75155cb 100644 --- a/packages/perseus/src/__tests__/perseus-markdown_test.jsx +++ b/packages/perseus/src/__tests__/perseus-markdown_test.jsx @@ -1,5 +1,5 @@ // @flow -import * as Gorgon from "@khanacademy/perseus-linter"; +import * as PerseusLinter from "@khanacademy/perseus-linter"; import PerseusMarkdown from "../perseus-markdown.jsx"; @@ -565,14 +565,14 @@ describe("perseus markdown", () => { "data 4 | $data 5 | data 6\n" + "data 7 | data 8 | data 9"; const context = { - ...Gorgon.linterContextDefault, + ...PerseusLinter.linterContextDefault, content, widgets: {}, }; // Act const parsedWithLint = parse(content); - Gorgon.runLinter(parsedWithLint, context, true); + PerseusLinter.runLinter(parsedWithLint, context, true); // Assert expect(parsedWithLint).toMatchSnapshot(); @@ -650,14 +650,14 @@ describe("perseus markdown", () => { "data 4 | $data 5 | data 6\n" + "data 7 | data 8 | data 9"; const context = { - ...Gorgon.linterContextDefault, + ...PerseusLinter.linterContextDefault, content, widgets: {}, }; // Act const parsedWithLint = parse(content); - Gorgon.runLinter(parsedWithLint, context, true); + PerseusLinter.runLinter(parsedWithLint, context, true); const output = PerseusMarkdown.basicOutput(parsedWithLint); diff --git a/packages/perseus/src/__tests__/renderer_test.jsx b/packages/perseus/src/__tests__/renderer_test.jsx index f1104bd468..7d0cd0923c 100644 --- a/packages/perseus/src/__tests__/renderer_test.jsx +++ b/packages/perseus/src/__tests__/renderer_test.jsx @@ -31,15 +31,15 @@ import type { PerseusInputNumberWidgetOptions, } from "../perseus-types.js"; -// NOTE(jeremy): We can't use an automatic mock for not-gorgon, because one of -// it's "instance" methods is created using `debounce` and Jest doesn't provide -// a mocked instance method for it (I suspect that Jest doesn't see that -// symbol as an instance method). +// NOTE(jeremy): We can't use an automatic mock for the translation linter, +// because one of it's "instance" methods is created using `debounce` and Jest +// doesn't provide a mocked instance method for it (I suspect that Jest doesn't +// see that symbol as an instance method). const mockRunLinter = jest.fn(); const mockApplyLintErrors = jest.fn(); -jest.mock("../not-gorgon.js", () => { - // We mock the NotGorgon constructor here setting things up so we can - // spy/verify calls to instances of NotGorgon +jest.mock("../translation-linter.js", () => { + // We mock the TranslationLinter constructor here setting things up so we + // can spy/verify calls to instances of TranslationLinter return function () { return { runLinter: mockRunLinter, @@ -106,7 +106,7 @@ describe("renderer", () => { }); }); - describe("linting (NotGorgon)", () => { + describe("linting (TranslationLinter)", () => { const extraProps = { linterContext: { contentType: "exercise", @@ -165,7 +165,7 @@ describe("renderer", () => { // Assert expect(renderer.state.jiptContent).toBeNull(); - expect(renderer.state.notGorgonLintErrors).toHaveLength(0); + expect(renderer.state.translationLintErrors).toHaveLength(0); expect(renderer.state.lastUsedWidgetId).toBeNull(); expect(renderer.state.widgetInfo).toStrictEqual(question1.widgets); diff --git a/packages/perseus/src/article-renderer.jsx b/packages/perseus/src/article-renderer.jsx index 4e99b58728..3e386c4b03 100644 --- a/packages/perseus/src/article-renderer.jsx +++ b/packages/perseus/src/article-renderer.jsx @@ -5,7 +5,7 @@ * composed of multiple (Renderer) sections concatenated together. */ -import * as Gorgon from "@khanacademy/perseus-linter"; +import * as PerseusLinter from "@khanacademy/perseus-linter"; import classNames from "classnames"; import PropTypes from "prop-types"; import * as React from "react"; @@ -37,14 +37,14 @@ class ArticleRenderer extends React.Component<$FlowFixMe, $FlowFixMe> { // Whether to use the new Bibliotron styles for articles useNewStyles: PropTypes.bool, - linterContext: Gorgon.linterContextProps, + linterContext: PerseusLinter.linterContextProps, legacyPerseusLint: PropTypes.arrayOf(PropTypes.string), }; static defaultProps: $FlowFixMe = { apiOptions: {}, useNewStyles: false, - linterContext: Gorgon.linterContextDefault, + linterContext: PerseusLinter.linterContextDefault, }; constructor(props: $FlowFixMe) { @@ -197,7 +197,7 @@ class ArticleRenderer extends React.Component<$FlowFixMe, $FlowFixMe> { ); }, }} - linterContext={Gorgon.pushContextStack( + linterContext={PerseusLinter.pushContextStack( this.props.linterContext, "article", )} diff --git a/packages/perseus/src/components/input-with-examples.jsx b/packages/perseus/src/components/input-with-examples.jsx index 0d692aa603..1f1688adad 100644 --- a/packages/perseus/src/components/input-with-examples.jsx +++ b/packages/perseus/src/components/input-with-examples.jsx @@ -1,6 +1,6 @@ /* eslint-disable react/sort-comp */ // @flow -import * as Gorgon from "@khanacademy/perseus-linter"; +import * as PerseusLinter from "@khanacademy/perseus-linter"; import PropTypes from "prop-types"; import * as React from "react"; import _ from "underscore"; @@ -37,7 +37,7 @@ class InputWithExamples extends React.Component<$FlowFixMe, $FlowFixMe> { // A unique string identifying this InputWithExamples id: PropTypes.string.isRequired, - linterContext: Gorgon.linterContextProps, + linterContext: PerseusLinter.linterContextProps, }; static defaultProps: $FlowFixMe = { @@ -46,7 +46,7 @@ class InputWithExamples extends React.Component<$FlowFixMe, $FlowFixMe> { onFocus: function () {}, onBlur: function () {}, disabled: false, - linterContext: Gorgon.linterContextDefault, + linterContext: PerseusLinter.linterContextDefault, }; state: $FlowFixMe = { @@ -178,7 +178,7 @@ class InputWithExamples extends React.Component<$FlowFixMe, $FlowFixMe> {
{ onMouseUp: PropTypes.func.isRequired, onRender: PropTypes.func.isRequired, type: PropTypes.oneOf([STATIC, DRAGGING, ANIMATING, DISABLED]), - linterContext: Gorgon.linterContextProps, + linterContext: PerseusLinter.linterContextProps, }; static defaultProps = { includePadding: true, type: STATIC, - linterContext: Gorgon.linterContextDefault, + linterContext: PerseusLinter.linterContextDefault, }; state: DraggableState = { @@ -214,7 +214,7 @@ class Draggable extends React.Component { > { onMeasure: function () {}, margin: 5, onChange: function () {}, - linterContext: Gorgon.linterContextDefault, + linterContext: PerseusLinter.linterContextDefault, waitForKatexLoad: true, }; @@ -618,7 +618,7 @@ class Sortable extends React.Component { includePadding={this.props.padding} margin={isLast && isStatic ? 0 : margin} endPosition={item.endPosition} - linterContext={Gorgon.pushContextStack( + linterContext={PerseusLinter.pushContextStack( this.props.linterContext, "sortable", )} diff --git a/packages/perseus/src/hint-renderer.jsx b/packages/perseus/src/hint-renderer.jsx index d56cc04f5a..0241cbad0a 100644 --- a/packages/perseus/src/hint-renderer.jsx +++ b/packages/perseus/src/hint-renderer.jsx @@ -1,5 +1,5 @@ // @flow -import * as Gorgon from "@khanacademy/perseus-linter"; +import * as PerseusLinter from "@khanacademy/perseus-linter"; import * as i18n from "@khanacademy/wonder-blocks-i18n"; import {StyleSheet, css} from "aphrodite"; import classnames from "classnames"; @@ -35,7 +35,7 @@ type DefaultProps = {| /* Renders just a hint preview */ class HintRenderer extends React.Component { static defaultProps: DefaultProps = { - linterContext: Gorgon.linterContextDefault, + linterContext: PerseusLinter.linterContextDefault, }; getSerializedState: () => void = () => { @@ -115,7 +115,7 @@ class HintRenderer extends React.Component { images={hint.images} apiOptions={rendererApiOptions} findExternalWidgets={this.props.findExternalWidgets} - linterContext={Gorgon.pushContextStack( + linterContext={PerseusLinter.pushContextStack( this.props.linterContext, "hint", )} diff --git a/packages/perseus/src/hints-renderer.jsx b/packages/perseus/src/hints-renderer.jsx index 448acf38a9..a35e67686d 100644 --- a/packages/perseus/src/hints-renderer.jsx +++ b/packages/perseus/src/hints-renderer.jsx @@ -1,5 +1,5 @@ // @flow -import * as Gorgon from "@khanacademy/perseus-linter"; +import * as PerseusLinter from "@khanacademy/perseus-linter"; import * as i18n from "@khanacademy/wonder-blocks-i18n"; import {StyleSheet, css} from "aphrodite"; import classnames from "classnames"; @@ -42,7 +42,7 @@ type State = {| // eslint-disable-next-line react/no-unsafe class HintsRenderer extends React.Component { static defaultProps: DefaultProps = { - linterContext: Gorgon.linterContextDefault, + linterContext: PerseusLinter.linterContextDefault, }; // The isFinalHelpPage property determines if the user has requested help @@ -180,7 +180,7 @@ class HintsRenderer extends React.Component { key={"hintRenderer" + i} apiOptions={apiOptions} findExternalWidgets={this.props.findExternalWidgets} - linterContext={Gorgon.pushContextStack( + linterContext={PerseusLinter.pushContextStack( this.props.linterContext, "hints[" + i + "]", )} diff --git a/packages/perseus/src/item-renderer.jsx b/packages/perseus/src/item-renderer.jsx index 12846509de..57fed03e2b 100644 --- a/packages/perseus/src/item-renderer.jsx +++ b/packages/perseus/src/item-renderer.jsx @@ -1,6 +1,6 @@ /* eslint-disable react/no-unsafe */ // @flow -import * as Gorgon from "@khanacademy/perseus-linter"; +import * as PerseusLinter from "@khanacademy/perseus-linter"; import $ from "jquery"; import * as React from "react"; import * as ReactDOM from "react-dom"; @@ -87,7 +87,7 @@ class ItemRenderer extends React.Component { initialHintsVisible: 0, workAreaSelector: "#workarea", reviewMode: false, - linterContext: Gorgon.linterContextDefault, + linterContext: PerseusLinter.linterContextDefault, }; constructor(props: Props) { @@ -208,7 +208,7 @@ class ItemRenderer extends React.Component { questionCompleted={this.state.questionCompleted} reviewMode={this.props.reviewMode} savedState={this.props.savedState} - linterContext={Gorgon.pushContextStack( + linterContext={PerseusLinter.pushContextStack( this.props.linterContext, "question", )} @@ -226,7 +226,7 @@ class ItemRenderer extends React.Component { hints={this.props.item.hints} hintsVisible={this.state.hintsVisible} apiOptions={apiOptions} - linterContext={Gorgon.pushContextStack( + linterContext={PerseusLinter.pushContextStack( this.props.linterContext, "hints", )} diff --git a/packages/perseus/src/perseus-markdown.jsx b/packages/perseus/src/perseus-markdown.jsx index 7b1476f7a1..7ae8a8176a 100644 --- a/packages/perseus/src/perseus-markdown.jsx +++ b/packages/perseus/src/perseus-markdown.jsx @@ -110,7 +110,8 @@ const rules = { } else if (node.table.type === "lint") { // The `table` in this node is actually a `lint` node, // not the expected `table` node. This is due to the linter - // implementation "reparenting" the `table` node, see gorgon.js + // implementation "reparenting" the `table` node, see + // perseus-linter/src/index.js if (node.table.content?.type === "table") { // And the `content` of this lint node is the `table` node // which we actually want to render. Thus, we perform diff --git a/packages/perseus/src/renderer.jsx b/packages/perseus/src/renderer.jsx index db705eb68d..ea40704b7f 100644 --- a/packages/perseus/src/renderer.jsx +++ b/packages/perseus/src/renderer.jsx @@ -1,6 +1,6 @@ /* eslint-disable react/no-unsafe */ // @flow -import * as Gorgon from "@khanacademy/perseus-linter"; +import * as PerseusLinter from "@khanacademy/perseus-linter"; import classNames from "classnames"; import $ from "jquery"; import * as React from "react"; @@ -18,11 +18,11 @@ import InteractionTracker from "./interaction-tracker.js"; import Objective from "./interactive2/objective_.js"; import JiptParagraphs from "./jipt-paragraphs.js"; import {Errors, Log} from "./logging/log.js"; -import NotGorgon from "./not-gorgon.js"; // The i18n linter import {ClassNames as ApiClassNames, ApiOptions} from "./perseus-api.jsx"; import {PerseusError} from "./perseus-error.js"; import PerseusMarkdown from "./perseus-markdown.jsx"; import QuestionParagraph from "./question-paragraph.jsx"; +import TranslationLinter from "./translation-linter.js"; import Util from "./util.js"; import preprocessTex from "./util/katex-preprocess.js"; import WidgetContainer from "./widget-container.jsx"; @@ -170,7 +170,7 @@ type Props = {| |}; type State = {| - notGorgonLintErrors: $ReadOnlyArray, + translationLintErrors: $ReadOnlyArray, widgetInfo: $ReadOnly<{|[id: string]: ?WidgetInfo|}>, widgetProps: $ReadOnly<{|[id: string]: ?$FlowFixMe|}>, jiptContent: any, @@ -209,7 +209,7 @@ class Renderer extends React.Component { _isTwoColumn: boolean; // The i18n linter. - _notGorgon: NotGorgon; + _translationLinter: TranslationLinter; lastRenderedMarkdown: React.Element; reuseMarkdown: boolean; @@ -233,20 +233,20 @@ class Renderer extends React.Component { reviewMode: false, serializedState: null, onSerializedStateUpdated: () => {}, - linterContext: Gorgon.linterContextDefault, + linterContext: PerseusLinter.linterContextDefault, }; constructor(props: Props, context: Context) { super(props, context); - this._notGorgon = new NotGorgon(); + this._translationLinter = new TranslationLinter(); this.state = { jiptContent: null, - // NotGorgon is async and currently does not contain a location. - // This is a list of error strings NotGorgon detected on its last - // run. - notGorgonLintErrors: [], + // TranslationLinter is async and currently does not contain a + // location. This is a list of error strings TranslationLinter + // detected on its last run. + translationLintErrors: [], // The ID of the last widget the user interacted with. We'll // use this to set the `isLastUsedWidget` flag on the @@ -275,9 +275,9 @@ class Renderer extends React.Component { if (this.props.linterContext.highlightLint) { // Get i18n lint errors asynchronously. If there are lint errors, // this component will be rerendered. - this._notGorgon.runLinter( + this._translationLinter.runLinter( this.props.content, - this.handleNotGorgonLintErrors, + this.handletranslationLintErrors, ); } } @@ -343,8 +343,8 @@ class Renderer extends React.Component { !newJipt && oldContent === newContent && _.isEqual( - this.state.notGorgonLintErrors, - nextState.notGorgonLintErrors, + this.state.translationLintErrors, + nextState.translationLintErrors, ) && // If we are running the linter then we need to know when // widgets have changed because we need for force the linter to @@ -391,9 +391,9 @@ class Renderer extends React.Component { if (this.props.linterContext.highlightLint) { // Get i18n lint errors asynchronously. If lint errors have changed // since the last run, this component will be rerendered. - this._notGorgon.runLinter( + this._translationLinter.runLinter( this.props.content, - this.handleNotGorgonLintErrors, + this.handletranslationLintErrors, ); } } @@ -537,7 +537,7 @@ class Renderer extends React.Component { type={type} initialProps={this.getWidgetProps(id)} shouldHighlight={shouldHighlight} - linterContext={Gorgon.pushContextStack( + linterContext={PerseusLinter.pushContextStack( this.props.linterContext, "widget", )} @@ -1780,18 +1780,17 @@ class Renderer extends React.Component { return examples[0]; }; - // NotGorgon callback - handleNotGorgonLintErrors: (lintErrors: $ReadOnlyArray) => void = ( - lintErrors: $ReadOnlyArray, - ) => { - if (!this._isMounted) { - return; - } + // TranslationLinter callback + handletranslationLintErrors: (lintErrors: $ReadOnlyArray) => void = + (lintErrors: $ReadOnlyArray) => { + if (!this._isMounted) { + return; + } - this.setState({ - notGorgonLintErrors: lintErrors, - }); - }; + this.setState({ + translationLintErrors: lintErrors, + }); + }; render(): React.Node { const apiOptions = this.getApiOptions(); @@ -1885,12 +1884,12 @@ class Renderer extends React.Component { ...this.props.linterContext, }; - Gorgon.runLinter(parsedMarkdown, context, true); + PerseusLinter.runLinter(parsedMarkdown, context, true); - // Apply the lint errors from the last NotGorgon run. + // Apply the lint errors from the last TranslationLinter run. // TODO(joshuan): Support overlapping dots. - this._notGorgon.applyLintErrors(parsedMarkdown, [ - ...this.state.notGorgonLintErrors, + this._translationLinter.applyLintErrors(parsedMarkdown, [ + ...this.state.translationLintErrors, ...(this.props.legacyPerseusLint || []), ]); } diff --git a/packages/perseus/src/not-gorgon.js b/packages/perseus/src/translation-linter.js similarity index 88% rename from packages/perseus/src/not-gorgon.js rename to packages/perseus/src/translation-linter.js index fbf12d29ca..6151201f60 100644 --- a/packages/perseus/src/not-gorgon.js +++ b/packages/perseus/src/translation-linter.js @@ -3,14 +3,11 @@ import {Rule} from "@khanacademy/perseus-linter"; import {debounce} from "underscore"; /** - * NotGorgon asynchronously calls Khan Academy's poentry linter. + * TranslationLinter asynchronously calls Khan Academy's poentry linter. * * The poentry linter checks for issues that prevent content from being - * translated. This linter is KA-specific and so NotGorgon does not do anything - * in non-KA environments. - * - * NotGorgon is named as such because it is not Gorgon, Perseus' built-in - * linter. + * translated. This linter is KA-specific and so TranslationLinter does not do + * anything in non-KA environments. */ // A LintCB is called once the linter has been run. @@ -20,7 +17,7 @@ type LintCB = (errors: $ReadOnlyArray) => void; // last call. The timer is reset if the lint is called during the wait. const DEBOUNCE_TIMEOUT = 1000; -export default class NotGorgon { +export default class TranslationLinter { // To avoid linting when nothing has changed. previousContent: ?string = null; @@ -101,17 +98,17 @@ export default class NotGorgon { /** * Applies an array of errors generated by linters without position - * information (NotGorgon and the legacy getSaveWarnings()) to the top - * of a Perseus tree. + * information (TranslationLinter and the legacy getSaveWarnings()) to the + * top of a Perseus tree. */ applyLintErrors( parsedMarkdown: any, - notGorgonLintErrors: $ReadOnlyArray, + translationLintErrors: $ReadOnlyArray, ) { // These lint errors do not have position data associated with // them, so we just plop them at the top. - if (notGorgonLintErrors.length) { - const errorText = notGorgonLintErrors.join("\n\n"); + if (translationLintErrors.length) { + const errorText = translationLintErrors.join("\n\n"); parsedMarkdown.unshift({ content: { type: "text",