Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1436 from matrix-org/luke/lint-jsx-curly-spacing
Browse files Browse the repository at this point in the history
Add eslint rule to disallow spaces inside of curly braces
  • Loading branch information
lukebarnard1 committed Sep 28, 2017
2 parents f3d155b + 07b6040 commit 6a988a0
Show file tree
Hide file tree
Showing 48 changed files with 368 additions and 356 deletions.
13 changes: 13 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,19 @@ module.exports = {
}],
"react/jsx-key": ["error"],

// Assert no spacing in JSX curly brackets
// <Element prop={ consideredError} prop={notConsideredError} />
//
// https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/jsx-curly-spacing.md
"react/jsx-curly-spacing": ["error", {"when": "never", "children": {"when": "always"}}],

// Assert spacing before self-closing JSX tags, and no spacing before or
// after the closing slash, and no spacing after the opening bracket of
// the opening tag or closing tag.
//
// https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/jsx-tag-spacing.md
"react/jsx-tag-spacing": ["error"],

/** flowtype **/
"flowtype/require-parameter-type": ["warn", {
"excludeArrowFunctions": true,
Expand Down
4 changes: 1 addition & 3 deletions jenkins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ npm run test -- --no-colors
npm run lintall -- -f checkstyle -o eslint.xml || true

# re-run the linter, excluding any files known to have errors or warnings.
./node_modules/.bin/eslint --max-warnings 0 \
--ignore-path .eslintignore.errorfiles \
src test
npm run lintwithexclusions

# delete the old tarball, if it exists
rm -f matrix-react-sdk-*.tgz
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"start": "parallelshell \"npm run build:watch\" \"npm run reskindex:watch\"",
"lint": "eslint src/",
"lintall": "eslint src/ test/",
"lintwithexclusions": "eslint --max-warnings 0 --ignore-path .eslintignore.errorfiles src test",
"clean": "rimraf lib",
"prepublish": "npm run clean && npm run build && git rev-parse HEAD > git-revision.txt",
"test": "karma start --single-run=true --browsers ChromeHeadless",
Expand Down Expand Up @@ -99,7 +100,7 @@
"eslint-config-google": "^0.7.1",
"eslint-plugin-babel": "^4.0.1",
"eslint-plugin-flowtype": "^2.30.0",
"eslint-plugin-react": "^6.9.0",
"eslint-plugin-react": "^7.4.0",
"expect": "^1.16.0",
"json-loader": "^0.5.3",
"karma": "^1.7.0",
Expand Down
4 changes: 1 addition & 3 deletions scripts/travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,4 @@ npm run test
./.travis-test-riot.sh

# run the linter, but exclude any files known to have errors or warnings.
./node_modules/.bin/eslint --max-warnings 0 \
--ignore-path .eslintignore.errorfiles \
src test
npm run lintwithexclusions
4 changes: 2 additions & 2 deletions src/SlashCommands.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ const commands = {
title: _t("Ignored user"),
description: (
<div>
<p>{_t("You are now ignoring %(userId)s", {userId: userId})}</p>
<p>{ _t("You are now ignoring %(userId)s", {userId: userId}) }</p>
</div>
),
hasCancelButton: false,
Expand All @@ -281,7 +281,7 @@ const commands = {
title: _t("Unignored user"),
description: (
<div>
<p>{_t("You are no longer ignoring %(userId)s", {userId: userId})}</p>
<p>{ _t("You are no longer ignoring %(userId)s", {userId: userId}) }</p>
</div>
),
hasCancelButton: false,
Expand Down
8 changes: 4 additions & 4 deletions src/async-components/views/dialogs/ExportE2eKeysDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,13 @@ export default React.createClass({
) }
</p>
<div className='error'>
{this.state.errStr}
{ this.state.errStr }
</div>
<div className='mx_E2eKeysDialog_inputTable'>
<div className='mx_E2eKeysDialog_inputRow'>
<div className='mx_E2eKeysDialog_inputLabel'>
<label htmlFor='passphrase1'>
{_t("Enter passphrase")}
{ _t("Enter passphrase") }
</label>
</div>
<div className='mx_E2eKeysDialog_inputCell'>
Expand All @@ -155,7 +155,7 @@ export default React.createClass({
<div className='mx_E2eKeysDialog_inputRow'>
<div className='mx_E2eKeysDialog_inputLabel'>
<label htmlFor='passphrase2'>
{_t("Confirm passphrase")}
{ _t("Confirm passphrase") }
</label>
</div>
<div className='mx_E2eKeysDialog_inputCell'>
Expand All @@ -172,7 +172,7 @@ export default React.createClass({
disabled={disableForm}
/>
<button onClick={this._onCancelClick} disabled={disableForm}>
{_t("Cancel")}
{ _t("Cancel") }
</button>
</div>
</form>
Expand Down
10 changes: 5 additions & 5 deletions src/async-components/views/dialogs/ImportE2eKeysDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,13 @@ export default React.createClass({
) }
</p>
<div className='error'>
{this.state.errStr}
{ this.state.errStr }
</div>
<div className='mx_E2eKeysDialog_inputTable'>
<div className='mx_E2eKeysDialog_inputRow'>
<div className='mx_E2eKeysDialog_inputLabel'>
<label htmlFor='importFile'>
{_t("File to import")}
{ _t("File to import") }
</label>
</div>
<div className='mx_E2eKeysDialog_inputCell'>
Expand All @@ -153,14 +153,14 @@ export default React.createClass({
<div className='mx_E2eKeysDialog_inputRow'>
<div className='mx_E2eKeysDialog_inputLabel'>
<label htmlFor='passphrase'>
{_t("Enter passphrase")}
{ _t("Enter passphrase") }
</label>
</div>
<div className='mx_E2eKeysDialog_inputCell'>
<input ref='passphrase' id='passphrase'
size='64' type='password'
onChange={this._onFormChange}
disabled={disableForm}/>
disabled={disableForm} />
</div>
</div>
</div>
Expand All @@ -170,7 +170,7 @@ export default React.createClass({
disabled={!this.state.enableSubmit || disableForm}
/>
<button onClick={this._onCancelClick} disabled={disableForm}>
{_t("Cancel")}
{ _t("Cancel") }
</button>
</div>
</form>
Expand Down
4 changes: 2 additions & 2 deletions src/autocomplete/CommandProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export default class CommandProvider extends AutocompleteProvider {
component: (<TextualCompletion
title={result.command}
subtitle={result.args}
description={ _t(result.description) }
description={_t(result.description)}
/>),
range,
};
Expand All @@ -150,7 +150,7 @@ export default class CommandProvider extends AutocompleteProvider {

renderCompletions(completions: [React.Component]): ?React.Component {
return <div className="mx_Autocomplete_Completion_container_block">
{completions}
{ completions }
</div>;
}
}
2 changes: 1 addition & 1 deletion src/autocomplete/RoomProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export default class RoomProvider extends AutocompleteProvider {

renderCompletions(completions: [React.Component]): ?React.Component {
return <div className="mx_Autocomplete_Completion_container_pill mx_Autocomplete_Completion_container_truncate">
{completions}
{ completions }
</div>;
}
}
Loading

0 comments on commit 6a988a0

Please sign in to comment.