Code Monkey home page Code Monkey logo

gradle-jslint-plugin's People

Contributors

kellyrob99 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

gradle-jslint-plugin's Issues

haltOnFailure does not make html report

First off thank you for this fantastic plugin.

I noticed that if I set haltOnFailure to true than the step to transform the xml to html doesn't work. I can only assume it's halting too soon ;)

Here's my config:

jslint {
    inputDirs = ['target/js']
    haltOnFailure = false
    excludes =  '**/3rdparty.js'
    options = 'rhino'
    formatterType = 'html'
}

Exception when running jslint

Hi,

I have come across your plugin and it's actually what I really want, but once I configured my project and run "gradle jslint" I get this error. This is my build.gradle

apply plugin: 'java'

buildscript {
dependencies {
classpath fileTree(dir: <My_Path>/gradle-jslint-plugin/releases', include: '*.jar')
}
}

repositories {
mavenCentral()
}

apply plugin: org.kar.jslint.gradle.plugin.JSLintPlugin

when I run "gradle jslint" I get this

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':jslint'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:71)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:48)
at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:34)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:55)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:57)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:41)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:51)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:42)
at org.gradle.api.internal.AbstractTask.execute(AbstractTask.java:237)
at org.gradle.execution.DefaultTaskGraphExecuter.executeTask(DefaultTaskGraphExecuter.java:167)
at org.gradle.execution.DefaultTaskGraphExecuter.doExecute(DefaultTaskGraphExecuter.java:160)
at org.gradle.execution.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:78)
at org.gradle.execution.TaskNameResolvingBuildExecuter.execute(TaskNameResolvingBuildExecuter.java:113)
at org.gradle.execution.DelegatingBuildExecuter.execute(DelegatingBuildExecuter.java:54)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:158)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:112)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:80)
at org.gradle.launcher.RunBuildAction.execute(RunBuildAction.java:41)
at org.gradle.launcher.RunBuildAction.execute(RunBuildAction.java:27)
at org.gradle.launcher.ExceptionReportingAction.execute(ExceptionReportingAction.java:32)
at org.gradle.launcher.ExceptionReportingAction.execute(ExceptionReportingAction.java:21)
at org.gradle.launcher.CommandLineActionFactory$WithLoggingAction.execute(CommandLineActionFactory.java:219)
at org.gradle.launcher.CommandLineActionFactory$WithLoggingAction.execute(CommandLineActionFactory.java:203)
at org.gradle.launcher.Main.execute(Main.java:55)
at org.gradle.launcher.Main.main(Main.java:40)
at org.gradle.launcher.ProcessBootstrap.runNoExit(ProcessBootstrap.java:46)
at org.gradle.launcher.ProcessBootstrap.run(ProcessBootstrap.java:28)
at org.gradle.launcher.GradleMain.main(GradleMain.java:24)
Caused by: : JSLint: 15 errors in 2 files
at com.googlecode.jslint4java.ant.JSLintTask.execute(JSLintTask.java:177)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.gradle.api.internal.project.ant.BasicAntBuilder.nodeCompleted(BasicAntBuilder.java:71)
at org.gradle.api.internal.project.ant.BasicAntBuilder.doInvokeMethod(BasicAntBuilder.java:86)
at org.gradle.api.internal.project.DefaultAntBuilder.super$3$invokeMethod(DefaultAntBuilder.groovy)
at org.gradle.api.internal.project.DefaultAntBuilder.invokeMethod(DefaultAntBuilder.groovy:37)
at org.kar.jslint.gradle.plugin.JSLintPlugin$_configureJslintTask_closure1.doCall(JSLintPlugin.groovy:50)
at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:443)
at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:431)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:63)
... 28 more

Thank you very much.

reportsDir deprecated & old jslint

Hi
first of all - thanks for your work!
i get following warning, which comes from your plugin:

The reportsDir property has been deprecated and is scheduled to be removed in Gradle 2.0. Please use the reporting.baseDir property instead.

And could you pls add the latest jslint plugin.

kind regards
Michael

Instructions on how to apply plugin

Could you please add some instruction on how to apply the plugin?

I tried with apply plugin 'jslint' and adding the following to buildscript.dependencies, classpath name: 'gradle-jslint-plugin'
When running i get the following error:

Configuration with name 'jslint' not found.

JSlint Fails With "Premature end of file."

Gradle build occasionally fails. And I do not know how to reproduce it. The next build usually goes OK.

