@khanacademy/perseus-linter 0.4.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var perseusError = require('@khanacademy/perseus-error');
6
5
  var perseusCore = require('@khanacademy/perseus-core');
7
6
  var PropTypes = require('prop-types');
8
7
 
@@ -29,7 +28,7 @@ class Selector {
29
28
  * subclasses must provide an implementation of this method.
30
29
  */
31
30
  match(state) {
32
- throw new perseusError.PerseusError("Selector subclasses must implement match()", perseusError.Errors.NotAllowed);
31
+ throw new perseusCore.PerseusError("Selector subclasses must implement match()", perseusCore.Errors.NotAllowed);
33
32
  }
34
33
 
35
34
  /**
@@ -561,7 +560,7 @@ class Rule {
561
560
  constructor(name, severity, selector, pattern, lint, applies) {
562
561
  var _this = this;
563
562
  if (!selector && !pattern) {
564
- throw new perseusError.PerseusError("Lint rules must have a selector or pattern", perseusError.Errors.InvalidInput, {
563
+ throw new perseusCore.PerseusError("Lint rules must have a selector or pattern", perseusCore.Errors.InvalidInput, {
565
564
  metadata: {
566
565
  name
567
566
  }
@@ -1159,14 +1158,6 @@ nested lists are hard to read on mobile devices;
1159
1158
  do not use additional indentation.`
1160
1159
  });
1161
1160
 
1162
- var Profanity = Rule.makeRule({
1163
- name: "profanity",
1164
- // This list could obviously be expanded a lot, but I figured we
1165
- // could start with https://en.wikipedia.org/wiki/Seven_dirty_words
1166
- pattern: /\b(shit|piss|fuck|cunt|cocksucker|motherfucker|tits)\b/i,
1167
- message: "Avoid profanity"
1168
- });
1169
-
1170
1161
  var TableMissingCells = Rule.makeRule({
1171
1162
  name: "table-missing-cells",
1172
1163
  severity: Rule.Severity.WARNING,
@@ -1214,7 +1205,7 @@ do not put widgets inside of tables.`
1214
1205
  });
1215
1206
 
1216
1207
  // TODO(davidflanagan):
1217
- var AllRules = [AbsoluteUrl, BlockquotedMath, BlockquotedWidget, DoubleSpacingAfterTerminal, ExtraContentSpacing, HeadingLevel1, HeadingLevelSkip, HeadingSentenceCase, HeadingTitleCase, ImageAltText, ImageInTable, LinkClickHere, LongParagraph, MathAdjacent, MathAlignExtraBreak, MathAlignLinebreaks, MathEmpty, MathFontSize, MathFrac, MathNested, MathStartsWithSpace, MathTextEmpty, NestedLists, TableMissingCells, UnescapedDollar, WidgetInTable, Profanity, MathWithoutDollars, UnbalancedCodeDelimiters, ImageSpacesAroundUrls, ImageWidget];
1208
+ var AllRules = [AbsoluteUrl, BlockquotedMath, BlockquotedWidget, DoubleSpacingAfterTerminal, ExtraContentSpacing, HeadingLevel1, HeadingLevelSkip, HeadingSentenceCase, HeadingTitleCase, ImageAltText, ImageInTable, LinkClickHere, LongParagraph, MathAdjacent, MathAlignExtraBreak, MathAlignLinebreaks, MathEmpty, MathFontSize, MathFrac, MathNested, MathStartsWithSpace, MathTextEmpty, NestedLists, TableMissingCells, UnescapedDollar, WidgetInTable, MathWithoutDollars, UnbalancedCodeDelimiters, ImageSpacesAroundUrls, ImageWidget];
1218
1209
 
1219
1210
  /**
1220
1211
  * TreeTransformer is a class for traversing and transforming trees. Create a
@@ -1571,7 +1562,7 @@ class TraversalState {
1571
1562
  replace() {
1572
1563
  const parent = this._containers.top();
1573
1564
  if (!parent) {
1574
- throw new perseusError.PerseusError("Can't replace the root of the tree", perseusError.Errors.Internal);
1565
+ throw new perseusCore.PerseusError("Can't replace the root of the tree", perseusCore.Errors.Internal);
1575
1566
  }
1576
1567
 
1577
1568
  // The top of the container stack is either an array or an object
@@ -1624,7 +1615,7 @@ class TraversalState {
1624
1615
  */
1625
1616
  goToPreviousSibling() {
1626
1617
  if (!this.hasPreviousSibling()) {
1627
- throw new perseusError.PerseusError("goToPreviousSibling(): node has no previous sibling", perseusError.Errors.Internal);
1618
+ throw new perseusCore.PerseusError("goToPreviousSibling(): node has no previous sibling", perseusCore.Errors.Internal);
1628
1619
  }
1629
1620
  this._currentNode = this.previousSibling();
1630
1621
  // Since we know that we have a previous sibling, we know that
@@ -1654,7 +1645,7 @@ class TraversalState {
1654
1645
  */
1655
1646
  goToParent() {
1656
1647
  if (!this.hasParent()) {
1657
- throw new perseusError.PerseusError("goToParent(): node has no ancestor", perseusError.Errors.NotAllowed);
1648
+ throw new perseusCore.PerseusError("goToParent(): node has no ancestor", perseusCore.Errors.NotAllowed);
1658
1649
  }
1659
1650
  this._currentNode = this._ancestors.pop();
1660
1651
 
@@ -1761,7 +1752,7 @@ class Stack {
1761
1752
 
1762
1753
  // This file is processed by a Rollup plugin (replace) to inject the production
1763
1754
  const libName = "@khanacademy/perseus-linter";
1764
- const libVersion = "0.4.0";
1755
+ const libVersion = "1.0.0";
1765
1756
  perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
1766
1757
 
1767
1758
  // Define the shape of the linter context object that is passed through the