فهرست منبع

Merge commit '6f0be54ace27db59654dbee0ce1922f189e1ae5e' into feat/tag-form-with-typeahead

# Conflicts:
#	src/client/js/app.js
#	yarn.lock
yusuketk 7 سال پیش
والد
کامیت
5413731751

+ 2 - 89
.eslintrc.js

@@ -1,18 +1,9 @@
 module.exports = {
-  parser: 'babel-eslint',
-  parserOptions: {
-    ecmaFeatures: {
-      jsx: true
-    }
-  },
   extends: [
-    'airbnb-base',
-    'airbnb/rules/react',
+    'weseek',
+    'weseek/react',
   ],
   env: {
-    browser: true,
-    node: true,
-    es6: true,
     mocha: true,
     jquery: true,
   },
@@ -24,58 +15,9 @@ module.exports = {
     window: true,
   },
   plugins: [
-    'react',
     'chai-friendly',
   ],
   rules: {
-    'arrow-body-style': ['error', 'always'],
-    'brace-style': [
-      'error',
-      'stroustrup',
-      { allowSingleLine: true },
-    ],
-    'class-methods-use-this': 'off',
-    'consistent-return': 'off',
-    'default-case': 'off',
-    'func-names': 'off',
-    'global-require': 'off',
-    'key-spacing': [
-      'error',
-      { mode: 'minimum' },
-    ],
-    'max-len': ['error',
-      {
-        code: 160,
-        ignoreTrailingComments: true,
-      },
-    ],
-    'no-continue': 'off',
-    'no-param-reassign': [
-      'error',
-      { props: false },
-    ],
-    'no-plusplus': 'off',
-    // Allow only for-of
-    // https://qiita.com/the_red/items/0c826e97b57da6d67621
-    'no-restricted-syntax': [
-      'error',
-      {
-        selector: 'ForInStatement',
-        message: 'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.',
-      },
-      {
-        selector: 'LabeledStatement',
-        message: 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
-      },
-      {
-        selector: 'WithStatement',
-        message: '`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
-      },
-    ],
-    'no-shadow': 'off',
-    'no-underscore-dangle': 'off',
-    'no-useless-return': 'off',
-    'prefer-destructuring': 'off',
     'indent': [
       'error',
       2,
@@ -87,40 +29,11 @@ module.exports = {
         FunctionExpression: { body: 1, parameters: 2 },
       },
     ],
-    'no-unused-vars': [
-      'error',
-      { args: 'none' },
-    ],
-    'padded-blocks': [
-      'error',
-      { classes: 'always' },
-    ],
-    'radix': 'off',
-    'semi': [
-      'error',
-      'always',
-      { omitLastInOneLineBlock: true },
-    ],
-    'space-before-function-paren': [
-      'error',
-      'never',
-    ],
-    'react/destructuring-assignment': 'off',
-    'react/forbid-prop-types': 'off',
     'react/jsx-filename-extension': [
       'warn',
       { extensions: ['.jsx']},
     ],
-    'react/no-unused-prop-types': 'off',
-    'react/jsx-one-expression-per-line': 'off',
-    'react/no-access-state-in-setstate': 'off',
-    'react/prefer-stateless-function': 'off',
-    'react/require-default-props': 'off',
-    'react/self-closing-comp': 'off',
-    'react/sort-comp': 'off',
     // eslint-plugin-import rules
-    'import/no-extraneous-dependencies': 'off',
-    'import/no-dynamic-require': 'off',
     'import/no-unresolved': [2, { ignore: ['^@'] }], // ignore @alias/..., @commons/..., ...
     // eslint-plugin-chai-friendly rules
     'no-unused-expressions': 0,

+ 1 - 1
.vscode/extensions.json

@@ -14,6 +14,6 @@
 	],
 	// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
 	"unwantedRecommendations": [
-
+    "hookyqr.beautify",
 	]
 }

+ 1 - 1
package.json

@@ -154,7 +154,7 @@
     "diff2html": "^2.3.3",
     "eazy-logger": "^3.0.2",
     "eslint": "^5.15.1",
-    "eslint-config-airbnb": "^17.1.0",
+    "eslint-config-weseek": "^1.0.1",
     "eslint-plugin-chai-friendly": "^0.4.1",
     "eslint-plugin-import": "^2.16.0",
     "eslint-plugin-react": "^7.12.4",

+ 1 - 3
src/client/js/app.js

