Skip to content

Commit 7b0faf9

Browse files
committed
Merge pull request #60 from salesforce-ux/documentation
Documentation
2 parents 1a92ccf + 362ab1d commit 7b0faf9

File tree

8 files changed

+230
-165
lines changed

8 files changed

+230
-165
lines changed

.eslintrc

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
{
2+
"parser": "babel-eslint",
3+
"env": {
4+
"browser": true,
5+
"node": true,
6+
"es6": true
7+
},
8+
9+
"plugins": ["react"],
10+
11+
"ecmaFeatures": {
12+
"arrowFunctions": true,
13+
"binaryLiterals": true,
14+
"blockBindings": true,
15+
"classes": true,
16+
"defaultParams": true,
17+
"destructuring": true,
18+
"forOf": true,
19+
"generators": true,
20+
"modules": true,
21+
"objectLiteralComputedProperties": true,
22+
"objectLiteralDuplicateProperties": true,
23+
"objectLiteralShorthandMethods": true,
24+
"objectLiteralShorthandProperties": true,
25+
"octalLiterals": true,
26+
"regexUFlag": true,
27+
"regexYFlag": true,
28+
"spread": true,
29+
"superInFunctions": true,
30+
"templateStrings": true,
31+
"unicodeCodePointEscapes": true,
32+
"globalReturn": true,
33+
"jsx": true
34+
},
35+
36+
"rules": {
37+
38+
//
39+
// Errors
40+
//
41+
// These are rules you must adhere to (please)
42+
//
43+
"no-dupe-keys": 2, // disallow duplicate keys when creating object literals
44+
"no-dupe-args": 2, // disallow duplicate arguments in functions
45+
"no-extra-semi": 2, // disallow unnecessary semicolons
46+
"valid-typeof": 2, // Ensure that the results of typeof are compared against a valid string
47+
"no-native-reassign": 2, // disallow reassignments of native objects
48+
49+
50+
//
51+
// Warnings - Stylistic Issues
52+
//
53+
// These rules are for code consistency and following best practices
54+
//
55+
"default-case": 1, // require default case in switch statements (off by default)
56+
"dot-notation": 1, // encourages use of dot notation whenever possible
57+
"eqeqeq": 1, // require the use of === and !==
58+
"indent": [1, 2], // this option sets a specific tab width for your code (off by default)
59+
"brace-style": 1, // enforce one true brace style (off by default)
60+
"camelcase": 1, // require camel case names
61+
"key-spacing": [1, {"beforeColon": false, "afterColon": true}], // enforces spacing between keys and values in object literal properties
62+
63+
64+
//
65+
// Strict Mode
66+
//
67+
// These rules relate to using strict mode.
68+
//
69+
"strict": 0, // controls location of Use Strict Directives. 0: required by `babel-eslint`
70+
71+
72+
73+
//
74+
// Variables
75+
//
76+
// These rules have to do with variable declarations.
77+
//
78+
"no-redeclare": 2, // disallow declaring the same variable more then once
79+
"no-unused-vars": 2, // disallow declaration of variables that are not used in the code
80+
81+
82+
83+
//
84+
// eslint-plugin-react
85+
//
86+
// React specific linting rules for ESLint
87+
//
88+
"react/display-name": 1, // Prevent missing displayName in a React component definition
89+
"react/jsx-no-undef": 2, // Disallow undeclared variables in JSX
90+
"react/no-multi-comp": 1, // Prevent multiple component definition per file
91+
"react/no-unknown-property": 2, // Prevent usage of unknown DOM property
92+
"react/prop-types": 1, // Prevent missing props validation in a React component definition
93+
}
94+
}

components/SLDSButton/index.js

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,45 +9,45 @@ Neither the name of salesforce.com, inc. nor the names of its contributors may b
99
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1010
*/
1111

12-
import React from 'react';
13-
const classNames = require('classnames');
14-
import createChainedFunction from '../utils/create-chained-function';
15-
import {ButtonIcon, Icon} from '../SLDSIcons.js';
16-
import omit from 'lodash.omit';
12+
import React from "react";
13+
const classNames = require("classnames");
14+
import createChainedFunction from "../utils/create-chained-function";
15+
import {ButtonIcon} from "../SLDSIcons.js";
16+
import omit from "lodash.omit";
1717

1818
class Button extends React.Component {
1919

2020
constructor(props) {
2121
super(props);
22-
this.displayName = 'SLDSButton';
22+
this.displayName = "SLDSButton";
2323
this.state = { active: false };
24-
};
24+
}
2525

2626
componentWillMount(){
2727
/*===============================
28-
TODO: refactor so that React doesn't throw warnings in console
28+
TODO: refactor so that React doesn"t throw warnings in console
2929
for (var key in this.props) {
30-
if(this.props.hasOwnProperty(key) && typeof(this.props[key]) === 'string' && key !== 'label'){
30+
if(this.props.hasOwnProperty(key) && typeof(this.props[key]) === "string" && key !== "label"){
3131
this.props[key] = this.props[key].toLowerCase();
3232
}
3333
}
3434
===============================*/
3535
}
3636

