Skip to content

Commit

Permalink
v0.1.0 - react 15 support for reals dude
Browse files Browse the repository at this point in the history
needed a little tweak to children handling for void elements like <img />

also:
* update dependencies
* jshint -> eslint
* react-tools -> babel
  • Loading branch information
jenseng committed Jun 15, 2016
1 parent afa920a commit e4966e2
Show file tree
Hide file tree
Showing 18 changed files with 299 additions and 65 deletions.
4 changes: 4 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"presets": ["es2015", "react"],
"plugins": ["transform-react-jsx"]
}
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/examples
/dist
229 changes: 229 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,229 @@
env:
es6: true
node: true
jasmine: true
jest: true
extends: 'eslint:recommended'
parserOptions:
ecmaFeatures:
experimentalObjectRestSpread: true
jsx: true
sourceType: module
plugins:
- react
rules:
accessor-pairs: error
array-bracket-spacing:
- error
- never
array-callback-return: error
arrow-body-style: error
arrow-parens: error
arrow-spacing: error
block-scoped-var: error
block-spacing:
- error
- always
brace-style: 'off'
callback-return: error
camelcase:
- error
- properties: never
comma-spacing:
- error
- after: true
before: false
comma-style:
- error
- last
complexity: error
computed-property-spacing:
- error
- never
consistent-return: 'off'
consistent-this: error
curly: 'off'
default-case: error
dot-location:
- error
- property
dot-notation: error
eol-last: error
eqeqeq: error
func-names: 'off'
func-style: 'off'
generator-star-spacing: error
global-require: 'off'
guard-for-in: 'off'
handle-callback-err: error
id-blacklist: error
id-length: 'off'
id-match: error
indent: 'off'
init-declarations: 'off'
jsx-quotes:
- error
- prefer-single
key-spacing: 'off'
keyword-spacing:
- error
- after: true
before: true
linebreak-style:
- error
- unix
lines-around-comment: error
max-depth: error
max-len: 'off'
max-lines: 'off'
max-nested-callbacks: error
max-params: 'off'
max-statements: 'off'
max-statements-per-line: error
new-parens: error
newline-after-var: 'off'
newline-before-return: 'off'
newline-per-chained-call: error
no-alert: error
no-array-constructor: error
no-bitwise: error
no-caller: error
no-catch-shadow: error
no-confusing-arrow: error
no-continue: 'off'
no-div-regex: error
no-duplicate-imports: error
no-else-return: 'off'
no-empty-function: error
no-eq-null: error
no-eval: error
no-extend-native: error
no-extra-bind: error
no-extra-label: error
no-extra-parens: 'off'
no-floating-decimal: error
no-implicit-globals: error
no-implied-eval: error
no-inline-comments: error
no-inner-declarations:
- error
- functions
no-invalid-this: 'off'
no-iterator: error
no-label-var: error
no-labels: error
no-lone-blocks: error
no-lonely-if: error
no-loop-func: error
no-magic-numbers: 'off'
no-mixed-operators: error
no-mixed-requires: error
no-multi-spaces: 'off'
no-multi-str: error
no-multiple-empty-lines: error
no-native-reassign: error
no-negated-condition: error
no-nested-ternary: error
no-new: error
no-new-func: error
no-new-object: error
no-new-require: error
no-new-wrappers: error
no-octal-escape: error
no-param-reassign: 'off'
no-path-concat: 'off'
no-plusplus: 'off'
no-process-env: error
no-process-exit: error
no-proto: error
no-prototype-builtins: 'off'
no-restricted-globals: error
no-restricted-imports: error
no-restricted-modules: error
no-restricted-syntax: error
no-return-assign: error
no-script-url: error
no-self-compare: error
no-sequences: error
no-shadow: 'off'
no-shadow-restricted-names: error
no-spaced-func: error
no-sync: error
no-ternary: 'off'
no-throw-literal: error
no-trailing-spaces: error
no-undef-init: error
no-undefined: error
no-underscore-dangle: error
no-unmodified-loop-condition: error
no-unneeded-ternary: error
no-unsafe-finally: error
no-unused-expressions: error
no-use-before-define: 'off'
no-useless-call: error
no-useless-computed-key: error
no-useless-concat: error
no-useless-constructor: error
no-useless-escape: error
no-useless-rename: error
no-var: 'off'
no-void: error
no-warning-comments: error
no-whitespace-before-property: error
no-with: error
object-curly-newline: error
object-curly-spacing: 'off'
object-property-newline: error
object-shorthand: 'off'
one-var: 'off'
one-var-declaration-per-line: 'off'
operator-assignment:
- error
- always
operator-linebreak: error
padded-blocks: 'off'
prefer-arrow-callback: 'off'
prefer-const: error
prefer-reflect: 'off'
prefer-rest-params: 'off'
prefer-spread: 'off'
prefer-template: 'off'
quote-props: 'off'
quotes: 'off'
radix: error
"react/jsx-uses-react": 1
require-jsdoc: 'off'
require-yield: error
rest-spread-spacing: error
semi: error
semi-spacing:
- error
- after: true
before: false
sort-imports: error
sort-vars: 'off'
space-before-blocks: 'off'
space-before-function-paren: 'off'
space-in-parens:
- error
- never
space-infix-ops: error
space-unary-ops: error
spaced-comment:
- error
- always
strict: error
template-curly-spacing:
- error
- never
unicode-bom:
- error
- never
valid-jsdoc: error
vars-on-top: 'off'
wrap-iife: error
wrap-regex: error
yield-star-spacing: error
yoda:
- error
- never
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v6.2.1
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
before_script: 'npm install'
language: node_js
node_js:
- "6"
2 changes: 1 addition & 1 deletion ComponentInterpolator.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var injectNewDescendants = function(element, newDescendants, props, ensureInject
newDescendants.injectedCount++;
}

