Skip to content

Commit

Permalink
Rename Gorgon -> PerseusLinter, NotGorgon -> TranslationLinter (#251)
Browse files Browse the repository at this point in the history
## 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: #251
  • Loading branch information
jeremywiebe authored May 26, 2022
1 parent 2bfc2f8 commit 2578bd1
Show file tree
Hide file tree
Showing 20 changed files with 102 additions and 92 deletions.
6 changes: 6 additions & 0 deletions .changeset/breezy-moons-approve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@khanacademy/perseus": minor
"@khanacademy/perseus-linter": minor
---

Rename NotGorgon to TranslationLinter
6 changes: 6 additions & 0 deletions .changeset/chilly-shirts-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@khanacademy/perseus": minor
"@khanacademy/perseus-linter": minor
---

Rename Gorgon to PerseusLinter
2 changes: 1 addition & 1 deletion packages/perseus-linter/src/__tests__/matcher_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/perseus-linter/src/__tests__/rule_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @flow
import Selector from "../selector.js";

describe("gorgon selector parser", () => {
describe("PerseusLinter selector parser", () => {
const validExpressions = [
"*",
" * ",
Expand Down
Original file line number Diff line number Diff line change
@@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion packages/perseus-linter/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions packages/perseus-linter/src/rule.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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:
*
Expand Down Expand Up @@ -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 {
Expand Down
10 changes: 5 additions & 5 deletions packages/perseus/src/__tests__/perseus-markdown_test.jsx
Original file line number Diff line number Diff line change
@@ -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";

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);

Expand Down
18 changes: 9 additions & 9 deletions packages/perseus/src/__tests__/renderer_test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -106,7 +106,7 @@ describe("renderer", () => {
});
});

describe("linting (NotGorgon)", () => {
describe("linting (TranslationLinter)", () => {
const extraProps = {
linterContext: {
contentType: "exercise",
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions packages/perseus/src/article-renderer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -197,7 +197,7 @@ class ArticleRenderer extends React.Component<$FlowFixMe, $FlowFixMe> {
);
},
}}
linterContext={Gorgon.pushContextStack(
linterContext={PerseusLinter.pushContextStack(
this.props.linterContext,
"article",
)}
Expand Down
8 changes: 4 additions & 4 deletions packages/perseus/src/components/input-with-examples.jsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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 = {
Expand All @@ -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 = {
Expand Down Expand Up @@ -178,7 +178,7 @@ class InputWithExamples extends React.Component<$FlowFixMe, $FlowFixMe> {
<div id={this._getUniqueId()}>
<Renderer
content={examplesContent}
linterContext={Gorgon.pushContextStack(
linterContext={PerseusLinter.pushContextStack(
this.props.linterContext,
"input-with-examples",
)}
Expand Down
3 changes: 2 additions & 1 deletion packages/perseus/src/components/lint.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// @flow
/**
* This component renders "lint" nodes in a markdown parse tree. Lint nodes
* are inserted into the tree by the Gorgon linter (see src/gorgon/gorgon.js).
* are inserted into the tree by the Perseus linter (see
* perseus-linter/src/index).
*
* This component serves multiple purposes
*
Expand Down
12 changes: 6 additions & 6 deletions packages/perseus/src/components/sortable.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @babel/no-invalid-this, react/forbid-prop-types, react/no-unsafe, react/sort-comp */
// @flow
import * as Gorgon from "@khanacademy/perseus-linter";
import * as PerseusLinter from "@khanacademy/perseus-linter";
import {CircularSpinner} from "@khanacademy/wonder-blocks-progress-spinner";
import {StyleSheet, css} from "aphrodite";
import $ from "jquery";
Expand Down Expand Up @@ -95,13 +95,13 @@ class Draggable extends React.Component<DraggableProps, DraggableState> {
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 = {
Expand Down Expand Up @@ -214,7 +214,7 @@ class Draggable extends React.Component<DraggableProps, DraggableState> {
>
<Renderer
content={this.props.content}
linterContext={Gorgon.pushContextStack(
linterContext={PerseusLinter.pushContextStack(
this.props.linterContext,
"draggable",
)}
Expand Down Expand Up @@ -422,7 +422,7 @@ class Sortable extends React.Component<SortableProps, SortableState> {
onMeasure: function () {},
margin: 5,
onChange: function () {},
linterContext: Gorgon.linterContextDefault,
linterContext: PerseusLinter.linterContextDefault,
waitForKatexLoad: true,
};

Expand Down Expand Up @@ -618,7 +618,7 @@ class Sortable extends React.Component<SortableProps, SortableState> {
includePadding={this.props.padding}
margin={isLast && isStatic ? 0 : margin}
endPosition={item.endPosition}
linterContext={Gorgon.pushContextStack(
linterContext={PerseusLinter.pushContextStack(
this.props.linterContext,
"sortable",
)}
Expand Down
6 changes: 3 additions & 3 deletions packages/perseus/src/hint-renderer.jsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -35,7 +35,7 @@ type DefaultProps = {|
/* Renders just a hint preview */
class HintRenderer extends React.Component<Props> {
static defaultProps: DefaultProps = {
linterContext: Gorgon.linterContextDefault,
linterContext: PerseusLinter.linterContextDefault,
};

getSerializedState: () => void = () => {
Expand Down Expand Up @@ -115,7 +115,7 @@ class HintRenderer extends React.Component<Props> {
images={hint.images}
apiOptions={rendererApiOptions}
findExternalWidgets={this.props.findExternalWidgets}
linterContext={Gorgon.pushContextStack(
linterContext={PerseusLinter.pushContextStack(
this.props.linterContext,
"hint",
)}
Expand Down
6 changes: 3 additions & 3 deletions packages/perseus/src/hints-renderer.jsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -42,7 +42,7 @@ type State = {|
// eslint-disable-next-line react/no-unsafe
class HintsRenderer extends React.Component<Props, State> {
static defaultProps: DefaultProps = {
linterContext: Gorgon.linterContextDefault,
linterContext: PerseusLinter.linterContextDefault,
};

// The isFinalHelpPage property determines if the user has requested help
Expand Down Expand Up @@ -180,7 +180,7 @@ class HintsRenderer extends React.Component<Props, State> {
key={"hintRenderer" + i}
apiOptions={apiOptions}
findExternalWidgets={this.props.findExternalWidgets}
linterContext={Gorgon.pushContextStack(
linterContext={PerseusLinter.pushContextStack(
this.props.linterContext,
"hints[" + i + "]",
)}
Expand Down
8 changes: 4 additions & 4 deletions packages/perseus/src/item-renderer.jsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -87,7 +87,7 @@ class ItemRenderer extends React.Component<Props, State> {
initialHintsVisible: 0,
workAreaSelector: "#workarea",
reviewMode: false,
linterContext: Gorgon.linterContextDefault,
linterContext: PerseusLinter.linterContextDefault,
};

constructor(props: Props) {
Expand Down Expand Up @@ -208,7 +208,7 @@ class ItemRenderer extends React.Component<Props, State> {
questionCompleted={this.state.questionCompleted}
reviewMode={this.props.reviewMode}
savedState={this.props.savedState}
linterContext={Gorgon.pushContextStack(
linterContext={PerseusLinter.pushContextStack(
this.props.linterContext,
"question",
)}
Expand All @@ -226,7 +226,7 @@ class ItemRenderer extends React.Component<Props, State> {
hints={this.props.item.hints}
hintsVisible={this.state.hintsVisible}
apiOptions={apiOptions}
linterContext={Gorgon.pushContextStack(
linterContext={PerseusLinter.pushContextStack(
this.props.linterContext,
"hints",
)}
Expand Down
3 changes: 2 additions & 1 deletion packages/perseus/src/perseus-markdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit 2578bd1

Please sign in to comment.