Search in sources :

Example 1 with JscsSettings

use of com.jscs.cli.JscsSettings in project jscs-plugin by idok.

the class Settings method toJscsSettings.

public JscsSettings toJscsSettings() {
    JscsSettings settings = new JscsSettings();
    settings.node = nodeInterpreter;
    settings.jscsExecutablePath = jscsExecutable;
    settings.preset = preset;
    settings.config = jscsrcFile;
    settings.esnext = esnext;
    settings.esprima = esprima;
    return settings;
}
Also used : JscsSettings(com.jscs.cli.JscsSettings)

Example 2 with JscsSettings

use of com.jscs.cli.JscsSettings in project jscs-plugin by idok.

the class JscsRunnerTest method testVersion.

@Test
public void testVersion() {
    JscsSettings settings = createSettings();
    try {
        String version = JscsRunner.version(settings);
        assertEquals("version should be", "1.6.1", version);
    } catch (ExecutionException e) {
        e.printStackTrace();
    }
}
Also used : JscsSettings(com.jscs.cli.JscsSettings) ExecutionException(com.intellij.execution.ExecutionException) Test(org.junit.Test)

Example 3 with JscsSettings

use of com.jscs.cli.JscsSettings in project jscs-plugin by idok.

the class JscsRunnerTest method testSimpleLintJSX.

@Test
public void testSimpleLintJSX() {
    String file = JSCS_PLUGIN_ROOT + "/testData/jsx.js";
    JscsSettings settings = createSettings(file);
    settings.esprima = "esprima-fb";
    LintResult result = JscsRunner.lint(settings);
    System.out.println(result.errorOutput);
    System.out.println(result.jscsLint.file.name);
    System.out.println("found " + result.jscsLint.file.errors.size() + " issues");
    for (JscsLint.Issue err : result.jscsLint.file.errors) {
        System.out.println(err.message);
    }
    assertEquals("File should match", file, result.jscsLint.file.name);
    assertEquals("Should be no errors", 0, result.jscsLint.file.errors.size());
}
Also used : JscsLint(com.jscs.cli.data.JscsLint) LintResult(com.jscs.cli.data.LintResult) JscsSettings(com.jscs.cli.JscsSettings) Test(org.junit.Test)

Example 4 with JscsSettings

use of com.jscs.cli.JscsSettings in project jscs-plugin by idok.

the class JscsRunnerTest method testSimpleLintES6.

@Test
public void testSimpleLintES6() {
    String file = JSCS_PLUGIN_ROOT + "/testData/es6.js";
    JscsSettings settings = createSettings(file);
    settings.esnext = true;
    LintResult result = JscsRunner.lint(settings);
    System.out.println(result.errorOutput);
    System.out.println(result.jscsLint.file.name);
    System.out.println("found " + result.jscsLint.file.errors.size() + " issues");
    for (JscsLint.Issue err : result.jscsLint.file.errors) {
        System.out.println(err.message);
    }
    assertEquals("File should match", file, result.jscsLint.file.name);
    assertEquals("Should be no errors", 0, result.jscsLint.file.errors.size());
}
Also used : JscsLint(com.jscs.cli.data.JscsLint) LintResult(com.jscs.cli.data.LintResult) JscsSettings(com.jscs.cli.JscsSettings) Test(org.junit.Test)

Example 5 with JscsSettings

use of com.jscs.cli.JscsSettings in project jscs-plugin by idok.

the class JscsRunnerTest method testSimpleLint2.

//    @Test
//    public void testSimpleLint() {
//        JscsSettings settings = createSettings(JSCS_PLUGIN_ROOT + "/testData/eq.js");
//        ProcessOutput out;
//        try {
//            out = JscsRunner.lint(settings);
////            System.out.println(settings);
//            System.out.println(out.getStdout());
//            assertEquals("Exit code should be 1", 1, out.getExitCode());
//        } catch (ExecutionException e) {
//            e.printStackTrace();
//        }
//    }
@Test
public void testSimpleLint2() {
    JscsSettings settings = createSettings(JSCS_PLUGIN_ROOT + "/testData/test.js");
    LintResult result = JscsRunner.lint(settings);
    System.out.println(result.errorOutput);
    System.out.println(result.jscsLint.file.name);
    System.out.println("found " + result.jscsLint.file.errors.size() + " issues");
    for (JscsLint.Issue err : result.jscsLint.file.errors) {
        System.out.println(err.message);
    }
    assertEquals("Exit code should be 1", JSCS_PLUGIN_ROOT + "/testData/test.js", result.jscsLint.file.name);
}
Also used : JscsLint(com.jscs.cli.data.JscsLint) LintResult(com.jscs.cli.data.LintResult) JscsSettings(com.jscs.cli.JscsSettings) Test(org.junit.Test)

Aggregations

JscsSettings (com.jscs.cli.JscsSettings)6 Test (org.junit.Test)4 JscsLint (com.jscs.cli.data.JscsLint)3 LintResult (com.jscs.cli.data.LintResult)3 ExecutionException (com.intellij.execution.ExecutionException)2