props.children = children;
props.children = children.length ? children : null;
if (ensureInjected) {
invariant(newDescendants.injectedCount === 1, 'wrappers must have a single "$1" text descendant');
}
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# react-i18nliner

[<img src="https://travis-ci.org/jenseng/react-i18nliner.svg" />](http://travis-ci.org/jenseng/react-i18nliner)

react-i18nliner brings [I18nliner](https://github.com/jenseng/i18nliner-js)
to React via the [html `translate` attribute](http://www.w3.org/International/questions/qa-translate-flag). I18n doesn't get any easier than this.

Expand Down
11 changes: 6 additions & 5 deletions __tests__/ComponentInterpolator.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
var subjector = require('../test_utils/subjector');
var Subject = subjector(__dirname + '/../ComponentInterpolator');
var React = require('react');
var ReactDOM = require('react-dom');

var removeNoise = function(string) {
return string.replace(/<span.*?>|<\/span>/g, '')
return string.replace(/<!--.*?-->/g, '')
.replace(/ data-reactid=".*?"/g, '');
};

Expand All @@ -14,15 +15,15 @@ describe('ComponentInterpolator', function() {
wrappers: {}
}, ["$1"]);
expect(subject.isMounted()).toEqual(true);
expect(subject.getDOMNode().textContent).toEqual('Hello World');
expect(ReactDOM.findDOMNode(subject).textContent).toEqual('Hello World');
});

it('escapes html in the string', function() {
var subject = Subject({
string: 'My favorite tag is <script />',
wrappers: {}
}, ["$1"]);
expect(subject.getDOMNode().textContent).toEqual('My favorite tag is <script />');
expect(ReactDOM.findDOMNode(subject).textContent).toEqual('My favorite tag is <script />');
});

it('interpolates wrapper components', function() {
Expand All @@ -34,7 +35,7 @@ describe('ComponentInterpolator', function() {
'***': <b><em>$1</em></b>
}
}, [<hr />, "$1"]);
expect(removeNoise(subject.getDOMNode().innerHTML)).toEqual(
expect(removeNoise(ReactDOM.findDOMNode(subject).innerHTML)).toEqual(
'<hr>Ohai, Jane, click <a href="/"><img>here</a> right <b><em>now <i>please</i> </em></b>'
);
});
Expand All @@ -47,7 +48,7 @@ describe('ComponentInterpolator', function() {
user_id: 0,
count: <input />
}, ["$1"]);
expect(removeNoise(subject.getDOMNode().innerHTML)).toEqual(
expect(removeNoise(ReactDOM.findDOMNode(subject).innerHTML)).toEqual(
'Hi Jane (0), create <input> new accounts'
);
});
Expand Down
2 changes: 1 addition & 1 deletion browserify-transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var config = I18nliner.config;
var preprocess = require("./preprocess");
var hasTranslatableText = require("./hasTranslatableText")(config);

module.exports = function(file) {
module.exports = function() {
return through(function (buf, enc, next) {
var source = buf.toString('utf8');
if (hasTranslatableText(source))
Expand Down
2 changes: 0 additions & 2 deletions dist/.gitignore

This file was deleted.

Loading

0 comments on commit e4966e2

Please sign in to comment.