فهرست منبع

removed interop, cleanup

Steven Fukase 4 سال پیش
والد
کامیت
7ba74e44f5

+ 0 - 1
packages/app/package.json

@@ -160,7 +160,6 @@
     "@atlaskit/navigation-next": "^8.0.5",
     "@handsontable/react": "=2.1.0",
     "@textlint/kernel": "^12.0.2",
-    "@textlint/module-interop": "^12.0.2",
     "@types/compression": "^1.7.0",
     "@types/express": "^4.17.11",
     "@types/multer": "^1.4.5",

+ 16 - 34
packages/app/src/client/util/codemirror/codemirror-textlint.js

@@ -1,56 +1,38 @@
 import { TextlintKernel } from '@textlint/kernel';
-import { moduleInterop } from '@textlint/module-interop';
 import textlintToCodeMirror from 'textlint-message-to-codemirror';
 
+const ruleModulesList = {
+  'max-comma': require('textlint-rule-max-comma').default,
+  'common-misspellings': require('textlint-rule-common-misspellings').default,
+};
+
 const kernel = new TextlintKernel();
 
 let textlintOption = {};
 
-const createSetupRules = (rules, ruleOptions) => {
-  return Object.keys(rules).map((ruleName) => {
-    console.log(ruleName);
-    return {
+const createSetupRules = (rules, ruleOptions) => (
+  Object.keys(rules).map(ruleName => (
+    {
       ruleId: ruleName,
       rule: rules[ruleName],
       options: ruleOptions[ruleName],
-    };
-  });
-};
-
-
-export default function createValidator() {
-  const enabledRules = [
-    {
-      name: 'max-comma',
-      rule: moduleInterop(require('textlint-rule-max-comma')),
-      options: {
-        max: 2,
-      },
-    },
-    {
-      name: 'common-misspellings',
-      rule: moduleInterop(require('textlint-rule-common-misspellings')),
-      options: {
-        ignore: [
-          'isnt',
-          'yuo',
-          'carefull',
-        ],
-      },
-    },
-  ];
+    }
+  ))
+);
 
 
-  const rules = enabledRules.reduce((rules, rule) => {
-    rules[rule.name] = rule.rule;
+export default function createValidator(rulesConfigArray) {
+  const rules = rulesConfigArray.reduce((rules, rule) => {
+    rules[rule.name] = ruleModulesList[rule.name];
     return rules;
   }, {});
 
-  const rulesOption = enabledRules.reduce((rules, rule) => {
+  const rulesOption = rulesConfigArray.reduce((rules, rule) => {
     rules[rule.name] = rule.options || {};
     return rules;
   }, {});
 
+
   textlintOption = Object.assign(
     {},
     {

+ 11 - 3
packages/app/src/components/PageEditor/CodeMirrorEditor.jsx

@@ -860,15 +860,23 @@ export default class CodeMirrorEditor extends AbstractEditor {
   render() {
     const mode = this.state.isGfmMode ? 'gfm-growi' : undefined;
     const additionalClasses = Array.from(this.state.additionalClassSet).join(' ');
+    const placeholder = this.state.isGfmMode ? 'Input with Markdown..' : 'Input with Plain Text..';
+
+    // TODO: Get config from db
     const textlintValidator = createValidator([
       {
         name: 'max-comma',
+      },
+      {
+        name: 'common-misspellings',
         options: {
-          max: 2,
+          ignore: [
+            'isnt',
+            'yuo',
+          ],
         },
       },
-      'common-misspellings']);
-    const placeholder = this.state.isGfmMode ? 'Input with Markdown..' : 'Input with Plane Text..';
+    ]);
 
     return (
       <React.Fragment>

+ 0 - 5
yarn.lock

@@ -2516,11 +2516,6 @@
     traverse "^0.6.6"
     unified "^6.2.0"
 
-"@textlint/module-interop@^12.0.2":
-  version "12.0.2"
-  resolved "https://registry.yarnpkg.com/@textlint/module-interop/-/module-interop-12.0.2.tgz#1edbf8caa5eba572cd9b20ba617968552de74290"
-  integrity sha512-jnFx7B7Q/au49n5Kt/ttPhecvnJGj7643KzPxRNXy422nmafi1EfOZDMGkNEJhlVsQ9WzAnliTTXTFTrBhtVYA==
-
 "@textlint/source-code-fixer@^12.0.2":
   version "12.0.2"
   resolved "https://registry.yarnpkg.com/@textlint/source-code-fixer/-/source-code-fixer-12.0.2.tgz#a41adcebde81592ff4c48bd5dc8133740b3a3ada"