@@ -296,7 +296,7 @@ if (pageId) {
   componentMappings['page-attachment'] = <PageAttachment pageId={pageId} markdown={markdown} crowi={crowi} />;
 }
 if (pagePath) {
-  componentMappings.page = <Page crowi={crowi} crowiRenderer={crowiRenderer} markdown={markdown} pagePath={pagePath} showHeadEditButton onSaveWithShortcut={saveWithShortcut} />;
+  componentMappings.page = <Page crowi={crowi} crowiRenderer={crowiRenderer} markdown={markdown} pagePath={pagePath} onSaveWithShortcut={saveWithShortcut} />;
   componentMappings['revision-path'] = <RevisionPath pageId={pageId} pagePath={pagePath} crowi={crowi} />;
   componentMappings['revision-url'] = <RevisionUrl pageId={pageId} pagePath={pagePath} />;
 }
@@ -362,7 +362,6 @@ if (savePageControlsElem) {
             }
           }}
         pageId={pageId}
-        pagePath={pagePath}
         slackChannels={slackChannels}
         grant={grant}
         grantGroupId={grantGroupId}
@@ -493,7 +492,6 @@ if (pageStatusAlertElem) {
   ReactDOM.render(
     <I18nextProvider i18n={i18n}>
       <PageStatusAlert
-        crowi={crowi}
         ref={(elem) => {
             if (pageStatusAlert == null) {
               pageStatusAlert = elem.getWrappedInstance();

+ 0 - 1
src/client/js/components/Page.jsx

@@ -69,5 +69,4 @@ Page.propTypes = {
   onSaveWithShortcut: PropTypes.func.isRequired,
   markdown: PropTypes.string.isRequired,
   pagePath: PropTypes.string.isRequired,
-  showHeadEditButton: PropTypes.bool,
 };

+ 0 - 3
src/client/js/components/PageComment/CommentForm.jsx

@@ -337,9 +337,6 @@ export default class CommentForm extends React.Component {
                           && (
                           <div className="form-inline align-self-center mr-md-2">
                             <SlackNotification
-                              crowi={this.props.crowi}
-                              pageId={this.props.pageId}
-                              pagePath={this.props.pagePath}
                               isSlackEnabled={this.state.isSlackEnabled}
                               slackChannels={this.state.slackChannels}
                               onEnabledFlagChange={this.onSlackEnabledFlagChange}

+ 2 - 0
src/client/js/components/PageEditor/AbstractEditor.js

@@ -1,3 +1,5 @@
+/* eslint-disable react/no-unused-prop-types */
+
 import React from 'react';
 import PropTypes from 'prop-types';
 

+ 0 - 1
src/client/js/components/PageStatusAlert.jsx

@@ -134,7 +134,6 @@ class PageStatusAlert extends React.Component {
 
 PageStatusAlert.propTypes = {
   t: PropTypes.func.isRequired, // i18next
-  crowi: PropTypes.object.isRequired,
   hasDraftOnHackmd: PropTypes.bool.isRequired,
   revisionId: PropTypes.string,
   revisionIdHackmdSynced: PropTypes.string,

+ 12 - 11
src/client/js/components/SavePageControls.jsx

@@ -52,22 +52,24 @@ class SavePageControls extends React.PureComponent {
     const { t } = this.props;
 
     const config = this.props.crowi.getConfig();
+    const hasSlackConfig = config.hasSlackConfig;
     const isAclEnabled = config.isAclEnabled;
     const labelSubmitButton = this.state.pageId == null ? t('Create') : t('Update');
     const labelOverwriteScopes = t('page_edit.overwrite_scopes', { operation: labelSubmitButton });
 
     return (
       <div className="d-flex align-items-center form-inline">
-        <div className="mr-2">
-          <SlackNotification
-            ref={(c) => { this.slackNotification = c }}
-            crowi={this.props.crowi}
-            pageId={this.props.pageId}
-            pagePath={this.props.pagePath}
-            isSlackEnabled={false}
-            slackChannels={this.props.slackChannels}
-          />
-        </div>
+        {hasSlackConfig
+          && (
+          <div className="mr-2">
+            <SlackNotification
+              ref={(c) => { this.slackNotification = c }}
+              isSlackEnabled={false}
+              slackChannels={this.props.slackChannels}
+            />
+          </div>
+          )
+        }
 
         {isAclEnabled
           && (
@@ -113,7 +115,6 @@ SavePageControls.propTypes = {
   onSubmit: PropTypes.func.isRequired,
   pageId: PropTypes.string,
   // for SlackNotification
-  pagePath: PropTypes.string,
   slackChannels: PropTypes.string,
   // for GrantSelector
   grant: PropTypes.number,

+ 0 - 3
src/client/js/components/SlackNotification.jsx

@@ -79,9 +79,6 @@ export default class SlackNotification extends React.Component {
 }
 
 SlackNotification.propTypes = {
-  crowi: PropTypes.object.isRequired,
-  pageId: PropTypes.string,
-  pagePath: PropTypes.string,
   isSlackEnabled: PropTypes.bool,
   slackChannels: PropTypes.string,
   onChannelChange: PropTypes.func,

+ 2 - 2
src/client/js/util/GrowiRenderer.js

@@ -143,7 +143,7 @@ export default class GrowiRenderer {
       if (!this.preProcessors[i].process) {
         continue;
       }
-      processed = this.preProcessors[i].process(markdown);
+      processed = this.preProcessors[i].process(processed);
     }
 
     return processed;
@@ -159,7 +159,7 @@ export default class GrowiRenderer {
       if (!this.postProcessors[i].process) {
         continue;
       }
-      processed = this.postProcessors[i].process(html);
+      processed = this.postProcessors[i].process(processed);
     }
 
     return processed;

+ 1 - 4
src/server/crowi/index.js

@@ -315,10 +315,7 @@ Crowi.prototype.setupSlack = function() {
   const Config = this.model('Config');
 
   return new Promise(((resolve, reject) => {
-    if (!Config.hasSlackConfig(config)) {
-      self.slack = {};
-    }
-    else {
+    if (Config.hasSlackConfig(config)) {
       self.slack = require('../util/slack')(self);
     }
 

+ 1 - 2
src/server/routes/page.js

@@ -93,9 +93,8 @@ module.exports = function(crowi, app) {
         logger.error('Error occured in updating slack channels: ', err);
       });
 
-    if (crowi.slack) {
+    if (Config.hasSlackConfig(config)) {
       const promises = slackChannels.split(',').map((chan) => {
-        logger.debug('crowi.slack is exist', crowi.slack);
         return crowi.slack.postPage(page, user, chan, updateOrCreate, previousRevision);
       });
 

+ 37 - 24
yarn.lock

@@ -17,11 +17,12 @@
   dependencies:
     "@babel/highlight" "^7.0.0"
 
-"@babel/generator@^7.3.4":
-  version "7.3.4"
-  resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.3.4.tgz#9aa48c1989257877a9d971296e5b73bfe72e446e"
+"@babel/generator@^7.4.0":
+  version "7.4.0"
+  resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.4.0.tgz#c230e79589ae7a729fd4631b9ded4dc220418196"
+  integrity sha512-/v5I+a1jhGSKLgZDcmAUZ4K/VePi43eRkUs3yePW1HB1iANOD5tqJXwGSG4BZhSksP8J9ejSlwGeTiiOFZOrXQ==
   dependencies:
-    "@babel/types" "^7.3.4"
+    "@babel/types" "^7.4.0"
     jsesc "^2.5.1"
     lodash "^4.17.11"
     source-map "^0.5.0"
@@ -41,11 +42,12 @@
   dependencies:
     "@babel/types" "^7.0.0"
 
-"@babel/helper-split-export-declaration@^7.0.0":
-  version "7.0.0"
-  resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.0.0.tgz#3aae285c0311c2ab095d997b8c9a94cad547d813"
+"@babel/helper-split-export-declaration@^7.4.0":
+  version "7.4.0"
+  resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.4.0.tgz#571bfd52701f492920d63b7f735030e9a3e10b55"
+  integrity sha512-7Cuc6JZiYShaZnybDmfwhY4UYHzI6rlqhWjaIqbsJGsIqPimEYy5uh3akSRLMg65LSdSEnJ8a8/bWQN6u2oMGw==
   dependencies:
-    "@babel/types" "^7.0.0"
+    "@babel/types" "^7.4.0"
 
 "@babel/highlight@^7.0.0":
   version "7.0.0"
@@ -55,9 +57,10 @@
     esutils "^2.0.2"
     js-tokens "^4.0.0"
 
-"@babel/parser@^7.0.0", "@babel/parser@^7.2.2", "@babel/parser@^7.3.4":
-  version "7.3.4"
-  resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.3.4.tgz#a43357e4bbf4b92a437fb9e465c192848287f27c"
+"@babel/parser@^7.0.0", "@babel/parser@^7.4.0":
+  version "7.4.2"
+  resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.4.2.tgz#b4521a400cb5a871eab3890787b4bc1326d38d91"
+  integrity sha512-9fJTDipQFvlfSVdD/JBtkiY0br9BtfvW2R8wo6CX/Ej2eMuV0gWPk1M67Mt3eggQvBqYW1FCEk8BN7WvGm/g5g==
 
 "@babel/runtime@^7.1.2":
   version "7.3.1"
@@ -66,30 +69,33 @@
     regenerator-runtime "^0.12.0"
 
 "@babel/template@^7.1.0":
-  version "7.2.2"
-  resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.2.2.tgz#005b3fdf0ed96e88041330379e0da9a708eb2907"
+  version "7.4.0"
+  resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.4.0.tgz#12474e9c077bae585c5d835a95c0b0b790c25c8b"
+  integrity sha512-SOWwxxClTTh5NdbbYZ0BmaBVzxzTh2tO/TeLTbF6MO6EzVhHTnff8CdBXx3mEtazFBoysmEM6GU/wF+SuSx4Fw==
   dependencies:
     "@babel/code-frame" "^7.0.0"
-    "@babel/parser" "^7.2.2"
-    "@babel/types" "^7.2.2"
+    "@babel/parser" "^7.4.0"
+    "@babel/types" "^7.4.0"
 
 "@babel/traverse@^7.0.0":
-  version "7.3.4"
-  resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.3.4.tgz#1330aab72234f8dea091b08c4f8b9d05c7119e06"
+  version "7.4.0"
+  resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.4.0.tgz#14006967dd1d2b3494cdd650c686db9daf0ddada"
+  integrity sha512-/DtIHKfyg2bBKnIN+BItaIlEg5pjAnzHOIQe5w+rHAw/rg9g0V7T4rqPX8BJPfW11kt3koyjAnTNwCzb28Y1PA==
   dependencies:
     "@babel/code-frame" "^7.0.0"
-    "@babel/generator" "^7.3.4"
+    "@babel/generator" "^7.4.0"
     "@babel/helper-function-name" "^7.1.0"
-    "@babel/helper-split-export-declaration" "^7.0.0"
-    "@babel/parser" "^7.3.4"
-    "@babel/types" "^7.3.4"
+    "@babel/helper-split-export-declaration" "^7.4.0"
+    "@babel/parser" "^7.4.0"
+    "@babel/types" "^7.4.0"
     debug "^4.1.0"
     globals "^11.1.0"
     lodash "^4.17.11"
 
-"@babel/types@^7.0.0", "@babel/types@^7.2.2", "@babel/types@^7.3.4":
-  version "7.3.4"
-  resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.3.4.tgz#bf482eaeaffb367a28abbf9357a94963235d90ed"
+"@babel/types@^7.0.0", "@babel/types@^7.4.0":
+  version "7.4.0"
+  resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.4.0.tgz#670724f77d24cce6cc7d8cf64599d511d164894c"
+  integrity sha512-aPvkXyU2SPOnztlgo8n9cEiXW755mgyvueUPcpStqdzoSPm0fjO0vQBjLkt3JKJW7ufikfcnMTTPsN1xaTsBPA==
   dependencies:
     esutils "^2.0.2"
     lodash "^4.17.11"
@@ -3500,6 +3506,13 @@ eslint-config-airbnb@^17.1.0:
     object.assign "^4.1.0"
     object.entries "^1.0.4"
 
+eslint-config-weseek@^1.0.1:
+  version "1.0.1"
+  resolved "https://registry.yarnpkg.com/eslint-config-weseek/-/eslint-config-weseek-1.0.1.tgz#f8291c0af8f7001cf3c0b7b60c97c01a9cf5422c"
+  integrity sha512-zwF2a08COqmx74wv9WV0QUdYdM4XeAHGGxYASKihHxfL6yq/thAGDf1fYormMaI6RCpaSYntwjf2O8aEegQogw==
+  dependencies:
+    eslint-config-airbnb "^17.1.0"
+
 eslint-import-resolver-node@^0.3.2:
   version "0.3.2"
   resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.2.tgz#58f15fb839b8d0576ca980413476aab2472db66a"