Skip to content

Commit

Permalink
Breaking: Migrate Annotations UI into React (#251)
Browse files Browse the repository at this point in the history
  • Loading branch information
pramodsum authored Oct 30, 2018
1 parent 2bfc2f1 commit d853b80
Show file tree
Hide file tree
Showing 190 changed files with 26,564 additions and 14,773 deletions.
82 changes: 78 additions & 4 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,16 +1,76 @@
{
"presets": [
["es2015", { "modules": false }],
["es2015", {
"modules": false
}],
"es2016",
"react"
"react",
"flow"
],
"plugins": [
"transform-class-properties",
"transform-object-rest-spread"
"transform-object-rest-spread",
"transform-regenerator"
],
"env": {
"dev": {
"presets": [
["env", {
"modules": false,
"targets": {
"browsers": ["last 1 Chrome versions", "last 1 Firefox versions"]
}
}],
"stage-1",
"react",
"flow"
],
"plugins": [
"flow-react-proptypes", [
"react-intl",
{
"enforceDescriptions": true,
"messagesDir": "./i18n/json"
}
]
]
},
"production": {
"presets": [
["env", {
"modules": false
}],
"stage-1",
"react",
"flow"
],
"plugins": [
[
"react-intl",
{
"enforceDescriptions": true,
"messagesDir": "./i18n/json"
}
]
]
},
"npm": {
"presets": [
["env", {
"modules": false
}],
"stage-1",
"react",
"flow"
],
"plugins": [
[
"react-intl",
{
"enforceDescriptions": true,
"messagesDir": "./i18n/json"
}
],
[
"babel-plugin-transform-require-ignore", {
"extensions": [".scss", ".css"]
Expand All @@ -19,8 +79,22 @@
]
},
"test": {
"presets": [
["env", {
"modules": false
}],
"stage-1",
"react",
"flow"
],
"plugins": [
"transform-es2015-modules-commonjs",
"transform-es2015-modules-commonjs", [
"react-intl",
{
"enforceDescriptions": false,
"messagesDir": "./i18n/json"
}
],
[
"babel-plugin-transform-require-ignore", {
"extensions": [".scss", ".css"]
Expand Down
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ dist/*
docs/*
lib/*
index.js
flow/**
flow-typed/**
148 changes: 53 additions & 95 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
"parser": "babel-eslint",
"extends": [
"airbnb",
"plugin:flowtype/recommended",
"plugin:react/recommended",
"prettier",
"prettier/flowtype",
"prettier/react"
],
"env": {
Expand Down Expand Up @@ -31,102 +34,57 @@
"jest": false
},
"rules": {
"quotes": [
"error",
"single"
],
"comma-dangle": [
"error",
"never"
],
"indent": [
"error",
4,
{
"SwitchCase": 1
"camelcase": ["off"],
"react/jsx-boolean-value": ["off"],
"react/no-unused-prop-types": ["off"],
"react/default-props-match-prop-types": ["off", {
"allowRequiredDefaults": true
}],
"react/sort-comp": ["off"],
"react/forbid-prop-types": ["off"],
"no-param-reassign": ["error", {
"props": false
}],
"react/require-default-props": ["off"],
"react/display-name": ["off"],
"quotes": ["error", "single"],
"comma-dangle": ["error", "never"],
"indent": ["error", 4, {
"SwitchCase": 1
}],
"import/imports-first": ["off"],
"jsx-quotes": ["error", "prefer-single"],
"max-len": ["off"],
"react/jsx-indent-props": ["error", 4],
"react/jsx-indent": ["error", 4],
"no-underscore-dangle": ["off"],
"react/jsx-filename-extension": ["off"],
"arrow-body-style": ["off"],
"class-methods-use-this": ["off"],
"arrow-parens": ["error", "always"],
"no-plusplus": ["error", {
"allowForLoopAfterthoughts": true
}],
"import/no-extraneous-dependencies": ["off"],
"import/no-webpack-loader-syntax": ["off"],
"valid-jsdoc": ["warn", {
"prefer": {
"returns": "return",
"class": "constructor"
},
"preferType": {
"array": "Array",
"function": "Function",
"object": "Object",
"Boolean": "boolean",
"Number": "number",
"String": "string"
}
],
"import/imports-first": [
"off"
],
"jsx-quotes": [
"error",
"prefer-single"
],
"max-len": [
"off"
],
"react/jsx-indent-props": [
"error",
4
],
"react/jsx-indent": [
"error",
4
],
"no-underscore-dangle": [
"off"
],
"react/jsx-filename-extension": [
"off"
],
"arrow-body-style": [
"off"
],
"class-methods-use-this": [
"off"
],
"arrow-parens": [
"error",
"always"
],
"no-plusplus": [
"error",
{
"allowForLoopAfterthoughts": true
}
],
"import/no-extraneous-dependencies": [
"off"
],
"import/no-webpack-loader-syntax": [
"off"
],
"require-jsdoc": [
"warn",
{
"require": {
"FunctionDeclaration": true,
"MethodDefinition": false,
"ClassDeclaration": false,
"ArrowFunctionExpression": true
}
}
],
"valid-jsdoc": [
"warn",
{
"prefer": {
"returns": "return",
"class": "constructor"
},
"preferType": {
"array": "Array",
"function": "Function",
"object": "Object",
"Boolean": "boolean",
"Number": "number",
"String": "string"
}
}
],
"prefer-destructuring": [
"error",
{
"object": true,
"array": false
}
]
}],
"prefer-destructuring": ["error", {
"object": true,
"array": false
}]
},
"settings": {
"import/resolver": {
Expand Down
35 changes: 35 additions & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[ignore]
.*/build/.*
.*/lib/.*
.*/functional-tests/.*
.*/test-utils/.*
.*/reports/.*
.*/node_modules/babel-plugin-flow-react-proptypes.*
.*/node_modules/conventional-changelog*
.*/node_modules/eslint*
.*/node_modules/jest*
.*/node_modules/npm-shrinkwrap.*
.*/node_modules/stylelint.*
.*/node_modules/webpack*
.*/node_modules/draft-js*
.*/node_modules/findup*
.*/node_modules/rangy*

[include]
./src

[libs]

[options]
module.name_mapper.extension='scss' -> '<PROJECT_ROOT>/flow/SCSSFlowStub.js.flow'
module.name_mapper.extension='css' -> '<PROJECT_ROOT>/flow/SCSSFlowStub.js.flow'
module.name_mapper='react-intl-locale-data' -> '<PROJECT_ROOT>/flow/WebpackI18N.js.flow'
module.name_mapper='box-annotations-locale-data' -> '<PROJECT_ROOT>/flow/WebpackI18N.js.flow'
module.name_mapper='box-react-ui-locale-data' -> '<PROJECT_ROOT>/flow/WebpackI18N.js.flow'
module.name_mapper='draft-js' -> '<PROJECT_ROOT>/flow/DraftJSFlowStub.js.flow'
module.name_mapper='draft-js/EditorState' -> '<PROJECT_ROOT>/flow/DraftJSFlowStub.js.flow'
module.name_mapper='rangy' -> '<PROJECT_ROOT>/flow/Rangy.js.flow'
module.name_mapper='rangy/lib/rangy-classapplier' -> '<PROJECT_ROOT>/flow/Rangy.js.flow'
module.name_mapper='rangy/lib/rangy-highlighter' -> '<PROJECT_ROOT>/flow/Rangy.js.flow'
module.name_mapper='rangy/lib/rangy-selectionsaverestore' -> '<PROJECT_ROOT>/flow/Rangy.js.flow'
suppress_comment= \\(.\\|\n\\)*\\$FlowFixMe
4 changes: 2 additions & 2 deletions .stylelintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"rules": {
"indentation": 4,
"at-rule-no-vendor-prefix": true,
"at-rule-no-unknown": [true, { "ignoreAtRules": ["include", "mixin"] }],
"at-rule-no-unknown": [true, { "ignoreAtRules": ["include", "mixin", "extend"] }],
"media-feature-name-no-vendor-prefix": true,
"property-no-vendor-prefix": true,
"selector-no-vendor-prefix": true,
Expand All @@ -17,4 +17,4 @@
"no-descending-specificity": null,
"order/properties-alphabetical-order": [true, { "severity": "warning" }]
}
}
}
13 changes: 6 additions & 7 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
// Place your settings in this file to overwrite default and user settings.
{
"editor.rulers": [
120
],
"flow.enabled": false,
"typescript.validate.enable": false,
"typescript.format.enable": false,
"flow.pathToFlow": "${workspaceRoot}/node_modules/.bin/flow",
"flow.useNPMPackagedFlow": true,
"flow.enabled": true,
"javascript.validate.enable": false,
"prettier.eslintIntegration": true,
"prettier.printWidth": 120,
"prettier.singleQuote": true,
"prettier.tabWidth": 4,
"typescript.format.enable": false,
"typescript.validate.enable": false
"prettier.singleQuote": true
}
19 changes: 19 additions & 0 deletions build/TranslationsPlugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* eslint-disable strict */

'use strict';

const path = require('path');
const buildTranslations = require('box-react-ui/lib/build-utils/buildTranslations');

const i18n = path.resolve('i18n'); // Where the .properties files are dumped
const jsonDir = path.join(i18n, 'json'); // Where the react-intl plugin dumps json

function TranslationsPlugin() {}
TranslationsPlugin.prototype.buildTranslations = () => {
buildTranslations(i18n, jsonDir);
};
TranslationsPlugin.prototype.apply = function apply(compiler) {
compiler.plugin('done', this.buildTranslations);
};

module.exports = TranslationsPlugin;
20 changes: 20 additions & 0 deletions build/build_locale.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const { execSync } = require('child_process');

/**
* Build a single locale
*
* @param {string} locale - locale to build
* @param {*} callback - callback from worker-farm master process
* @return {void}
*/
module.exports = (locale, callback) => {
try {
console.log(`Building ${locale}`);
// build assets for a single locale
execSync(`time LANGUAGE=${locale} yarn run build-prod`);
callback();
} catch (error) {
console.error(`Error: Failed to build ${locale}`);
callback(true);
}
};
7 changes: 7 additions & 0 deletions build/enzyme-adapter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import 'core-js/es6/map';
import 'core-js/es6/set';
import 'raf/polyfill';
import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';

Enzyme.configure({ adapter: new Adapter() });
Loading

0 comments on commit d853b80

Please sign in to comment.