37-
onClick(e) {
37+
onClick() {
3838
this.setState({ active: !this.state.active });
3939
}
4040

4141
getClassName() {
4242
let isSelected = this.props.stateful && this.state.active ? true : false;
4343
let notSelected = this.props.stateful && !this.state.active ? true : false;
44-
return classNames(this.props.className, 'slds-button', {
44+
return classNames(this.props.className, "slds-button", {
4545
[`slds-button--${this.props.variant}`]: this.props.variant,
4646
[`slds-button--icon-${this.props.iconVariant}`]: this.props.iconVariant,
47-
['slds-max-small-button--stretch']: this.props.responsive,
48-
['slds-not-selected']: notSelected,
49-
['slds-is-selected']: isSelected,
50-
['slds-button--icon-inverse']: this.props.inverse,
47+
["slds-max-small-button--stretch"]: this.props.responsive,
48+
["slds-not-selected"]: notSelected,
49+
["slds-is-selected"]: isSelected,
50+
["slds-button--icon-inverse"]: this.props.inverse,
5151
});
5252
}
5353

@@ -69,25 +69,25 @@ class Button extends React.Component {
6969
}
7070

7171
renderIconMore(){
72-
if(this.props.iconVariant === 'more'){
72+
if(this.props.iconVariant === "more"){
7373
return(
7474
<ButtonIcon
7575
variant={this.props.variant}
7676
disabled={this.props.disabled}
7777
inverse={this.props.inverse}
78-
name='down'
79-
size='x-small'
78+
name="down"
79+
size="x-small"
8080
/>
8181
);
8282
}
8383
}
8484

8585

8686
render() {
87-
const props = omit(this.props,'className');
87+
const props = omit(this.props, "className");
8888
const click = createChainedFunction(this.props.onClick, this.onClick.bind(this));
89-
const labelClasses = this.props.variant === 'icon' ? 'slds-assistive-text': '';
90-
if (this.props.disabled) { props['disabled'] = 'disabled' };
89+
const labelClasses = this.props.variant === "icon" ? "slds-assistive-text": "";
90+
if (this.props.disabled) { props["disabled"] = "disabled" };
9191

9292
if(this.props.stateful){
9393
return (
@@ -109,10 +109,10 @@ class Button extends React.Component {
109109
}else{
110110
return (
111111
<button tabIndex={this.props.tabindex} className={this.getClassName()} {...props} onClick={click}>
112-
{this.props.iconPosition === 'right' ? <span className={labelClasses}>{this.props.label}</span>: null}
112+
{this.props.iconPosition === "right" ? <span className={labelClasses}>{this.props.label}</span>: null}
113113
{this.renderIcon(this.props.iconName)}
114114
{this.renderIconMore()}
115-
{(this.props.iconPosition === 'left' || !this.props.iconPosition) ? <span className={labelClasses}>{this.props.label}</span>: null}
115+
{(this.props.iconPosition === "left" || !this.props.iconPosition) ? <span className={labelClasses}>{this.props.label}</span>: null}
116116
{this.props.children}
117117
</button>
118118
);
@@ -122,17 +122,17 @@ class Button extends React.Component {
122122

123123
Button.propTypes = {
124124
label: React.PropTypes.string.isRequired,
125-
variant: React.PropTypes.oneOf(['base', 'neutral', 'brand', 'destructive', 'icon']),
125+
variant: React.PropTypes.oneOf(["base", "neutral", "brand", "destructive", "icon"]),
126126
tabindex: React.PropTypes.string,
127127
disabled: React.PropTypes.bool,
128128
inverse: React.PropTypes.bool,
129129
hint: React.PropTypes.bool,
130130
stateful: React.PropTypes.bool,
131131
responsive: React.PropTypes.bool,
132132
iconName: React.PropTypes.string,
133-
iconVariant: React.PropTypes.oneOf(['bare', 'container', 'border', 'border-filled', 'small', 'more']),
134-
iconSize: React.PropTypes.oneOf(['x-small', 'small', 'medium', 'large']),
135-
iconPosition: React.PropTypes.oneOf(['left', 'right']),
133+
iconVariant: React.PropTypes.oneOf(["bare", "container", "border", "border-filled", "small", "more"]),
134+
iconSize: React.PropTypes.oneOf(["x-small", "small", "medium", "large"]),
135+
iconPosition: React.PropTypes.oneOf(["left", "right"]),
136136
onClick: React.PropTypes.func,
137137
}
138138

components/SLDSButtonGroup/index.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ Neither the name of salesforce.com, inc. nor the names of its contributors may b
99
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1010
*/
1111

12-
import React from 'react';
13-
const classNames = require('classnames');
14-
import {ButtonIcon, Icon} from '../SLDSIcons.js';
12+
import React from "react";
1513

1614
class ButtonGroup extends React.Component {
1715
constructor(props) {
@@ -26,7 +24,6 @@ class ButtonGroup extends React.Component {
2624
);
2725
}
2826
}
29-
ButtonGroup.propTypes = {
30-
};
27+
3128
module.exports = ButtonGroup;
3229

0 commit comments

Comments
 (0)