File tree 4 files changed +3170
-0
lines changed
4 files changed +3170
-0
lines changed Original file line number Diff line number Diff line change
1
+ node_modules
2
+ .idea
Original file line number Diff line number Diff line change
1
+ const browserifyPreprocessor = require ( '@cypress/browserify-preprocessor' ) ;
2
+ const fs = require ( 'fs' ) ;
3
+ const CLIEngine = require ( 'eslint' ) . CLIEngine ;
4
+ const cli = new CLIEngine ( ) ;
5
+ const path = require ( 'path' ) ;
6
+
7
+ const lint = ( preprocessor ) => ( file ) => {
8
+ const report = cli . executeOnFiles ( [ file . filePath ] ) ;
9
+ if ( report . errorCount > 0 ) {
10
+ console . log ( `\nERROR in ${ file . filePath } ` ) ;
11
+
12
+ const errorResults = report . results . filter ( result => result . errorCount > 1 ) ;
13
+ errorResults . forEach ( ( result ) => {
14
+ console . log ( `\n${ path . relative ( process . cwd ( ) , result . filePath ) } ` ) ;
15
+ result . messages . forEach ( ( message ) => {
16
+ // todo: format with nice colours
17
+ console . log ( `${ message . line } :${ message . column } error ${ message . message } ${ message . ruleId } ` ) ;
18
+ } ) ;
19
+ } ) ;
20
+ }
21
+
22
+ if ( ! preprocessor ) {
23
+ preprocessor = browserifyPreprocessor ( browserifyPreprocessor . defaultOptions ) ;
24
+ }
25
+ return preprocessor ( file ) ;
26
+ } ;
27
+
28
+ module . exports = lint ;
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " cypress-eslint" ,
3
+ "version" : " 1.0.0" ,
4
+ "description" : " Cypress plugin that will run linting via ESLint on your spec files as they are loaded and display errors in console" ,
5
+ "main" : " index.js" ,
6
+ "scripts" : {
7
+ "test" : " echo \" Error: no test specified\" && exit 1"
8
+ },
9
+ "keywords" : [
10
+ " cypress" ,
11
+ " cypress-plugin" ,
12
+ " eslint"
13
+ ],
14
+ "author" : {
15
+ "name" : " Heather Roberts" ,
16
+ "email" : " heather.roberts427@gmail.com"
17
+ },
18
+ "license" : " ISC" ,
19
+ "dependencies" : {
20
+ "@cypress/browserify-preprocessor" : " ^1.0.2" ,
21
+ "eslint" : " ^4.19.1"
22
+ }
23
+ }
You can’t perform that action at this time.
0 commit comments