File tree 10 files changed +243
-3
lines changed
10 files changed +243
-3
lines changed Original file line number Diff line number Diff line change
1
+ # http://editorconfig.org
2
+ root = true
3
+
4
+ [* ]
5
+ indent_style = space
6
+ indent_size = 2
7
+ end_of_line = lf
8
+ charset = utf-8
9
+ trim_trailing_whitespace = true
10
+ insert_final_newline = true
11
+
12
+ [* .md ]
13
+ trim_trailing_whitespace = false
Original file line number Diff line number Diff line change @@ -6,6 +6,16 @@ bin-release/
6
6
# Other files and folders
7
7
.settings /
8
8
9
- # Project files, i.e. `.project`, `.actionScriptProperties` and `.flexProperties`
10
- # should NOT be excluded as they contain compiler settings and other important
11
- # information for Eclipse / Flash Builder.
9
+ /node_modules
10
+ coverage /
11
+ build /
12
+ npm-debug.log
13
+ .DS_Store
14
+ tmp /
15
+ .idea
16
+ jsdoc /
17
+ versions.json
18
+ * .iml
19
+ .eslintcache
20
+ .cache
21
+ /packages /** /node_modules
Original file line number Diff line number Diff line change
1
+ sudo : false
2
+ language : node_js
3
+ cache :
4
+ directories :
5
+ - node_modules
6
+ notifications :
7
+ email : false
8
+ node_js :
9
+ - ' 0.10'
10
+ before_install :
11
+ - npm i -g npm@^2.0.0
12
+ before_script :
13
+ - npm prune
14
+ after_success :
15
+ - npm run semantic-release
Original file line number Diff line number Diff line change
1
+ # eslint-plugin-protractor
2
+
3
+ [ ![ Build Status] [ travis-image ]] [ travis-url ]
4
+
5
+ [ travis-url ] : https://travis-ci.org/alecxe/eslint-plugin-protractor
6
+ [ travis-image ] : https://img.shields.io/travis/alecxe/eslint-plugin-protractor.svg
7
+
8
+ > ESLint rules for Protractor
9
+
10
+ ## Usage
11
+
12
+ 1 . Install ` eslint-plugin-protractor ` as a dev-dependency:
13
+
14
+ ``` shell
15
+ npm install --save-dev eslint-plugin-protractor
16
+ ```
17
+
18
+ 2. Enable the plugin by adding it to your ` .eslintrc` :
19
+
20
+ ` ` ` yaml
21
+ plugins:
22
+ - protractor
23
+ ` ` `
24
+
25
+ # # Configuration
26
+
27
+ This plugin ships with a default configuration for each rule:
28
+
29
+ Rule | Default | Options
30
+ ---- | ------- | -------
31
+ [missing-perform][] | 2 |
32
+
33
+
34
+ For example, the ` missing-perform` rule is enabled by default and will cause
35
+ ESLint to throw an error (with an exit code of ` 1` ) when triggered.
36
+
37
+ You may customise each rule by adding a value in your ` .eslintrc` ` rules`
38
+ property:
39
+
40
+ ` ` ` yaml
41
+ plugins:
42
+ - protractor
43
+ rules:
44
+ jasmine/missing-perform: 0
45
+ ` ` `
46
+
47
+ See [configuring rules][] for more information.
48
+
49
+ [missing-perform]: docs/rules/missing-perform.md
50
+ [configuring rules]: http://eslint.org/docs/user-guide/configuring#configuring-rules
51
+
52
+ # # Author
53
+
54
+ © 2016 Alexander Afanasyev
55
+
56
+ # # License
57
+
58
+ Licensed under the [MIT license](LICENSE).
Original file line number Diff line number Diff line change
1
+ # Enforce valid ` browser.actions() ` usage (missing-perform)
2
+
3
+ Ensure ` perform() ` is called on ` browser.actions() ` chain of actions.
4
+
5
+ ## Rule details
6
+
7
+ This rule triggers an error if there is no ` perform() ` at the end of the ` browser.actions() ` chain.
8
+ Note that there has to be at least one applied action to trigger the rule. In other words, ` var actions = browser.actions(); ` is a considered valid since it is quite a common pattern.
9
+
10
+ The following patterns are considered errors:
11
+
12
+ ``` js
13
+ browser .actions ().click ();
14
+ browser .actions ().mouseMove (elm);
15
+ ```
16
+
17
+ The following patterns are not errors:
18
+
19
+ ``` js
20
+ var actions = browser .actions ();
21
+ browser .actions ().click (elm).perform ();
22
+ browser .actions ().mouseMove (elm).click ().perform ();
23
+ browser .actions ().dragAndDrop (elm1, elm2).perform ();
24
+ ```
Original file line number Diff line number Diff line change
1
+ 'use strict'
2
+
3
+ module . exports = {
4
+ rules : {
5
+ 'missing-perform' : require ( './lib/rules/missing-perform' )
6
+ } ,
7
+ rulesConfig : {
8
+ 'missing-perform' : 2
9
+ }
10
+ }
Original file line number Diff line number Diff line change
1
+ 'use strict'
2
+
3
+ /**
4
+ * @fileoverview perform() has to be called on browser.actions()
5
+ * @author Alexander Afanasyev
6
+ */
7
+
8
+ module . exports = function ( context ) {
9
+ return {
10
+ 'MemberExpression' : function ( node ) {
11
+ // find browser.actions() code parts
12
+ if ( node . property . name === 'actions' && node . object . name === 'browser' ) {
13
+ // here is a tricky part - getting the parent nodes
14
+ // continue searching for perform call only if there is something called on browser.actions()
15
+ var parent = node . parent . parent
16
+ var performMissing = true
17
+
18
+ if ( parent . type === 'MemberExpression' ) {
19
+ while ( parent ) {
20
+ if ( parent . property && parent . property . name === 'perform' ) {
21
+ performMissing = false
22
+ break
23
+ }
24
+
25
+ node = parent
26
+ parent = node . parent
27
+ }
28
+
29
+ if ( performMissing ) {
30
+ context . report ( node , 'No perform() called on browser.actions()' )
31
+ }
32
+ }
33
+ }
34
+ }
35
+ }
36
+ }
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " eslint-plugin-protractor" ,
3
+ "description" : " ESLint rules for Protractor" ,
4
+ "main" : " index.js" ,
5
+ "directories" : {
6
+ "doc" : " docs" ,
7
+ "test" : " tests"
8
+ },
9
+ "scripts" : {
10
+ "pretest" : " standard" ,
11
+ "test" : " mocha" ,
12
+ "watch" : " mocha --watch" ,
13
+ "semantic-release" : " semantic-release pre && npm publish && semantic-release post"
14
+ },
15
+ "keywords" : [
16
+ " eslint" ,
17
+ " eslint-plugin" ,
18
+ " eslintplugin" ,
19
+ " protractor"
20
+ ],
21
+ "author" :
" Alexander Afanasyev <[email protected] >" ,
22
+ "license" : " MIT" ,
23
+ "repository" : {
24
+ "type" : " git" ,
25
+ "url" : " https://github.com/alecxe/eslint-plugin-protractor.git"
26
+ },
27
+ "bugs" : {
28
+ "url" : " https://github.com/alecxe/eslint-plugin-protractor/issues"
29
+ },
30
+ "homepage" : " https://github.com/alecxe/eslint-plugin-protractor" ,
31
+ "devDependencies" : {
32
+ "eslint" : " ^1.8.0" ,
33
+ "mocha" : " ^2.2.5" ,
34
+ "semantic-release" : " ^4.0.2" ,
35
+ "standard" : " ^5.3.1"
36
+ }
37
+ }
Original file line number Diff line number Diff line change
1
+ --recursive
2
+ --bail
Original file line number Diff line number Diff line change
1
+ 'use strict'
2
+
3
+ var rule = require ( '../../lib/rules/missing-perform' )
4
+ var RuleTester = require ( 'eslint' ) . RuleTester
5
+
6
+ var eslintTester = new RuleTester ( )
7
+
8
+ eslintTester . run ( 'missing-perform' , rule , {
9
+ valid : [
10
+ 'var actions = browser.actions();' ,
11
+ 'var actions = browser.actions()' ,
12
+ 'browser.actions().click(elm).perform();' ,
13
+ 'browser.actions().mouseMove(elm).click().perform();' ,
14
+ 'browser.actions().dragAndDrop(elm1, elm2).perform();'
15
+ ] ,
16
+
17
+ invalid : [
18
+ {
19
+ code : 'browser.actions().click();' ,
20
+ errors : [
21
+ {
22
+ message : 'No perform() called on browser.actions()'
23
+ }
24
+ ]
25
+ } ,
26
+ {
27
+ code : 'browser.actions().mouseMove(elm);' ,
28
+ errors : [
29
+ {
30
+ message : 'No perform() called on browser.actions()'
31
+ }
32
+ ]
33
+ }
34
+ ]
35
+ } )
You can’t perform that action at this time.
0 commit comments