:jslint FAILED
FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':jslint'.

javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: Premature end of file.

This is the my JSLint config

if (!System.properties['skipJSLint']){
    war.dependsOn jslint
}

jslint {
    haltOnFailure = true
    inputDirs = ["${project.projectDir.absolutePath}/devkit", "${project.projectDir.absolutePath}/test/qunit/tests", "${project.projectDir.absolutePath}/devkit/3rdparty/browser-i18n/"]
    includes = "**/*.js"
    excludes = "**/3rdparty/**, **/qunit.js, **/qunit/devkit/**"
    formatterType = 'html'
    options = ''
}
jslint.doFirst {
    def reportDir   = new File("$buildDir/reports/i18n")
    if (!reportDir.exists()){
        reportDir.mkdirs();
    }
    def reportFile  = new File(reportDir, 'index.html')
    reportFile.delete()
    // check JSON i18n files
    def i18nDir = new File("${project.projectDir.absolutePath}/devkit/i18n")
    def i18nFiles = i18nDir.listFiles({d, f-> f ==~ /.*.json/ } as FilenameFilter)
    def builder = new groovy.xml.MarkupBuilder(new FileWriter(reportFile))
    builder.html {
        head {
            title "Internationalisation(i81n) Report"
            link (rel : 'stylesheet', type: 'text/css', href: 'i18n.css')
        }
        body {
            h1 "Mutual I18n File Analysis"
            table(class: 'i18n') {
                tr {
                    td "File A"
                    td "File B"
                    td "Keys Missing in File B"
                }
                for (int f1 = 0; f1 <= i18nFiles.length - 2; f1++) {
                    def file1 = i18nFiles[f1]
                    def convertJsonToProperties = { file ->
                        println "Parsing file ${file.absolutePath}"
                        def flattenMap
                        flattenMap = { map, result = [:], prefix = '' ->
                            def addPrefix = { suffix ->
                                prefix ? prefix + '.' + suffix : suffix
                            }
                            map.each { k, v ->
                                switch (v) {
                                    case String:
                                        result[addPrefix(k)] = v
                                        break
                                    case Map:
                                        flattenMap(v, result, addPrefix(k))
                                        break
                                    default:
                                        throw new org.gradle.api.InvalidUserDataException("Error: uknown type: ${v.class}")
                                        break
                                }
                            }
                            return result
                        }
                        def m = flattenMap(new groovy.json.JsonSlurper().parseText(file.text))
                        //println "parsed properties: $m"
                        return m
                    }
                    def i118n1 = convertJsonToProperties(file1)
                    for (int f2 = f1 + 1; f2 <= i18nFiles.length - 1; f2++) {
                        def file2 = i18nFiles[f2]
                        def i118n2 = convertJsonToProperties(file2)
                        def diff1 = i118n1.keySet() - i118n2.keySet(), diff2 = i118n2.keySet() - i118n1.keySet()
                        def reportMissing = { diff, fName1, fName2 ->
                            if (diff) {
                                if (!reportFile.exists()) {
                                    reportFile.parentFile.mkdirs()
                                }
                                tr {
                                    td fName1
                                    td fName2
                                    td {
                                        ul {
                                            diff.each {
                                                li it
                                            }
                                        }
                                    }
                                }
                                //"Keys present in '$fName1', but not in '$fName2':".toString()
                            }
                        }
                        reportMissing(diff1, file1.name, file2.name)
                        reportMissing(diff2, file2.name, file1.name)
                    }
                }
            }
        }
    }
}
jslint.doFirst {
    // clean out reports, as otherwise we get an XSLT error, if we have a report from previous build
    if (buildDir.exists()) {
        ant.delete { fileset(dir: buildDir, includes: "reports/*") }
    }
}

task i18n(type: Copy){
    from "${project.projectDir.absolutePath}/test/css/jenkins/i18n.css"
    from("${project.projectDir.absolutePath}/test/") {
        include 'images/**/*'
    }
    into "$buildDir/reports/i18n/"
}

jslint << {
    i18n.execute()
}

I have added --stacktrace option to the build, when it fails again I will provide you with the stack trace.

Unable to pass jslint 'predef' option in the options string

In my codebase, I am linting my tests also. When I run jslint, it gives error for 'describe', 'beforeEach' etc. like this:
describe' is not defined

I am trying to add these to the accepted global variables by sending these options:
options='predef=describe,beforeEach'

But this shows message
Unknown option beforeEach

Is there a way I can pass predef?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.