diff --git a/pom.xml b/pom.xml index fdcc041..3ef659b 100644 --- a/pom.xml +++ b/pom.xml @@ -47,6 +47,7 @@ sonar-web-frontend-angular-eslint sonar-duplication-cpd sonar-duplication-simian + sonar-web-frontend-typescript sonar-web-frontend-plugin diff --git a/sonar-web-frontend-plugin/pom.xml b/sonar-web-frontend-plugin/pom.xml index 50903ad..f36b949 100644 --- a/sonar-web-frontend-plugin/pom.xml +++ b/sonar-web-frontend-plugin/pom.xml @@ -45,6 +45,11 @@ sonar-web-frontend-angular-eslint ${project.version} + + fr.sii.sonar + sonar-web-frontend-typescript + ${project.version} + diff --git a/sonar-web-frontend-typescript/.gitignore b/sonar-web-frontend-typescript/.gitignore new file mode 100644 index 0000000..e1bb6cf --- /dev/null +++ b/sonar-web-frontend-typescript/.gitignore @@ -0,0 +1,2 @@ +/target +/target/* diff --git a/sonar-web-frontend-typescript/pom.xml b/sonar-web-frontend-typescript/pom.xml new file mode 100644 index 0000000..93c089d --- /dev/null +++ b/sonar-web-frontend-typescript/pom.xml @@ -0,0 +1,59 @@ + + + 4.0.0 + + + fr.sii.sonar + sonar-sii-plugin-parent + 2.0.1-SNAPSHOT + + + sonar-web-frontend-typescript + sonar-plugin + + SII web frontend plugin :: TypeScript + Consume reports generated by tslint for code quality. Also consume reports for code duplication (either simian or cpd). Consumes the unit/integration tests reports (generated by Jasmin) coverage report (lcov generated by Istanbul). The information generated by reports are added in Sonar + + + + fr.sii.sonar + sonar-report-core + ${project.version} + + + fr.sii.sonar + sonar-coverage-lcov + ${project.version} + + + fr.sii.sonar + sonar-test-junit + ${project.version} + + + fr.sii.sonar + sonar-duplication-cpd + ${project.version} + + + fr.sii.sonar + sonar-duplication-simian + ${project.version} + + + + + + + org.codehaus.sonar + sonar-packaging-maven-plugin + ${sonar.plugin.version} + true + + fr.sii.sonar.web.frontend.typescript.TypeScriptPlugin + + + + + + diff --git a/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/TypeScript.java b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/TypeScript.java new file mode 100644 index 0000000..d93be14 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/TypeScript.java @@ -0,0 +1,14 @@ +package fr.sii.sonar.web.frontend.typescript; + +import org.sonar.api.config.Settings; + +import fr.sii.sonar.report.core.common.language.ConfigurableLanguage; + +public class TypeScript extends ConfigurableLanguage { + + public TypeScript(Settings settings) { + super(settings, TypeScriptLanguageConstants.LANGUAGE_KEY, TypeScriptLanguageConstants.FILE_SUFFIXES_KEY, TypeScriptLanguageConstants.FILE_SUFFIXES_DEFVALUE, "TS"); + } + + +} diff --git a/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/TypeScriptLanguageConstants.java b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/TypeScriptLanguageConstants.java new file mode 100644 index 0000000..cd06c43 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/TypeScriptLanguageConstants.java @@ -0,0 +1,16 @@ +package fr.sii.sonar.web.frontend.typescript; + +import fr.sii.sonar.report.core.common.ReportConstants; +import fr.sii.sonar.report.core.common.language.LanguageConstants; + +public abstract class TypeScriptLanguageConstants implements ReportConstants, LanguageConstants { + public static final String FILE_SUFFIXES_KEY = "sonar.sii.ts.suffixes"; + public static final String FILE_SUFFIXES_DEFVALUE = ".ts"; + public static final String LANGUAGE_KEY = "ts"; + public static final String CATEGORY = "TypeScript"; + public static final String SUB_CATEGORY = "General"; + + public String getLanguageKey() { + return LANGUAGE_KEY; + } +} diff --git a/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/TypeScriptPlugin.java b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/TypeScriptPlugin.java new file mode 100644 index 0000000..7f4792b --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/TypeScriptPlugin.java @@ -0,0 +1,219 @@ +package fr.sii.sonar.web.frontend.typescript; + +import java.util.Arrays; +import java.util.List; + +import org.sonar.api.SonarPlugin; +import org.sonar.api.config.PropertyDefinition; +import org.sonar.api.resources.Qualifiers; + +import fr.sii.sonar.report.core.common.PluginDependencies; +import fr.sii.sonar.web.frontend.typescript.coverage.LcovIntegrationCoverageConstants; +import fr.sii.sonar.web.frontend.typescript.coverage.LcovIntegrationCoverageSensor; +import fr.sii.sonar.web.frontend.typescript.coverage.LcovOverallCoverageConstants; +import fr.sii.sonar.web.frontend.typescript.coverage.LcovOverallCoverageSensor; +import fr.sii.sonar.web.frontend.typescript.coverage.LcovUnitCoverageConstants; +import fr.sii.sonar.web.frontend.typescript.coverage.LcovUnitCoverageSensor; +import fr.sii.sonar.web.frontend.typescript.duplication.TypeScriptDuplicationConstants; +import fr.sii.sonar.web.frontend.typescript.duplication.TypeScriptDuplicationSensor; +import fr.sii.sonar.web.frontend.typescript.quality.TslintQualityConstants; +import fr.sii.sonar.web.frontend.typescript.quality.TslintQualitySensor; +import fr.sii.sonar.web.frontend.typescript.quality.TslintProfileDefinition; +import fr.sii.sonar.web.frontend.typescript.quality.TslintRulesDefinition; +import fr.sii.sonar.web.frontend.typescript.test.JUnitConstants; +import fr.sii.sonar.web.frontend.typescript.test.JUnitIntegrationConstants; +import fr.sii.sonar.web.frontend.typescript.test.JUnitIntegrationReportSensor; +import fr.sii.sonar.web.frontend.typescript.test.JUnitReportSensor; + +/** + * This class is the entry point for all extensions + */ +public final class TypeScriptPlugin extends SonarPlugin { + + + // This is where you're going to declare all your Sonar extensions + @SuppressWarnings({ "rawtypes" }) + public List getExtensions() { + return Arrays.asList( + // needed here for standalone version + PluginDependencies.class, + + // general configuration + PropertyDefinition.builder(TypeScriptLanguageConstants.FILE_SUFFIXES_KEY) + .defaultValue(TypeScriptLanguageConstants.FILE_SUFFIXES_DEFVALUE) + .category(TypeScriptLanguageConstants.CATEGORY) + .subCategory(TypeScriptLanguageConstants.SUB_CATEGORY) + .name("File suffixes for TypeScript files") + .description("Comma-separated list of suffixes for files to analyze.") + .onQualifiers(Qualifiers.PROJECT) + .build(), + + TypeScript.class, + + // Quality configuration + PropertyDefinition.builder(TslintQualityConstants.REPORT_PATH_KEY) + .defaultValue(TslintQualityConstants.REPORT_PATH_DEFVALUE) + .category(TslintQualityConstants.CATEGORY) + .subCategory(TslintQualityConstants.SUB_CATEGORY) + .name("TypeScript quality report path") + .description("The path to the TypeScript report file to load") + .onQualifiers(Qualifiers.PROJECT) + .build(), + PropertyDefinition.builder(TslintQualityConstants.FAIL_MISSING_FILE_KEY) + .defaultValue(TslintQualityConstants.FAIL_MISSING_FILE_DEFVALUE) + .category(TslintQualityConstants.CATEGORY) + .subCategory(TslintQualityConstants.SUB_CATEGORY) + .name("Fail on missing source file") + .description("True to stop analysis if a source file is not found") + .onQualifiers(Qualifiers.PROJECT) + .build(), + PropertyDefinition.builder(TslintQualityConstants.SKIP_FILE_METRICS_KEY) + .defaultValue(TslintQualityConstants.SKIP_FILE_METRICS_DEFVALUE) + .category(TslintQualityConstants.CATEGORY) + .subCategory(TslintQualityConstants.SUB_CATEGORY) + .name("Skip save of file metrics") + .description("If you have several plugins that are able to handle TypeScript, you may have an error (Can not add the same measure twice). Set it to true to let the other plugin save the metrics") + .onQualifiers(Qualifiers.PROJECT) + .build(), + + TslintQualityConstants.class, + TslintRulesDefinition.class, + TslintProfileDefinition.class, + TslintQualitySensor.class, + + // Unit coverage configuration + PropertyDefinition.builder(LcovUnitCoverageConstants.REPORT_PATH_KEY) + .defaultValue(LcovUnitCoverageConstants.REPORT_PATH_DEFVALUE) + .category(LcovUnitCoverageConstants.CATEGORY) + .subCategory(LcovUnitCoverageConstants.SUB_CATEGORY) + .name("TypeScript unit tests coverage report path") + .description("The path to the TypeScript report file to load for unit tests coverage") + .onQualifiers(Qualifiers.PROJECT) + .build(), + PropertyDefinition.builder(LcovUnitCoverageConstants.FAIL_MISSING_FILE_KEY) + .defaultValue(LcovUnitCoverageConstants.FAIL_MISSING_FILE_DEFVALUE) + .category(LcovUnitCoverageConstants.CATEGORY) + .subCategory(LcovUnitCoverageConstants.SUB_CATEGORY) + .name("Fail on missing source file") + .description("True to stop analysis if a source file is not found") + .onQualifiers(Qualifiers.PROJECT) + .build() + +// LcovUnitCoverageConstants.class, +// LcovUnitCoverageSensor.class, +// +// // Integration coverage configuration +// PropertyDefinition.builder(LcovIntegrationCoverageConstants.REPORT_PATH_KEY) +// .defaultValue(LcovIntegrationCoverageConstants.REPORT_PATH_DEFVALUE) +// .category(LcovIntegrationCoverageConstants.CATEGORY) +// .subCategory(LcovIntegrationCoverageConstants.SUB_CATEGORY) +// .name("TypeScript integration tests coverage report path") +// .description("The path to the TypeScript report file to load for integration tests coverage") +// .onQualifiers(Qualifiers.PROJECT) +// .build(), +// PropertyDefinition.builder(LcovIntegrationCoverageConstants.FAIL_MISSING_FILE_KEY) +// .defaultValue(LcovIntegrationCoverageConstants.FAIL_MISSING_FILE_DEFVALUE) +// .category(LcovIntegrationCoverageConstants.CATEGORY) +// .subCategory(LcovIntegrationCoverageConstants.SUB_CATEGORY) +// .name("Fail on missing source file") +// .description("True to stop analysis if a source file is not found") +// .onQualifiers(Qualifiers.PROJECT) +// .build(), +// +// LcovIntegrationCoverageConstants.class, +// LcovIntegrationCoverageSensor.class, +// +// // Overall coverage configuration +// PropertyDefinition.builder(LcovOverallCoverageConstants.REPORT_PATH_KEY) +// .defaultValue(LcovOverallCoverageConstants.REPORT_PATH_DEFVALUE) +// .category(LcovOverallCoverageConstants.CATEGORY) +// .subCategory(LcovOverallCoverageConstants.SUB_CATEGORY) +// .name("TypeScript overall tests coverage report path") +// .description("The path to the TypeScript report file to load for overall tests coverage") +// .onQualifiers(Qualifiers.PROJECT) +// .build(), +// PropertyDefinition.builder(LcovOverallCoverageConstants.FAIL_MISSING_FILE_KEY) +// .defaultValue(LcovOverallCoverageConstants.FAIL_MISSING_FILE_DEFVALUE) +// .category(LcovOverallCoverageConstants.CATEGORY) +// .subCategory(LcovOverallCoverageConstants.SUB_CATEGORY) +// .name("Fail on missing source file") +// .description("True to stop analysis if a source file is not found") +// .onQualifiers(Qualifiers.PROJECT) +// .build(), +// +// LcovOverallCoverageConstants.class, +// LcovOverallCoverageSensor.class, +// +// // Unit testing configuration +// PropertyDefinition.builder(JUnitConstants.REPORT_PATH_KEY) +// .defaultValue(JUnitConstants.REPORT_PATH_DEFVALUE) +// .category(JUnitConstants.CATEGORY) +// .subCategory(JUnitConstants.SUB_CATEGORY) +// .name("TypeScript junit unit test report path") +// .description("The path to the TypeScript report file to load") +// .onQualifiers(Qualifiers.PROJECT) +// .build(), +// PropertyDefinition.builder(JUnitConstants.FAIL_MISSING_FILE_KEY) +// .defaultValue(JUnitConstants.FAIL_MISSING_FILE_DEFVALUE) +// .category(JUnitConstants.CATEGORY) +// .subCategory(JUnitConstants.SUB_CATEGORY) +// .name("Fail on missing test file") +// .description("True to stop analysis if a test file is not found") +// .onQualifiers(Qualifiers.PROJECT) +// .build(), +// +// JUnitConstants.class, +// JUnitReportSensor.class, +// +// // Integration testing configuration +// PropertyDefinition.builder(JUnitIntegrationConstants.REPORT_PATH_KEY) +// .defaultValue(JUnitIntegrationConstants.REPORT_PATH_DEFVALUE) +// .category(JUnitIntegrationConstants.CATEGORY) +// .subCategory(JUnitIntegrationConstants.SUB_CATEGORY) +// .name("TypeScript junit integration test report path") +// .description("The path to the TypeScript report file to load") +// .onQualifiers(Qualifiers.PROJECT) +// .build(), +// PropertyDefinition.builder(JUnitIntegrationConstants.FAIL_MISSING_FILE_KEY) +// .defaultValue(JUnitIntegrationConstants.FAIL_MISSING_FILE_DEFVALUE) +// .category(JUnitIntegrationConstants.CATEGORY) +// .subCategory(JUnitIntegrationConstants.SUB_CATEGORY) +// .name("Fail on missing test file") +// .description("True to stop analysis if a test file is not found") +// .onQualifiers(Qualifiers.PROJECT) +// .build(), +// +// JUnitIntegrationConstants.class, +// JUnitIntegrationReportSensor.class, +// +// // Duplication configuration +// PropertyDefinition.builder(TypeScriptDuplicationConstants.REPORT_PATH_KEY) +// .defaultValue(TypeScriptDuplicationConstants.REPORT_PATH_DEFVALUE) +// .category(TypeScriptDuplicationConstants.CATEGORY) +// .subCategory(TypeScriptDuplicationConstants.SUB_CATEGORY) +// .name("TypeScript duplication report path") +// .description("The path to the TypeScript report file to load") +// .onQualifiers(Qualifiers.PROJECT) +// .build(), +// PropertyDefinition.builder(TypeScriptDuplicationConstants.FAIL_MISSING_FILE_KEY) +// .defaultValue(TypeScriptDuplicationConstants.FAIL_MISSING_FILE_DEFVALUE) +// .category(TypeScriptDuplicationConstants.CATEGORY) +// .subCategory(TypeScriptDuplicationConstants.SUB_CATEGORY) +// .name("Fail on missing source file") +// .description("True to stop analysis if a source file is not found") +// .onQualifiers(Qualifiers.PROJECT) +// .build(), +// PropertyDefinition.builder(TypeScriptDuplicationConstants.SKIP_DUPLICATION_KEY) +// .defaultValue(TypeScriptDuplicationConstants.SKIP_DUPLICATION_DEFVAL) +// .category(TypeScriptDuplicationConstants.CATEGORY) +// .subCategory(TypeScriptDuplicationConstants.SUB_CATEGORY) +// .name("Skip duplication analysis") +// .description("True to skip code duplication analysis done by this plugin") +// .onQualifiers(Qualifiers.PROJECT) +// .build(), +// +// TypeScriptDuplicationConstants.class, +// TypeScriptDuplicationSensor.class + ); + } +} diff --git a/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/coverage/LcovIntegrationCoverageConstants.java b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/coverage/LcovIntegrationCoverageConstants.java new file mode 100644 index 0000000..cb794f7 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/coverage/LcovIntegrationCoverageConstants.java @@ -0,0 +1,22 @@ +package fr.sii.sonar.web.frontend.typescript.coverage; + +import fr.sii.sonar.report.core.common.ReportConstants; +import fr.sii.sonar.report.core.coverage.CoverageConstants; +import fr.sii.sonar.web.frontend.typescript.TypeScriptLanguageConstants; + +public class LcovIntegrationCoverageConstants extends TypeScriptLanguageConstants implements ReportConstants, CoverageConstants { + public static final String REPORT_PATH_KEY = "sonar.sii.coverage.it.ts.report.path"; + public static final String FAIL_MISSING_FILE_KEY = "sonar.sii.coverage.it.ts.file.missing.fail"; + public static final String REPORT_PATH_DEFVALUE = "/reports/sonar/ts-it.lcov"; + public static final String FAIL_MISSING_FILE_DEFVALUE = "true"; + public static final String SUB_CATEGORY = "Coverage"; + + public String getReportPathKey() { + return REPORT_PATH_KEY; + } + + public String getMissingFileFailKey() { + return FAIL_MISSING_FILE_KEY; + } + +} diff --git a/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/coverage/LcovIntegrationCoverageSensor.java b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/coverage/LcovIntegrationCoverageSensor.java new file mode 100644 index 0000000..7856225 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/coverage/LcovIntegrationCoverageSensor.java @@ -0,0 +1,21 @@ +package fr.sii.sonar.web.frontend.typescript.coverage; + +import fr.sii.sonar.coverage.lcov.factory.LcovProviderFactory; +import fr.sii.sonar.report.core.common.PluginDependencies; +import fr.sii.sonar.report.core.common.ReportSensor; +import fr.sii.sonar.report.core.coverage.domain.CoverageReport; +import fr.sii.sonar.report.core.coverage.factory.IntegrationCoverageSaverFactory; + +/** + * Sensor specific to TypeScript code coverage for integration tests that loads LCOV report + * + * @author Aurélien Baudet + * + */ +public class LcovIntegrationCoverageSensor extends ReportSensor { + + public LcovIntegrationCoverageSensor(LcovIntegrationCoverageConstants constants, PluginDependencies pluginDependencies) { + super(constants, pluginDependencies, new LcovProviderFactory(), new IntegrationCoverageSaverFactory()); + } + +} diff --git a/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/coverage/LcovOverallCoverageConstants.java b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/coverage/LcovOverallCoverageConstants.java new file mode 100644 index 0000000..b4ff4db --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/coverage/LcovOverallCoverageConstants.java @@ -0,0 +1,22 @@ +package fr.sii.sonar.web.frontend.typescript.coverage; + +import fr.sii.sonar.report.core.common.ReportConstants; +import fr.sii.sonar.report.core.coverage.CoverageConstants; +import fr.sii.sonar.web.frontend.typescript.TypeScriptLanguageConstants; + +public class LcovOverallCoverageConstants extends TypeScriptLanguageConstants implements ReportConstants, CoverageConstants { + public static final String REPORT_PATH_KEY = "sonar.sii.coverage.overall.ts.report.path"; + public static final String FAIL_MISSING_FILE_KEY = "sonar.sii.coverage.overall.ts.file.missing.fail"; + public static final String REPORT_PATH_DEFVALUE = "/reports/sonar/ts-overall.lcov"; + public static final String FAIL_MISSING_FILE_DEFVALUE = "true"; + public static final String SUB_CATEGORY = "Coverage"; + + public String getReportPathKey() { + return REPORT_PATH_KEY; + } + + public String getMissingFileFailKey() { + return FAIL_MISSING_FILE_KEY; + } + +} diff --git a/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/coverage/LcovOverallCoverageSensor.java b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/coverage/LcovOverallCoverageSensor.java new file mode 100644 index 0000000..82c4579 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/coverage/LcovOverallCoverageSensor.java @@ -0,0 +1,21 @@ +package fr.sii.sonar.web.frontend.typescript.coverage; + +import fr.sii.sonar.coverage.lcov.factory.LcovProviderFactory; +import fr.sii.sonar.report.core.common.PluginDependencies; +import fr.sii.sonar.report.core.common.ReportSensor; +import fr.sii.sonar.report.core.coverage.domain.CoverageReport; +import fr.sii.sonar.report.core.coverage.factory.OverallCoverageSaverFactory; + +/** + * Sensor specific to TypeScript code coverage for overall tests that loads LCOV report + * + * @author Aurélien Baudet + * + */ +public class LcovOverallCoverageSensor extends ReportSensor { + + public LcovOverallCoverageSensor(LcovOverallCoverageConstants constants, PluginDependencies pluginDependencies) { + super(constants, pluginDependencies, new LcovProviderFactory(), new OverallCoverageSaverFactory()); + } + +} diff --git a/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/coverage/LcovUnitCoverageConstants.java b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/coverage/LcovUnitCoverageConstants.java new file mode 100644 index 0000000..8942b1d --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/coverage/LcovUnitCoverageConstants.java @@ -0,0 +1,22 @@ +package fr.sii.sonar.web.frontend.typescript.coverage; + +import fr.sii.sonar.report.core.common.ReportConstants; +import fr.sii.sonar.report.core.coverage.CoverageConstants; +import fr.sii.sonar.web.frontend.typescript.TypeScriptLanguageConstants; + +public class LcovUnitCoverageConstants extends TypeScriptLanguageConstants implements ReportConstants, CoverageConstants { + public static final String REPORT_PATH_KEY = "sonar.sii.coverage.ut.ts.report.path"; + public static final String FAIL_MISSING_FILE_KEY = "sonar.sii.coverage.ut.ts.file.missing.fail"; + public static final String REPORT_PATH_DEFVALUE = "/reports/sonar/ts-ut.lcov"; + public static final String FAIL_MISSING_FILE_DEFVALUE = "true"; + public static final String SUB_CATEGORY = "Coverage"; + + public String getReportPathKey() { + return REPORT_PATH_KEY; + } + + public String getMissingFileFailKey() { + return FAIL_MISSING_FILE_KEY; + } + +} diff --git a/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/coverage/LcovUnitCoverageSensor.java b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/coverage/LcovUnitCoverageSensor.java new file mode 100644 index 0000000..9e30994 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/coverage/LcovUnitCoverageSensor.java @@ -0,0 +1,21 @@ +package fr.sii.sonar.web.frontend.typescript.coverage; + +import fr.sii.sonar.coverage.lcov.factory.LcovProviderFactory; +import fr.sii.sonar.report.core.common.PluginDependencies; +import fr.sii.sonar.report.core.common.ReportSensor; +import fr.sii.sonar.report.core.coverage.domain.CoverageReport; +import fr.sii.sonar.report.core.coverage.factory.UnitCoverageSaverFactory; + +/** + * Sensor specific to TypeScript code coverage for unit tests that loads LCOV report + * + * @author Aurélien Baudet + * + */ +public class LcovUnitCoverageSensor extends ReportSensor { + + public LcovUnitCoverageSensor(LcovUnitCoverageConstants constants, PluginDependencies pluginDependencies) { + super(constants, pluginDependencies, new LcovProviderFactory(), new UnitCoverageSaverFactory()); + } + +} diff --git a/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/duplication/TypeScriptDuplicationConstants.java b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/duplication/TypeScriptDuplicationConstants.java new file mode 100644 index 0000000..8f779b2 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/duplication/TypeScriptDuplicationConstants.java @@ -0,0 +1,27 @@ +package fr.sii.sonar.web.frontend.typescript.duplication; + +import fr.sii.sonar.report.core.duplication.DuplicationConstants; +import fr.sii.sonar.web.frontend.typescript.TypeScriptLanguageConstants; + +public class TypeScriptDuplicationConstants extends TypeScriptLanguageConstants implements DuplicationConstants { + public static final String REPORT_PATH_KEY = "sonar.sii.duplication.ts.report.path"; + public static final String FAIL_MISSING_FILE_KEY = "sonar.sii.duplication.ts.file.missing.fail"; + public static final String SKIP_DUPLICATION_KEY = "sonar.sii.duplication.ts.skip"; + public static final String SKIP_DUPLICATION_DEFVAL = "false"; + public static final String REPORT_PATH_DEFVALUE = "/reports/sonar/ts-duplication.xml"; + public static final String FAIL_MISSING_FILE_DEFVALUE = "true"; + public static final String SUB_CATEGORY = "Duplication"; + + public String getReportPathKey() { + return REPORT_PATH_KEY; + } + + public String getMissingFileFailKey() { + return FAIL_MISSING_FILE_KEY; + } + + public String getSkipDuplicationKey() { + return SKIP_DUPLICATION_KEY; + } + +} diff --git a/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/duplication/TypeScriptDuplicationSensor.java b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/duplication/TypeScriptDuplicationSensor.java new file mode 100644 index 0000000..33adbfa --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/duplication/TypeScriptDuplicationSensor.java @@ -0,0 +1,24 @@ +package fr.sii.sonar.web.frontend.typescript.duplication; + +import fr.sii.sonar.duplication.cpd.provider.CpdProvider; +import fr.sii.sonar.duplication.simian.provider.SimianProvider; +import fr.sii.sonar.report.core.common.PluginDependencies; +import fr.sii.sonar.report.core.common.ReportSensor; +import fr.sii.sonar.report.core.common.factory.FallbackProviderFactory; +import fr.sii.sonar.report.core.duplication.domain.DuplicationReport; +import fr.sii.sonar.report.core.duplication.factory.DuplicationSaverFactory; + +/** + * Sensor specific to code duplication that loads duplication report (either CPD or Simian) + * + * @author Aurélien Baudet + * + */ +public class TypeScriptDuplicationSensor extends ReportSensor { + + @SuppressWarnings({ "unchecked" }) + public TypeScriptDuplicationSensor(TypeScriptDuplicationConstants constants, PluginDependencies pluginDependencies) { + super(constants, pluginDependencies, new FallbackProviderFactory(CpdProvider.class, SimianProvider.class), new DuplicationSaverFactory()); + } + +} diff --git a/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/quality/TslintProfileDefinition.java b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/quality/TslintProfileDefinition.java new file mode 100644 index 0000000..ee36789 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/quality/TslintProfileDefinition.java @@ -0,0 +1,20 @@ +package fr.sii.sonar.web.frontend.typescript.quality; + +import org.sonar.api.rules.RuleFinder; + +import fr.sii.sonar.report.core.quality.profile.JsonProfileParser; +import fr.sii.sonar.report.core.quality.profile.ProfileFileDefinition; + +/** + * Just a specific implementation to help dependency injection + * + * @author Aurélien Baudet + * + */ +public class TslintProfileDefinition extends ProfileFileDefinition { + + public TslintProfileDefinition(RuleFinder ruleFinder, TslintQualityConstants constants) { + super(constants.getProfileJsonPath(), new JsonProfileParser(), ruleFinder); + } + +} diff --git a/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/quality/TslintQualityConstants.java b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/quality/TslintQualityConstants.java new file mode 100644 index 0000000..94d18c1 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/quality/TslintQualityConstants.java @@ -0,0 +1,49 @@ +package fr.sii.sonar.web.frontend.typescript.quality; + +import fr.sii.sonar.report.core.common.rules.RulesDefinitionConstants; +import fr.sii.sonar.report.core.quality.ProfileDefinitionConstants; +import fr.sii.sonar.report.core.quality.QualityConstants; +import fr.sii.sonar.web.frontend.typescript.TypeScriptLanguageConstants; + +public class TslintQualityConstants extends TypeScriptLanguageConstants implements QualityConstants, RulesDefinitionConstants, ProfileDefinitionConstants { + public static final String REPORT_PATH_KEY = "sonar.sii.quality.ts.report.path"; + public static final String FAIL_MISSING_FILE_KEY = "sonar.sii.quality.ts.file.missing.fail"; + public static final String SKIP_FILE_METRICS_KEY = "sonar.sii.quality.ts.file.metrics.skip"; + public static final String SKIP_FILE_METRICS_DEFVALUE = "false"; + public static final String REPORT_PATH_DEFVALUE = "/reports/sonar/tslint.json"; + public static final String FAIL_MISSING_FILE_DEFVALUE = "true"; + public static final String RULES_PATH = "/rules/tslint.json"; + public static final String REPOSITORY_NAME = "TSLint"; + public static final String REPOSITORY_KEY = "tslint"; + public static final String SUB_CATEGORY = "Quality"; + public static final String PROFILE_PATH = "/profiles/tslint.json"; + + public String getReportPathKey() { + return REPORT_PATH_KEY; + } + + public String getRepositoryKey() { + return REPOSITORY_KEY; + } + + public String getMissingFileFailKey() { + return FAIL_MISSING_FILE_KEY; + } + + public String getRepositoryName() { + return REPOSITORY_NAME; + } + + public String getRulesJsonPath() { + return RULES_PATH; + } + + public String getProfileJsonPath() { + return PROFILE_PATH; + } + + public String getSkipFileMetricsKey() { + return SKIP_FILE_METRICS_KEY; + } + +} diff --git a/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/quality/TslintQualitySensor.java b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/quality/TslintQualitySensor.java new file mode 100644 index 0000000..43123fd --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/quality/TslintQualitySensor.java @@ -0,0 +1,21 @@ +package fr.sii.sonar.web.frontend.typescript.quality; + +import fr.sii.sonar.report.core.common.PluginDependencies; +import fr.sii.sonar.report.core.common.ReportSensor; +import fr.sii.sonar.report.core.quality.domain.report.QualityReport; +import fr.sii.sonar.report.core.quality.factory.JsonQualityReportProviderFactory; +import fr.sii.sonar.report.core.quality.factory.QualitySaverFactory; + +/** + * Just a specific implementation to help dependency injection + * + * @author Aurélien Baudet + * + */ +public class TslintQualitySensor extends ReportSensor { + + public TslintQualitySensor(TslintQualityConstants constants, PluginDependencies pluginDependencies) { + super(constants, pluginDependencies, new JsonQualityReportProviderFactory(), new QualitySaverFactory()); + } + +} diff --git a/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/quality/TslintRulesDefinition.java b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/quality/TslintRulesDefinition.java new file mode 100644 index 0000000..5c55c6c --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/quality/TslintRulesDefinition.java @@ -0,0 +1,17 @@ +package fr.sii.sonar.web.frontend.typescript.quality; + +import fr.sii.sonar.report.core.common.rules.ComposableRulesDefinition; + +/** + * Repository for tslint rules + * + * @author Aurélien Baudet + * + */ +public class TslintRulesDefinition extends ComposableRulesDefinition { + + public TslintRulesDefinition(TslintQualityConstants constants) { + super(constants); + } + +} \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/test/JUnitConstants.java b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/test/JUnitConstants.java new file mode 100644 index 0000000..e5a78df --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/test/JUnitConstants.java @@ -0,0 +1,26 @@ +package fr.sii.sonar.web.frontend.typescript.test; + +import fr.sii.sonar.report.core.test.TestConstants; +import fr.sii.sonar.report.core.test.domain.Type; +import fr.sii.sonar.web.frontend.typescript.TypeScriptLanguageConstants; + +public class JUnitConstants extends TypeScriptLanguageConstants implements TestConstants { + public static final String REPORT_PATH_KEY = "sonar.sii.test.unit.ts.report.path"; + public static final String FAIL_MISSING_FILE_KEY = "sonar.sii.test.unit.ts.file.missing.fail"; + public static final String REPORT_PATH_DEFVALUE = "/reports/sonar/ts-ut.xml"; + public static final String FAIL_MISSING_FILE_DEFVALUE = "true"; + public static final String SUB_CATEGORY = "Unit testing"; + + public String getReportPathKey() { + return REPORT_PATH_KEY; + } + + public String getMissingFileFailKey() { + return FAIL_MISSING_FILE_KEY; + } + + public Type getType() { + return Type.UNIT; + } + +} diff --git a/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/test/JUnitIntegrationConstants.java b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/test/JUnitIntegrationConstants.java new file mode 100644 index 0000000..05ed208 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/test/JUnitIntegrationConstants.java @@ -0,0 +1,26 @@ +package fr.sii.sonar.web.frontend.typescript.test; + +import fr.sii.sonar.report.core.test.TestConstants; +import fr.sii.sonar.report.core.test.domain.Type; +import fr.sii.sonar.web.frontend.typescript.TypeScriptLanguageConstants; + +public class JUnitIntegrationConstants extends TypeScriptLanguageConstants implements TestConstants { + public static final String REPORT_PATH_KEY = "sonar.sii.test.it.ts.report.path"; + public static final String FAIL_MISSING_FILE_KEY = "sonar.sii.test.it.ts.file.missing.fail"; + public static final String REPORT_PATH_DEFVALUE = "/reports/sonar/ts-it.xml"; + public static final String FAIL_MISSING_FILE_DEFVALUE = "true"; + public static final String SUB_CATEGORY = "Integration testing"; + + public String getReportPathKey() { + return REPORT_PATH_KEY; + } + + public String getMissingFileFailKey() { + return FAIL_MISSING_FILE_KEY; + } + + public Type getType() { + return Type.INTEGRATION; + } + +} diff --git a/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/test/JUnitIntegrationReportSensor.java b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/test/JUnitIntegrationReportSensor.java new file mode 100644 index 0000000..221cb0e --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/test/JUnitIntegrationReportSensor.java @@ -0,0 +1,21 @@ +package fr.sii.sonar.web.frontend.typescript.test; + +import fr.sii.sonar.report.core.common.PluginDependencies; +import fr.sii.sonar.report.core.common.ReportSensor; +import fr.sii.sonar.report.core.test.domain.TestReport; +import fr.sii.sonar.report.core.test.factory.TestSaverFactory; +import fr.sii.sonar.report.test.junit.factory.JUnitFallbackProviderFactory; + +/** + * Sensor specialized to load JUnit report file and save integration test measures + * + * @author Aurélien Baudet + * + */ +public class JUnitIntegrationReportSensor extends ReportSensor { + + public JUnitIntegrationReportSensor(JUnitIntegrationConstants constants, PluginDependencies pluginDependencies) { + super(constants, pluginDependencies, new JUnitFallbackProviderFactory(), new TestSaverFactory()); + } + +} diff --git a/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/test/JUnitReportSensor.java b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/test/JUnitReportSensor.java new file mode 100644 index 0000000..0c307c2 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/java/fr/sii/sonar/web/frontend/typescript/test/JUnitReportSensor.java @@ -0,0 +1,21 @@ +package fr.sii.sonar.web.frontend.typescript.test; + +import fr.sii.sonar.report.core.common.PluginDependencies; +import fr.sii.sonar.report.core.common.ReportSensor; +import fr.sii.sonar.report.core.test.domain.TestReport; +import fr.sii.sonar.report.core.test.factory.TestSaverFactory; +import fr.sii.sonar.report.test.junit.factory.JUnitFallbackProviderFactory; + +/** + * Sensor specialized to load JUnit report file and save unit test measures + * + * @author Aurélien Baudet + * + */ +public class JUnitReportSensor extends ReportSensor { + + public JUnitReportSensor(JUnitConstants constants, PluginDependencies pluginDependencies) { + super(constants, pluginDependencies, new JUnitFallbackProviderFactory(), new TestSaverFactory()); + } + +} diff --git a/sonar-web-frontend-typescript/src/main/resources/profiles/tslint.json b/sonar-web-frontend-typescript/src/main/resources/profiles/tslint.json new file mode 100644 index 0000000..41f1eb5 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/profiles/tslint.json @@ -0,0 +1,12 @@ +{ + "name": "tslint", + "language": "ts", + "repositories": [{ + "key": "tslint", + "rules": "/rules/tslint.json" + }], + "rules": [{ + "repositoryKey": "tslint", + "key": "unknown-rule" + }] +} \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/jshint.css b/sonar-web-frontend-typescript/src/main/resources/rules/jshint.css new file mode 100644 index 0000000..e69de29 diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint.json b/sonar-web-frontend-typescript/src/main/resources/rules/tslint.json new file mode 100644 index 0000000..8a91544 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint.json @@ -0,0 +1,877 @@ +[ { + "key" : "member-access", + "name" : "member-access", + "description" : "Requires explicit visibility declarations for class members.", + "severity" : "MINOR", + "status" : null, + "tags" : ["tslint", "convention"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "member-ordering", + "name" : "member-ordering", + "description" : "Enforces member ordering.", + "severity" : "MINOR", + "status" : null, + "tags" : ["tslint", "convention"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-any", + "name" : "no-any", + "description" : "Diallows usages of any as a type declaration.", + "severity" : "MAJOR", + "status" : null, + "tags" : ["tslint", "convention", "pitfall"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "30min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "no-inferrable-types", + "name" : "no-inferrable-types", + "description" : "Disallows explicit type declarations for variables or parameters initialized to a number, string, or boolean.", + "severity" : "MINOR", + "status" : null, + "tags" : ["tslint", "convention", "useless"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-internal-module", + "name" : "no-internal-module", + "description" : "Disallows internal module", + "severity" : "MAJOR", + "status" : null, + "tags" : ["tslint", "convention", "confusion", "es6"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "no-namespace", + "name" : "no-namespace", + "description" : "Disallows use of internal modules and namespaces.", + "severity" : "MAJOR", + "status" : null, + "tags" : ["tslint", "obsolete", "es6"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "MAINTENABILITY_COMPLIANCE" + } +}, { + "key" : "no-reference", + "name" : "no-reference", + "description" : "Disallows /// imports (use ES6-style imports instead).", + "severity" : "MAJOR", + "status" : null, + "tags" : ["tslint", "obsolete", "es6"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "MAINTENABILITY_COMPLIANCE" + } +}, { + "key" : "no-var-requires", + "name" : "no-var-requires", + "description" : "Disallows the use of require statements except in import statements.", + "severity" : "MAJOR", + "status" : null, + "tags" : ["tslint", "convention", "es6"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "MAINTENABILITY_COMPLIANCE" + } +}, { + "key" : "typedef", + "name" : "typedef", + "description" : "Requires type definitions to exist.", + "severity" : "CRITICAL", + "status" : null, + "tags" : ["tslint", "pitfall"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "ARCHITECTURE_RELIABILITY" + } +}, { + "key" : "typedef-whitespace", + "name" : "typedef-whitespace", + "description" : "Requires or disallows whitespace for type definitions.", + "severity" : "MINOR", + "status" : null, + "tags" : ["tslint", "convention"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "ban", + "name" : "ban", + "description" : "Bans the use of specific functions.", + "severity" : "MAJOR", + "status" : null, + "tags" : ["tslint", "convention", "forbidden"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "ARCHITECTURE_RELIABILITY" + } +}, { + "key" : "curly", + "name" : "curly", + "description" : "Enforces braces for if/for/do/while statements.", + "severity" : "MAJOR", + "status" : null, + "tags" : ["tslint", "convention", "pitfall"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "forin", + "name" : "forin", + "description" : "Requires a for ... in statement to be filtered with an if statement.", + "severity" : "MAJOR", + "status" : null, + "tags" : ["tslint", "bug", "pitfall"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "label-position", + "name" : "label-position", + "description" : "Only allows labels in sensible locations.", + "severity" : "CRITICAL", + "status" : null, + "tags" : ["tslint", "bad-practice", "pitfall"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "label-undefined", + "name" : "label-undefined", + "description" : "Checks that labels are defined before usage.", + "severity" : "BLOCKER", + "status" : null, + "tags" : ["tslint", "bug"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "no-arg", + "name" : "no-arg", + "description" : "Disallows use of arguments.callee.", + "severity" : "MAJOR", + "status" : null, + "tags" : ["tslint", "performance"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "CPU_EFFICIENCY" + } +}, { + "key" : "no-bitwise", + "name" : "no-bitwise", + "description" : "Disallows bitwise operators.", + "severity" : "MAJOR", + "status" : null, + "tags" : ["tslint", "suspicious", "bad-practice"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "no-conditional-assignment", + "name" : "no-conditional-assignment", + "description" : "Disallows any type of assignment in conditionals.", + "severity" : "CRITICAL", + "status" : null, + "tags" : ["tslint", "suspicious", "bad-practice"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "no-console", + "name" : "no-console", + "description" : "Bans the use of specified console methods.", + "severity" : "MAJOR", + "status" : null, + "tags" : ["tslint", "bad-practice"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "SOFTWARE_RELATED_PORTABILITY" + } +}, { + "key" : "no-construct", + "name" : "no-construct", + "description" : "Disallows access to the constructors of String, Number, and Boolean.", + "severity" : "CRITICAL", + "status" : null, + "tags" : ["tslint", "bad-practice", "pitfall"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "no-debugger", + "name" : "no-debugger", + "description" : "Disallows debugger statements.", + "severity" : "MAJOR", + "status" : null, + "tags" : ["tslint", "bad-practice"], + "debt" : null +}, { + "key" : "no-duplicate-key", + "name" : "no-duplicate-key", + "description" : "Disallows duplicate keys in object literals.", + "severity" : "MAJOR", + "status" : null, + "tags" : ["tslint", "bad-practice", "suspicious"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "no-duplicate-variable", + "name" : "no-duplicate-variable", + "description" : "Disallows duplicate variable declarations in the same block scope.", + "severity" : "CRITICAL", + "status" : null, + "tags" : ["tslint", "bad-practice", "pitfall"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "no-empty", + "name" : "no-empty", + "description" : "Disallows empty blocks.", + "severity" : "MAJOR", + "status" : null, + "tags" : ["tslint", "convention"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-eval", + "name" : "no-eval", + "description" : "Disallows eval function invocations.", + "severity" : "CRITICAL", + "status" : null, + "tags" : ["tslint", "bad-practice", "security"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "30min" + }, + "sqaleSubCharacteristic" : "API_ABUSE" + } +}, { + "key" : "no-invalid-this", + "name" : "no-invalid-this", + "description" : "Disallows using the this keyword outside of classes.", + "severity" : "MAJOR", + "status" : null, + "tags" : ["tslint", "bad-practice", "pitfall"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "no-null-keyword", + "name" : "no-null-keyword", + "description" : "Disallows use of the null keyword literal.", + "severity" : "MINOR", + "status" : null, + "tags" : ["tslint", "bad-practice", "pitfall"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "no-shadowed-variable", + "name" : "no-shadowed-variable", + "description" : "Disallows shadowing variable declarations.", + "severity" : "CRITICAL", + "status" : null, + "tags" : ["tslint", "bad-practice", "pitfall"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "no-string-literal", + "name" : "no-string-literal", + "description" : "Disallows object access via string literals.", + "severity" : "MAJOR", + "status" : null, + "tags" : ["tslint", "convention", "type-safe"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "ARCHITECTURE_CHANGEABILITY" + } +}, { + "key" : "no-switch-case-fall-through", + "name" : "no-switch-case-fall-through", + "description" : "Disallows falling through case statements.", + "severity" : "MAJOR", + "status" : null, + "tags" : ["tslint", "pitfall", "bad-practice"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "no-unreachable", + "name" : "no-unreachable", + "description" : "Disallows unreachable code after break, catch, throw, and return statements.", + "severity" : "CRITICAL", + "status" : null, + "tags" : ["tslint", "suspicious", "bad-practice", "dead-code"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-unused-expression", + "name" : "no-unused-expression", + "description" : "Disallows unused expression statements.", + "severity" : "MAJOR", + "status" : null, + "tags" : ["tslint", "suspicious", "bad-practice", "unused"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-unused-variable", + "name" : "no-unused-variable", + "description" : "Disallows unused imports, variables, functions and private class members.", + "severity" : "MAJOR", + "status" : null, + "tags" : ["tslint", "bad-practice", "unused"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-use-before-declare", + "name" : "no-use-before-declare", + "description" : "Disallows usage of variables before their declaration.", + "severity" : "CRITICAL", + "status" : null, + "tags" : ["tslint", "bad-practice", "pitfall"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "no-var-keyword", + "name" : "no-var-keyword", + "description" : "Disallows usage of the var keyword.", + "severity" : "MINOR", + "status" : null, + "tags" : ["tslint", "convention"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "radix", + "name" : "radix", + "description" : "Requires the radix parameter to be specified when calling parseInt.", + "severity" : "MAJOR", + "status" : null, + "tags" : ["tslint", "bad-practice", "pitfall"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "INSTRUCTION_RELIABILITY" + } +}, { + "key" : "switch-default", + "name" : "switch-default", + "description" : "Require a default case in all switch statements.", + "severity" : "MAJOR", + "status" : null, + "tags" : ["tslint", "convention", "suspicious"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "DATA_CHANGEABILITY" + } +}, { + "key" : "triple-equals", + "name" : "triple-equals", + "description" : "Requires === and !== in place of == and !=.", + "severity" : "MAJOR", + "status" : null, + "tags" : ["tslint", "bad-practice", "pitfall"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "use-isnan", + "name" : "use-isnan", + "description" : "Enforces use of the isNaN() function to check for NaN references instead of a comparison to the NaN constant.", + "severity" : "MAJOR", + "status" : null, + "tags" : ["tslint", "bad-practice", "pitfall"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "LOGIC_RELIABILITY" + } +}, { + "key" : "use-strict", + "name" : "use-strict", + "description" : "Requires using ECMAScript 5’s strict mode.", + "severity" : "MAJOR", + "status" : null, + "tags" : ["tslint", "convention"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "SOFTWARE_RELATED_PORTABILITY" + } +}, { + "key" : "eofline", + "name" : "eofline", + "description" : "Ensures the file ends with a newline.", + "severity" : "MINOR", + "status" : null, + "tags" : ["tslint", "convention"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "indent", + "name" : "indent", + "description" : "Enforces indentation with tabs or spaces.", + "severity" : "MINOR", + "status" : null, + "tags" : ["tslint", "convention"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "max-line-length", + "name" : "max-line-length", + "description" : "Requires lines to be under a certain max length.", + "severity" : "MINOR", + "status" : null, + "tags" : ["tslint", "convention"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-default-export", + "name" : "no-default-export", + "description" : "Disallows default exports in ES6-style modules.", + "severity" : "MAJOR", + "status" : null, + "tags" : ["tslint", "bad-practice", "pitfall"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "20min" + }, + "sqaleSubCharacteristic" : "ARCHITECTURE_CHANGEABILITY" + } +}, { + "key" : "no-require-imports", + "name" : "no-require-imports", + "description" : "Disallows invocation of require().", + "severity" : "MAJOR", + "status" : null, + "tags" : ["tslint", "convention", "es6"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "LANGUAGE_RELATED_PORTABILITY" + } +}, { + "key" : "no-trailing-whitespace", + "name" : "no-trailing-whitespace", + "description" : "Disallows trailing whitespace at the end of a line.", + "severity" : "MINOR", + "status" : null, + "tags" : ["tslint", "convention"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "object-literal-sort-keys", + "name" : "object-literal-sort-keys", + "description" : "Requires keys in object literals to be sorted alphabetically", + "severity" : "MINOR", + "status" : null, + "tags" : ["tslint", "convention"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "trailing-comma", + "name" : "trailing-comma", + "description" : "Requires or disallows trailing commas in array and object literals, destructuring assignments and named imports.", + "severity" : "MINOR", + "status" : null, + "tags" : ["tslint", "convention"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "align", + "name" : "align", + "description" : "Enforces vertical alignment.", + "severity" : "MINOR", + "status" : null, + "tags" : ["tslint", "convention"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "class-name", + "name" : "class-name", + "description" : "Enforces PascalCased class and interface names.", + "severity" : "MAJOR", + "status" : null, + "tags" : ["tslint", "convention"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "5min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "comment-format", + "name" : "comment-format", + "description" : "Enforces formatting rules for single-line comments.", + "severity" : "MINOR", + "status" : null, + "tags" : ["tslint", "convention"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "interface-name", + "name" : "interface-name", + "description" : "Requires interface names to begin with a capital ‘I’", + "severity" : "INFO", + "status" : null, + "tags" : ["tslint", "convention"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "UNDERSTANDABILITY" + } +}, { + "key" : "jsdoc-format", + "name" : "jsdoc-format", + "description" : "Enforces basic format rules for JSDoc comments.", + "severity" : "MINOR", + "status" : null, + "tags" : ["tslint", "convention"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "new-parens", + "name" : "new-parens", + "description" : "Requires parentheses when invoking a constructor via the new keyword.", + "severity" : "MINOR", + "status" : null, + "tags" : ["tslint", "convention"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-angle-bracket-type-assertion", + "name" : "no-angle-bracket-type-assertion", + "description" : "Requires the use of as Type for type assertions instead of .", + "severity" : "MINOR", + "status" : null, + "tags" : ["tslint", "convention", "tsx"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "10min" + }, + "sqaleSubCharacteristic" : "LANGUAGE_RELATED_PORTABILITY" + } +}, { + "key" : "no-consecutive-blank-lines", + "name" : "no-consecutive-blank-lines", + "description" : "Disallows more than one blank line in a row.", + "severity" : "MINOR", + "status" : null, + "tags" : ["tslint", "convention"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "no-constructor-vars", + "name" : "no-constructor-vars", + "description" : "Disallows parameter properties.", + "severity" : "MINOR", + "status" : null, + "tags" : ["tslint", "convention"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "2min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "one-line", + "name" : "one-line", + "description" : "Requires the specified tokens to be on the same line as the expression preceding them.", + "severity" : "MINOR", + "status" : null, + "tags" : ["tslint", "convention"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "one-variable-per-declaration", + "name" : "one-variable-per-declaration", + "description" : "Disallows multiple variable definitions in the same declaration statement.", + "severity" : "MINOR", + "status" : null, + "tags" : ["tslint", "convention"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "quotemark", + "name" : "quotemark", + "description" : "Requires single or double quotes for string literals.", + "severity" : "MINOR", + "status" : null, + "tags" : ["tslint", "convention", "consistency"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "semicolon", + "name" : "semicolon", + "description" : "Enforces consistent semicolon usage at the end of every statement.", + "severity" : "MINOR", + "status" : null, + "tags" : ["tslint", "convention"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "variable-name", + "name" : "variable-name", + "description" : "Checks variable names for various errors.", + "severity" : "MINOR", + "status" : null, + "tags" : ["tslint", "convention"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +}, { + "key" : "whitespace", + "name" : "whitespace", + "description" : "Enforces whitespace style conventions.", + "severity" : "MINOR", + "status" : null, + "tags" : ["tslint", "convention"], + "debt" : { + "sqaleRemediation" : { + "type" : "constant", + "offset" : "1min" + }, + "sqaleSubCharacteristic" : "READABILITY" + } +} ] \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/align.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/align.html new file mode 100644 index 0000000..a482512 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/align.html @@ -0,0 +1,38 @@ +

Details

+ + +
+

Rule: align

+

+
+ + +

Enforces vertical alignment.

+ + + +
Rationale
+

Helps maintain a readable, consistent style in your codebase.

+ + + + +

Config

+ +

Three arguments may be optionally provided:

+ +
    +
  • "parameters" checks alignment of function parameters.
  • +
  • "arguments" checks alignment of function call arguments.
  • +
  • "statements" checks alignment of statements.
  • +
+ + +
Examples
+ +
"align": [true, "parameters", "statements"]
+ + +
Schema
+
{
"type": "list",
"listType": {
"type": "enum",
"enumValues": [
"arguments",
"parameters",
"statements"
]
}
}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/ban.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/ban.html new file mode 100644 index 0000000..06a3383 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/ban.html @@ -0,0 +1,30 @@ +

Details

+ + +
+

Rule: ban

+

+
+ + +

Bans the use of specific functions.

+ + +

At this time, there is no way to disable global methods with this rule.

+ + + + + +

Config

+

A list of ['object', 'method'] pairs which ban object.method().

+ + +
Examples
+ +
"ban": [true, ["console", "log"], ["someObject", "someFunction"]]
+ + +
Schema
+
{
"type": "list",
"listType": {
"type": "array",
"arrayMembers": [
{
"type": "string"
},
{
"type": "string"
}
]
}
}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/class-name.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/class-name.html new file mode 100644 index 0000000..4ac5148 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/class-name.html @@ -0,0 +1,31 @@ +

Details

+ + +
+

Rule: class-name

+

+
+ + +

Enforces PascalCased class and interface names.

+ + + +
Rationale
+

Makes it easy to differentitate classes from regular variables at a glance.

+ + + + +

Config

+

Not configurable.

+ + +
Examples
+ +
"class-name": true
+ + +
Schema
+
{}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/comment-format.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/comment-format.html new file mode 100644 index 0000000..e89d167 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/comment-format.html @@ -0,0 +1,42 @@ +

Details

+ + +
+

Rule: comment-format

+

+
+ + +

Enforces formatting rules for single-line comments.

+ + + +
Rationale
+

Helps maintain a consistent, readable style in your codebase.

+ + + + +

Config

+ +

Three arguments may be optionally provided:

+ +
    +
  • "check-space" requires that all single-line comments must begin with a space, as in // comment +
      +
    • note that comments starting with /// are also allowed, for things such as ///<reference>
    • +
    +
  • +
  • "check-lowercase" requires that the first non-whitespace character of a comment must be lowercase, if applicable.
  • +
  • "check-uppercase" requires that the first non-whitespace character of a comment must be uppercase, if applicable.
  • +
+ + +
Examples
+ +
"comment-format": [true, "check-space", "check-lowercase"]
+ + +
Schema
+
{
"type": "list",
"listType": {
"type": "enum",
"enumValues": [
"check-space",
"check-lowercase",
"check-uppercase"
]
}
}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/curly.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/curly.html new file mode 100644 index 0000000..85f0c29 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/curly.html @@ -0,0 +1,36 @@ +

Details

+ + +
+

Rule: curly

+

+
+ + +

Enforces braces for if/for/do/while statements.

+ + + +
Rationale
+ +
if (foo === bar)
foo++;
bar++;
+ +

In the code above, the author almost certainly meant for both foo++ and bar++ +to be executed only if foo === bar. However, he forgot braces and bar++ will be executed +no matter what. This rule could prevent such a mistake.

+ + + + +

Config

+

Not configurable.

+ + +
Examples
+ +
"curly": true
+ + +
Schema
+
{}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/eofline.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/eofline.html new file mode 100644 index 0000000..e77e912 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/eofline.html @@ -0,0 +1,31 @@ +

Details

+ + +
+

Rule: eofline

+

+
+ + +

Ensures the file ends with a newline.

+ + + +
Rationale
+

It is a standard convention to end files with a newline.

+ + + + +

Config

+

Not configurable.

+ + +
Examples
+ +
"eofline": true
+ + +
Schema
+
{}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/forin.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/forin.html new file mode 100644 index 0000000..3dca177 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/forin.html @@ -0,0 +1,35 @@ +

Details

+ + +
+

Rule: forin

+

+
+ + +

Requires a for ... in statement to be filtered with an if statement.

+ + + +
Rationale
+ +
for (let key in someObject) {
if (someObject.hasOwnProperty(key)) {
// code here
}
}
+

Prevents accidental interation over properties inherited from an object’s prototype. +See MDN’s for...in +documentation for more information about for...in loops.

+ + + + +

Config

+

Not configurable.

+ + +
Examples
+ +
"forin": true
+ + +
Schema
+
{}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/indent.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/indent.html new file mode 100644 index 0000000..b432c9f --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/indent.html @@ -0,0 +1,39 @@ +

Details

+ + +
+

Rule: indent

+

+
+ + +

Enforces indentation with tabs or spaces.

+ + + +
Rationale
+ +

Using only one of tabs or spaces for indentation leads to more consistent editor behavior, +cleaner diffs in version control, and easier programatic manipulation.

+ + + + +

Config

+ +

One of the following arguments must be provided:

+ +
    +
  • "spaces" enforces consistent spaces.
  • +
  • "tabs" enforces consistent tabs.
  • +
+ + +
Examples
+ +
"indent": [true, "spaces"]
+ + +
Schema
+
{
"type": "enum",
"enumValues": [
"tabs",
"spaces"
]
}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/interface-name.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/interface-name.html new file mode 100644 index 0000000..ba0a4a1 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/interface-name.html @@ -0,0 +1,39 @@ +

Details

+ + +
+

Rule: interface-name

+

+
+ + +

Requires interface names to begin with a capital ‘I’

+ + + +
Rationale
+

Makes it easy to differentitate interfaces from regular classes at a glance.

+ + + + +

Config

+ +

One of the following two options must be provided:

+ +
    +
  • "always-prefix" requires interface names to start with an “I”
  • +
  • "never-prefix" requires interface names to not have an “I” prefix
  • +
+ + +
Examples
+ +
"interface-name": [true, "always-prefix"]
+ +
"interface-name": [true, "never-prefix"]
+ + +
Schema
+
{
"type": "enum",
"enumValues": [
"always-prefix",
"never-prefix"
]
}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/jsdoc-format.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/jsdoc-format.html new file mode 100644 index 0000000..9967284 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/jsdoc-format.html @@ -0,0 +1,42 @@ +

Details

+ + +
+

Rule: jsdoc-format

+

+
+ + +

Enforces basic format rules for JSDoc comments.

+ + + +

The following rules are enforced for JSDoc comments (comments starting with /**):

+ +
    +
  • each line contains an asterisk and asterisks must be aligned
  • +
  • each asterisk must be followed by either a space or a newline (except for the first and the last)
  • +
  • the only characters before the asterisk on each line must be whitespace characters
  • +
  • one line comments must start with /** and end with */
  • +
+ + + +
Rationale
+

Helps maintain a consistent, readable style for JSDoc comments.

+ + + + +

Config

+

Not configurable.

+ + +
Examples
+ +
"jsdoc-format": true
+ + +
Schema
+
{}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/label-position.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/label-position.html new file mode 100644 index 0000000..813f060 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/label-position.html @@ -0,0 +1,37 @@ +

Details

+ + +
+

Rule: label-position

+

+
+ + +

Only allows labels in sensible locations.

+ + +

This rule only allows labels to be on do/for/while/switch statements.

+ + + +
Rationale
+ +

Labels in JavaScript only can be used in conjunction with break or continue, +constructs meant to be used for loop flow control. While you can theoretically use +labels on any block statement in JS, it is considered poor code structure to do so.

+ + + + +

Config

+

Not configurable.

+ + +
Examples
+ +
"label-position": true
+ + +
Schema
+
{}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/label-undefined.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/label-undefined.html new file mode 100644 index 0000000..5fa9d1a --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/label-undefined.html @@ -0,0 +1,34 @@ +

Details

+ + +
+

Rule: label-undefined

+

+
+ + +

Checks that labels are defined before usage.

+ + +

This rule is now implemented in the TypeScript compiler and does not need to be used.

+ + + +
Rationale
+

Using break or continue to go to an out-of-scope label is an error in JS.

+ + + + +

Config

+

Not configurable.

+ + +
Examples
+ +
"label-undefined": true
+ + +
Schema
+
{}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/max-line-length.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/max-line-length.html new file mode 100644 index 0000000..676917f --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/max-line-length.html @@ -0,0 +1,34 @@ +

Details

+ + +
+

Rule: max-line-length

+

+
+ + +

Requires lines to be under a certain max length.

+ + + +
Rationale
+ +

Limiting the length of a line of code improves code readability. +It also makes comparing code side-by-side easier and improves compatibility with +various editors, IDEs, and diff viewers.

+ + + + +

Config

+

An integer indicating the max length of lines.

+ + +
Examples
+ +
"max-line-length": [true, 120]
+ + +
Schema
+
{
"type": "number"
}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/member-access.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/member-access.html new file mode 100644 index 0000000..12e1e63 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/member-access.html @@ -0,0 +1,39 @@ +

Details

+ + +
+

Rule: member-access

+

+
+ + +

Requires explicit visibility declarations for class members.

+ + + +
Rationale
+

Explicit visibility declarations can make code more readable and accessible for those new to TS.

+ + + + +

Config

+ +

Two arguments may be optionally provided:

+ +
    +
  • "check-accessor" enforces explicit visibility on get/set accessors (can only be public)
  • +
  • "check-constructor" enforces explicit visibility on constructors (can only be public)
  • +
+ + +
Examples
+ +
"member-access": true
+ +
"member-access": [true, "check-accessor"]
+ + +
Schema
+
{
"type": "list",
"listType": {
"type": "enum",
"enumValues": [
"check-accessor",
"check-constructor"
]
}
}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/member-ordering.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/member-ordering.html new file mode 100644 index 0000000..9fa58ac --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/member-ordering.html @@ -0,0 +1,59 @@ +

Details

+ + +
+

Rule: member-ordering

+

+
+ + +

Enforces member ordering.

+ + + +
Rationale
+

A consistent ordering for class members can make classes easier to read, navigate, and edit.

+ + + + +

Config

+ +

One argument, which is an object, must be provided. It should contain an order property. +The order property should have a value of one of the following strings:

+ +
    +
  • fields-first
  • +
  • statics-first
  • +
  • instance-sandwich
  • +
+ +

Alternatively, the value for order maybe be an array consisting of the following strings:

+ +
    +
  • public-static-field
  • +
  • protected-static-field
  • +
  • private-static-field
  • +
  • public-instance-field
  • +
  • protected-instance-field
  • +
  • private-instance-field
  • +
  • constructor
  • +
  • public-static-method
  • +
  • protected-static-method
  • +
  • private-static-method
  • +
  • public-instance-method
  • +
  • protected-instance-method
  • +
  • private-instance-method
  • +
+ +

This is useful if one of the preset orders does not meet your needs.

+ + +
Examples
+ +
"member-ordering": [true, { "order": "fields-first" }]
+ + +
Schema
+
{
"type": "object",
"properties": {
"order": {
"type": "enum",
"enumValues": [
"fields-first",
"statics-first",
"instance-sandwich"
]
}
}
}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/new-parens.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/new-parens.html new file mode 100644 index 0000000..085e9ff --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/new-parens.html @@ -0,0 +1,31 @@ +

Details

+ + +
+

Rule: new-parens

+

+
+ + +

Requires parentheses when invoking a constructor via the new keyword.

+ + + +
Rationale
+

Maintains stylistic consistency with other function calls.

+ + + + +

Config

+

Not configurable.

+ + +
Examples
+ +
"new-parens": true
+ + +
Schema
+
{}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-angle-bracket-type-assertion.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-angle-bracket-type-assertion.html new file mode 100644 index 0000000..4b5a7e4 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-angle-bracket-type-assertion.html @@ -0,0 +1,34 @@ +

Details

+ + +
+

Rule: no-angle-bracket-type-assertion

+

+
+ + +

Requires the use of as Type for type assertions instead of <Type>.

+ + + +
Rationale
+ +

Both formats of type assertions have the same effect, but only as type assertions +work in .tsx files. This rule ensures that you have a consistent type assertion style +across your codebase.

+ + + + +

Config

+

Not configurable.

+ + +
Examples
+ +
"no-angle-bracket-type-assertion": true
+ + +
Schema
+
{}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-any.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-any.html new file mode 100644 index 0000000..4cdb8c1 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-any.html @@ -0,0 +1,31 @@ +

Details

+ + +
+

Rule: no-any

+

+
+ + +

Diallows usages of any as a type declaration.

+ + + +
Rationale
+

Using any as a type declaration nullifies the compile-time benefits of the type system.

+ + + + +

Config

+

Not configurable.

+ + +
Examples
+ +
"no-any": true
+ + +
Schema
+
{}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-arg.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-arg.html new file mode 100644 index 0000000..30e73f1 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-arg.html @@ -0,0 +1,34 @@ +

Details

+ + +
+

Rule: no-arg

+

+
+ + +

Disallows use of arguments.callee.

+ + + +
Rationale
+ +

Using arguments.callee makes various performance optimizations impossible. +See MDN +for more details on why to avoid arguments.callee.

+ + + + +

Config

+

Not configurable.

+ + +
Examples
+ +
"no-arg": true
+ + +
Schema
+
{}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-bitwise.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-bitwise.html new file mode 100644 index 0000000..0382bb6 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-bitwise.html @@ -0,0 +1,41 @@ +

Details

+ + +
+

Rule: no-bitwise

+

+
+ + +

Disallows bitwise operators.

+ + + +

Specifically, the following bitwise operators are banned: +&, &=, |, |=, +^, ^=, <<, <<=, +>>, >>=, >>>, >>>=, and ~. +This rule does not ban the use of & and | for intersection and union types.

+ + + +
Rationale
+ +

Bitwise operators are often typos - for example bool1 & bool2 instead of bool1 && bool2. +They also can be an indicator of overly clever code which decreases maintainability.

+ + + + +

Config

+

Not configurable.

+ + +
Examples
+ +
"no-bitwise": true
+ + +
Schema
+
{}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-conditional-assignment.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-conditional-assignment.html new file mode 100644 index 0000000..3ecde97 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-conditional-assignment.html @@ -0,0 +1,37 @@ +

Details

+ + +
+

Rule: no-conditional-assignment

+

+
+ + +

Disallows any type of assignment in conditionals.

+ + +

This applies to do-while, for, if, and while statements.

+ + + +
Rationale
+ +

Assignments in conditionals are often typos: +for example if (var1 = var2) instead of if (var1 == var2). +They also can be an indicator of overly clever code which decreases maintainability.

+ + + + +

Config

+

Not configurable.

+ + +
Examples
+ +
"no-conditional-assignment": true
+ + +
Schema
+
{}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-consecutive-blank-lines.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-consecutive-blank-lines.html new file mode 100644 index 0000000..e9e014d --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-consecutive-blank-lines.html @@ -0,0 +1,31 @@ +

Details

+ + +
+

Rule: no-consecutive-blank-lines

+

+
+ + +

Disallows more than one blank line in a row.

+ + + +
Rationale
+

Helps maintain a readable style in your codebase.

+ + + + +

Config

+

Not configurable.

+ + +
Examples
+ +
"no-consecutive-blank-lines": true
+ + +
Schema
+
{}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-console.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-console.html new file mode 100644 index 0000000..479c9c4 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-console.html @@ -0,0 +1,31 @@ +

Details

+ + +
+

Rule: no-console

+

+
+ + +

Bans the use of specified console methods.

+ + + +
Rationale
+

In general, console methods aren’t appropriate for production code.

+ + + + +

Config

+

A list of method names to ban.

+ + +
Examples
+ +
"no-console": [true, ["log", "error"]]
+ + +
Schema
+
{
"type": "list",
"listType": {
"type": "string"
}
}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-construct.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-construct.html new file mode 100644 index 0000000..d433bb1 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-construct.html @@ -0,0 +1,37 @@ +

Details

+ + +
+

Rule: no-construct

+

+
+ + +

Disallows access to the constructors of String, Number, and Boolean.

+ + +

Disallows constructor use such as new Number(foo) but does not disallow Number(foo).

+ + + +
Rationale
+ +

There is little reason to use String, Number, or Boolean as constructors. +In almost all cases, the regular function-call version is more appropriate. +More details are available on StackOverflow.

+ + + + +

Config

+

Not configurable.

+ + +
Examples
+ +
"no-construct": true
+ + +
Schema
+
{}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-constructor-vars.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-constructor-vars.html new file mode 100644 index 0000000..025d752 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-constructor-vars.html @@ -0,0 +1,33 @@ +

Details

+ + +
+

Rule: no-constructor-vars

+

+
+ + +

Disallows parameter properties.

+ + + +
Rationale
+ +

Parameter properties can be confusing to those new to TS as they are less explicit +than other ways of declaring and initializing class members.

+ + + + +

Config

+

Not configurable.

+ + +
Examples
+ +
"no-constructor-vars": true
+ + +
Schema
+
{}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-debugger.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-debugger.html new file mode 100644 index 0000000..339dbbe --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-debugger.html @@ -0,0 +1,31 @@ +

Details

+ + +
+

Rule: no-debugger

+

+
+ + +

Disallows debugger statements.

+ + + +
Rationale
+

In general, debugger statements aren’t appropriate for production code.

+ + + + +

Config

+

Not configurable.

+ + +
Examples
+ +
"no-debugger": true
+ + +
Schema
+
{}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-default-export.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-default-export.html new file mode 100644 index 0000000..c76ee80 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-default-export.html @@ -0,0 +1,37 @@ +

Details

+ + +
+

Rule: no-default-export

+

+
+ + +

Disallows default exports in ES6-style modules.

+ + +

Use named exports instead.

+ + + +
Rationale
+ +

Named imports/exports promote clarity. +In addition, current tooling differs on the correct way to handle default imports/exports. +Avoiding them all together can help avoid tooling bugs and conflicts.

+ + + + +

Config

+

Not configurable.

+ + +
Examples
+ +
"no-default-export": true
+ + +
Schema
+
{}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-duplicate-key.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-duplicate-key.html new file mode 100644 index 0000000..59e7aaf --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-duplicate-key.html @@ -0,0 +1,33 @@ +

Details

+ + +
+

Rule: no-duplicate-key

+

+
+ + +

Disallows duplicate keys in object literals.

+ + + +
Rationale
+ +

There is no good reason to define an object literal with the same key twice. +This rule is now implemented in the TypeScript compiler and does not need to be used.

+ + + + +

Config

+

Not configurable.

+ + +
Examples
+ +
"no-duplicate-key": true
+ + +
Schema
+
{}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-duplicate-variable.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-duplicate-variable.html new file mode 100644 index 0000000..91091e6 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-duplicate-variable.html @@ -0,0 +1,38 @@ +

Details

+ + +
+

Rule: no-duplicate-variable

+

+
+ + +

Disallows duplicate variable declarations in the same block scope.

+ + + +

This rule is only useful when using the var keyword - +the compiler will detect redeclarations of let and const variables.

+ + + +
Rationale
+ +

A variable can be reassigned if necessary - +there’s no good reason to have a duplicate variable declaration.

+ + + + +

Config

+

Not configurable.

+ + +
Examples
+ +
"no-duplicate-variable": true
+ + +
Schema
+
{}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-empty.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-empty.html new file mode 100644 index 0000000..2de7aa4 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-empty.html @@ -0,0 +1,34 @@ +

Details

+ + +
+

Rule: no-empty

+

+
+ + +

Disallows empty blocks.

+ + +

Blocks with a comment inside are not considered empty.

+ + + +
Rationale
+

Empty blocks are often indicators of missing code.

+ + + + +

Config

+

Not configurable.

+ + +
Examples
+ +
"no-empty": true
+ + +
Schema
+
{}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-eval.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-eval.html new file mode 100644 index 0000000..28e76d3 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-eval.html @@ -0,0 +1,34 @@ +

Details

+ + +
+

Rule: no-eval

+

+
+ + +

Disallows eval function invocations.

+ + + +
Rationale
+ +

eval() is dangerous as it allows arbitrary code execution with full privileges. There are +alternatives +for most of the use cases for eval().

+ + + + +

Config

+

Not configurable.

+ + +
Examples
+ +
"no-eval": true
+ + +
Schema
+
{}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-inferrable-types.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-inferrable-types.html new file mode 100644 index 0000000..2456a7f --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-inferrable-types.html @@ -0,0 +1,39 @@ +

Details

+ + +
+

Rule: no-inferrable-types

+

+
+ + +

Disallows explicit type declarations for variables or parameters initialized to a number, string, or boolean.

+ + + +
Rationale
+

Explicit types where they can be easily infered by the compiler make code more verbose.

+ + + + +

Config

+ +

One argument may be optionally provided:

+ +
    +
  • ignore-params allows specifying an inferrable type annotation for function params. +This can be useful when combining with the typedef rule.
  • +
+ + +
Examples
+ +
"no-inferrable-types": true
+ +
"no-inferrable-types": [true, "ignore-params"]
+ + +
Schema
+
{
"type": "list",
"listType": {
"type": "enum",
"enumValues": [
"ignore-params"
]
}
}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-internal-module.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-internal-module.html new file mode 100644 index 0000000..1ce01b3 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-internal-module.html @@ -0,0 +1,31 @@ +

Details

+ + +
+

Rule: no-internal-module

+

+
+ + +

Disallows internal module

+ + + +
Rationale
+

Using module leads to a confusion of concepts with external modules. Use the newer namespace keyword instead.

+ + + + +

Config

+

Not configurable.

+ + +
Examples
+ +
"no-internal-module": true
+ + +
Schema
+
{}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-invalid-this.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-invalid-this.html new file mode 100644 index 0000000..ebe6191 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-invalid-this.html @@ -0,0 +1,38 @@ +

Details

+ + +
+

Rule: no-invalid-this

+

+
+ + +

Disallows using the this keyword outside of classes.

+ + + +
Rationale
+

See the rule’s author’s rationale here.

+ + + + +

Config

+ +

One argument may be optionally provided:

+ +
    +
  • check-function-in-method disallows using the this keyword in functions within class methods.
  • +
+ + +
Examples
+ +
"no-invalid-this": true
+ +
"no-invalid-this": [true, "check-function-in-method"]
+ + +
Schema
+
{
"type": "list",
"listType": {
"type": "enum",
"enumValues": [
"check-function-in-method"
]
}
}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-namespace.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-namespace.html new file mode 100644 index 0000000..850069b --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-namespace.html @@ -0,0 +1,43 @@ +

Details

+ + +
+

Rule: no-namespace

+

+
+ + +

Disallows use of internal modules and namespaces.

+ + +

This rule still allows the use of declare module ... {}

+ + + +
Rationale
+ +

ES6-style external modules are the standard way to modularize code. +Using module {} and namespace {} are outdated ways to organize TypeScript code.

+ + + + +

Config

+ +

One argument may be optionally provided:

+ +
    +
  • allow-declarations allows declare namespace ... {} to describe external APIs.
  • +
+ + +
Examples
+ +
"no-namespace": true
+ +
"no-namespace": [true, "allow-declarations"]
+ + +
Schema
+
{
"type": "list",
"listType": {
"type": "enum",
"enumValues": [
"allow-declarations"
]
}
}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-null-keyword.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-null-keyword.html new file mode 100644 index 0000000..2e87659 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-null-keyword.html @@ -0,0 +1,33 @@ +

Details

+ + +
+

Rule: no-null-keyword

+

+
+ + +

Disallows use of the null keyword literal.

+ + + +
Rationale
+ +

Instead of having the dual concepts of null andundefined in a codebase, +this rule ensures that only undefined is used.

+ + + + +

Config

+

Not configurable.

+ + +
Examples
+ +
"no-null-keyword": true
+ + +
Schema
+
{}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-reference.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-reference.html new file mode 100644 index 0000000..0ab2baf --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-reference.html @@ -0,0 +1,33 @@ +

Details

+ + +
+

Rule: no-reference

+

+
+ + +

Disallows /// <reference path=> imports (use ES6-style imports instead).

+ + + +
Rationale
+ +

Using /// <reference path=> comments to load other files is outdated. +Use ES6-style imports to reference other files.

+ + + + +

Config

+

Not configurable.

+ + +
Examples
+ +
"no-reference": true
+ + +
Schema
+
{}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-require-imports.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-require-imports.html new file mode 100644 index 0000000..3c6d2a7 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-require-imports.html @@ -0,0 +1,31 @@ +

Details

+ + +
+

Rule: no-require-imports

+

+
+ + +

Disallows invocation of require().

+ + + +
Rationale
+

Prefer the newer ES6-style imports over require().

+ + + + +

Config

+

Not configurable.

+ + +
Examples
+ +
"no-require-imports": true
+ + +
Schema
+
{}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-shadowed-variable.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-shadowed-variable.html new file mode 100644 index 0000000..f1fef2a --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-shadowed-variable.html @@ -0,0 +1,31 @@ +

Details

+ + +
+

Rule: no-shadowed-variable

+

+
+ + +

Disallows shadowing variable declarations.

+ + + +
Rationale
+

Shadowing a variable masks access to it and obscures to what value an identifier actually refers.

+ + + + +

Config

+

Not configurable.

+ + +
Examples
+ +
"no-shadowed-variable": true
+ + +
Schema
+
{}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-string-literal.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-string-literal.html new file mode 100644 index 0000000..deea3c8 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-string-literal.html @@ -0,0 +1,31 @@ +

Details

+ + +
+

Rule: no-string-literal

+

+
+ + +

Disallows object access via string literals.

+ + + +
Rationale
+

Encourages using strongly-typed property access.

+ + + + +

Config

+

Not configurable.

+ + +
Examples
+ +
"no-string-literal": true
+ + +
Schema
+
{}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-switch-case-fall-through.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-switch-case-fall-through.html new file mode 100644 index 0000000..3056e29 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-switch-case-fall-through.html @@ -0,0 +1,42 @@ +

Details

+ + +
+

Rule: no-switch-case-fall-through

+

+
+ + +

Disallows falling through case statements.

+ + + +

For example, the following is not allowed:

+ +
switch(foo) {
case 1:
someFunc(foo);
case 2:
someOtherFunc(foo);
}
+ +

However, fall through is allowed when case statements are consecutive or +a magic /* falls through */ comment is present. The following is valid:

+ +
switch(foo) {
case 1:
someFunc(foo);
/* falls through */
case 2:
case 3:
someOtherFunc(foo);
}
+ + + +
Rationale
+

Fall though in switch statements is often unintentional and a bug.

+ + + + +

Config

+

Not configurable.

+ + +
Examples
+ +
"no-switch-case-fall-through": true
+ + +
Schema
+
{}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-trailing-whitespace.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-trailing-whitespace.html new file mode 100644 index 0000000..aee4742 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-trailing-whitespace.html @@ -0,0 +1,31 @@ +

Details

+ + +
+

Rule: no-trailing-whitespace

+

+
+ + +

Disallows trailing whitespace at the end of a line.

+ + + +
Rationale
+

Keeps version control diffs clean as it prevents accidental whitespace from being committed.

+ + + + +

Config

+

Not configurable.

+ + +
Examples
+ +
"no-trailing-whitespace": true
+ + +
Schema
+
{}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-unreachable.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-unreachable.html new file mode 100644 index 0000000..4d9b8b7 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-unreachable.html @@ -0,0 +1,31 @@ +

Details

+ + +
+

Rule: no-unreachable

+

+
+ + +

Disallows unreachable code after break, catch, throw, and return statements.

+ + + +
Rationale
+

Unreachable code is often indication of a logic error.

+ + + + +

Config

+

Not configurable.

+ + +
Examples
+ +
"no-unreachable": true
+ + +
Schema
+
{}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-unused-expression.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-unused-expression.html new file mode 100644 index 0000000..d44a6f6 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-unused-expression.html @@ -0,0 +1,38 @@ +

Details

+ + +
+

Rule: no-unused-expression

+

+
+ + +

Disallows unused expression statements.

+ + + +

Unused expressions are expression statements which are not assignments or function calls +(and thus usually no-ops).

+ + + +
Rationale
+ +

Detects potential errors where an assignment or function call was intended. Also detects constructs such as +new SomeClass(), where a constructor is used solely for its side effects, which is considered poor style.

+ + + + +

Config

+

Not configurable.

+ + +
Examples
+ +
"no-unused-expression": true
+ + +
Schema
+
{}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-unused-variable.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-unused-variable.html new file mode 100644 index 0000000..b6cb98f --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-unused-variable.html @@ -0,0 +1,45 @@ +

Details

+ + +
+

Rule: no-unused-variable

+

+
+ + +

Disallows unused imports, variables, functions and private class members.

+ + + + + +

Config

+ +

Three optional arguments may be optionally provided:

+ +
    +
  • "check-parameters" disallows unused function and constructor parameters. +
      +
    • NOTE: this option is experimental and does not work with classes + that use abstract method declarations, among other things.
    • +
    +
  • +
  • "react" relaxes the rule for a namespace import named React +(from either the module "react" or "react/addons"). +Any JSX expression in the file will be treated as a usage of React +(because it expands to React.createElement ).
  • +
  • {"ignore-pattern": "pattern"} where pattern is a case-sensitive regexp. +Variable names that match the pattern will be ignored.
  • +
+ + +
Examples
+ +
"no-unused-variable": [true, "react"]
+ +
"no-unused-variable": [true, {"ignore-pattern": "^_"}]
+ + +
Schema
+
{
"type": "array",
"arrayMembers": [
{
"type": "list",
"listType": {
"type": "enum",
"enumValues": [
"check-parameters",
"react"
]
}
},
{
"type": "object",
"properties": {
"ignore-pattern": {
"type": "string"
}
}
}
]
}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-use-before-declare.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-use-before-declare.html new file mode 100644 index 0000000..089f66c --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-use-before-declare.html @@ -0,0 +1,32 @@ +

Details

+ + +
+

Rule: no-use-before-declare

+

+
+ + +

Disallows usage of variables before their declaration.

+ + + +

This rule is primarily useful when using the var keyword - +the compiler will detect if a let and const variable is used before it is declared.

+ + + + + +

Config

+

Not configurable.

+ + +
Examples
+ +
"no-use-before-declare": true
+ + +
Schema
+
{}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-var-keyword.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-var-keyword.html new file mode 100644 index 0000000..bbf9480 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-var-keyword.html @@ -0,0 +1,30 @@ +

Details

+ + +
+

Rule: no-var-keyword

+

+
+ + +

Disallows usage of the var keyword.

+ + +

Use let or const instead.

+ + + + + +

Config

+

Not configurable.

+ + +
Examples
+ +
"no-var-keyword": true
+ + +
Schema
+
{}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-var-requires.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-var-requires.html new file mode 100644 index 0000000..4b4670d --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/no-var-requires.html @@ -0,0 +1,32 @@ +

Details

+ + +
+

Rule: no-var-requires

+

+
+ + +

Disallows the use of require statements except in import statements.

+ + + +

In other words, the use of forms such as var module = require("module") are banned. +Instead use ES6 style imports or import foo = require('foo') imports.

+ + + + + +

Config

+

Not configurable.

+ + +
Examples
+ +
"no-var-requires": true
+ + +
Schema
+
{}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/object-literal-sort-keys.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/object-literal-sort-keys.html new file mode 100644 index 0000000..097844c --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/object-literal-sort-keys.html @@ -0,0 +1,31 @@ +

Details

+ + +
+

Rule: object-literal-sort-keys

+

+
+ + +

Requires keys in object literals to be sorted alphabetically

+ + + +
Rationale
+

Useful in preventing merge conflicts

+ + + + +

Config

+

Not configurable.

+ + +
Examples
+ +
"object-literal-sort-keys": true
+ + +
Schema
+
{}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/one-line.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/one-line.html new file mode 100644 index 0000000..245aeaa --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/one-line.html @@ -0,0 +1,36 @@ +

Details

+ + +
+

Rule: one-line

+

+
+ + +

Requires the specified tokens to be on the same line as the expression preceding them.

+ + + + + +

Config

+ +

Five arguments may be optionally provided:

+ +
    +
  • "check-catch" checks that catch is on the same line as the closing brace for try.
  • +
  • "check-finally" checks that finally is on the same line as the closing brace for catch.
  • +
  • "check-else" checks that else is on the same line as the closing brace for if.
  • +
  • "check-open-brace" checks that an open brace falls on the same line as its preceding expression.
  • +
  • "check-whitespace" checks preceding whitespace for the specified tokens.
  • +
+ + +
Examples
+ +
"one-line": [true, "check-catch", "check-finally", "check-else"]
+ + +
Schema
+
{
"type": "list",
"listType": {
"type": "enum",
"enumValues": [
"check-catch",
"check-finally",
"check-else",
"check-open-brace",
"check-whitespace"
]
}
}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/one-variable-per-declaration.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/one-variable-per-declaration.html new file mode 100644 index 0000000..1a5a5e2 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/one-variable-per-declaration.html @@ -0,0 +1,34 @@ +

Details

+ + +
+

Rule: one-variable-per-declaration

+

+
+ + +

Disallows multiple variable definitions in the same declaration statement.

+ + + + + +

Config

+ +

One argument may be optionally provided:

+ +
    +
  • ignore-for-loop allows multiple variable definitions in a for loop declaration.
  • +
+ + +
Examples
+ +
"one-variable-per-declaration": true
+ +
"one-variable-per-declaration": [true, "ignore-for-loop"]
+ + +
Schema
+
{
"type": "list",
"listType": {
"type": "enum",
"enumValues": [
"ignore-for-loop"
]
}
}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/quotemark.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/quotemark.html new file mode 100644 index 0000000..090cfb6 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/quotemark.html @@ -0,0 +1,39 @@ +

Details

+ + +
+

Rule: quotemark

+

+
+ + +

Requires single or double quotes for string literals.

+ + + + + +

Config

+ +

Five arguments may be optionally provided:

+ +
    +
  • "single" enforces single quotes.
  • +
  • "double" enforces double quotes.
  • +
  • "jsx-single" enforces single quotes for JSX attributes.
  • +
  • "jsx-double" enforces double quotes for JSX attributes.
  • +
  • "avoid-escape" allows you to use the “other” quotemark in cases where escaping would normally be required. +For example, [true, "double", "avoid-escape"] would not report a failure on the string literal 'Hello "World"'.
  • +
+ + +
Examples
+ +
"quotemark": [true, "single", "avoid-escape"]
+ +
"quotemark": [true, "single", "jsx-double"]
+ + +
Schema
+
{
"type": "list",
"listType": {
"type": "enum",
"enumValues": [
"single",
"double",
"jsx-single",
"jsx-double",
"avoid-escape"
]
}
}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/radix.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/radix.html new file mode 100644 index 0000000..49a7a78 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/radix.html @@ -0,0 +1,34 @@ +

Details

+ + +
+

Rule: radix

+

+
+ + +

Requires the radix parameter to be specified when calling parseInt.

+ + + +
Rationale
+ +

From MDN: +> Always specify this parameter to eliminate reader confusion and to guarantee predictable behavior. +> Different implementations produce different results when a radix is not specified, usually defaulting the value to 10.

+ + + + +

Config

+

Not configurable.

+ + +
Examples
+ +
"radix": true
+ + +
Schema
+
{}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/semicolon.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/semicolon.html new file mode 100644 index 0000000..d9dbd5b --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/semicolon.html @@ -0,0 +1,35 @@ +

Details

+ + +
+

Rule: semicolon

+

+
+ + +

Enforces consistent semicolon usage at the end of every statement.

+ + + + + +

Config

+ +

One of the following arguments must be provided:

+ +
    +
  • "always" enforces semicolons at the end of every statement.
  • +
  • "never" disallows semicolons at the end of every statement except for when they are necessary.
  • +
+ + +
Examples
+ +
"semicolon": [true, "always"]
+ +
"semicolon": [true, "never"]
+ + +
Schema
+
{
"type": "enum",
"enumValues": [
"always",
"never"
]
}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/switch-default.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/switch-default.html new file mode 100644 index 0000000..e186954 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/switch-default.html @@ -0,0 +1,27 @@ +

Details

+ + +
+

Rule: switch-default

+

+
+ + +

Require a default case in all switch statements.

+ + + + + +

Config

+

Not configurable.

+ + +
Examples
+ +
"switch-default": true
+ + +
Schema
+
{}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/trailing-comma.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/trailing-comma.html new file mode 100644 index 0000000..fbfec2c --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/trailing-comma.html @@ -0,0 +1,38 @@ +

Details

+ + +
+

Rule: trailing-comma

+

+
+ + +

Requires or disallows trailing commas in array and object literals, destructuring assignments and named imports.

+ + + + + +

Config

+ +

One argument which is an object with the keys multiline and singleline. +Both should be set to either "always" or "never".

+ +
    +
  • "multiline" checks multi-line object literals.
  • +
  • "singleline" checks single-line object literals.
  • +
+ +

A array is considered “multiline” if its closing bracket is on a line +after the last array element. The same general logic is followed for +object literals and named import statements.

+ + +
Examples
+ +
"trailing-comma": [true, {"multiline": "always", "singleline": "never"}]
+ + +
Schema
+
{
"type": "object",
"properties": {
"multiline": {
"type": "enum",
"enumValues": [
"always",
"never"
]
},
"singleline": {
"type": "enum",
"enumValues": [
"always",
"never"
]
}
}
}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/triple-equals.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/triple-equals.html new file mode 100644 index 0000000..970f923 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/triple-equals.html @@ -0,0 +1,37 @@ +

Details

+ + +
+

Rule: triple-equals

+

+
+ + +

Requires === and !== in place of == and !=.

+ + + + + +

Config

+ +

Two arguments may be optionally provided:

+ +
    +
  • "allow-null-check" allows == and != when comparing to null.
  • +
  • "allow-undefined-check" allows == and != when comparing to undefined.
  • +
+ + +
Examples
+ +
"triple-equals": true
+ +
"triple-equals": [true, "allow-null-check"]
+ +
"triple-equals": [true, "allow-undefined-check"]
+ + +
Schema
+
{
"type": "list",
"listType": {
"type": "enum",
"enumValues": [
"allow-null-check",
"allow-undefined-check"
]
}
}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/typedef-whitespace.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/typedef-whitespace.html new file mode 100644 index 0000000..9f81c0a --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/typedef-whitespace.html @@ -0,0 +1,43 @@ +

Details

+ + +
+

Rule: typedef-whitespace

+

+
+ + +

Requires or disallows whitespace for type definitions.

+ + +

Determines if a space is required or not before the colon in a type specifier.

+ + + + + +

Config

+ +

Two arguments which are both objects. +The first argument specifies how much space should be to the left of a typedef colon. +The second argument specifies how much space should be to the right of a typedef colon. +Each key should have a value of "space" or "nospace". +Possible keys are:

+ +
    +
  • "call-signature" checks return type of functions.
  • +
  • "index-signature" checks index type specifier of indexers.
  • +
  • "parameter" checks function parameters.
  • +
  • "property-declaration" checks object property declarations.
  • +
  • "variable-declaration" checks variable declaration.
  • +
+ + +
Examples
+ +
"typedef-whitespace": 
[
true,
{
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
},
{
"call-signature": "onespace",
"index-signature": "onespace",
"parameter": "onespace",
"property-declaration": "onespace",
"variable-declaration": "onespace"
}
]
+ + +
Schema
+
{
"type": "array",
"arrayMembers": [
{
"type": "object",
"properties": {
"call-signature": {
"type": "enum",
"enumValues": [
"nospace",
"onespace",
"space"
]
},
"index-signature": {
"type": "enum",
"enumValues": [
"nospace",
"onespace",
"space"
]
},
"parameter": {
"type": "enum",
"enumValues": [
"nospace",
"onespace",
"space"
]
},
"property-declaration": {
"type": "enum",
"enumValues": [
"nospace",
"onespace",
"space"
]
},
"variable-declaration": {
"type": "enum",
"enumValues": [
"nospace",
"onespace",
"space"
]
}
}
},
{
"type": "object",
"properties": {
"call-signature": {
"type": "enum",
"enumValues": [
"nospace",
"onespace",
"space"
]
},
"index-signature": {
"type": "enum",
"enumValues": [
"nospace",
"onespace",
"space"
]
},
"parameter": {
"type": "enum",
"enumValues": [
"nospace",
"onespace",
"space"
]
},
"property-declaration": {
"type": "enum",
"enumValues": [
"nospace",
"onespace",
"space"
]
},
"variable-declaration": {
"type": "enum",
"enumValues": [
"nospace",
"onespace",
"space"
]
}
}
}
]
}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/typedef.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/typedef.html new file mode 100644 index 0000000..5b81a22 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/typedef.html @@ -0,0 +1,37 @@ +

Details

+ + +
+

Rule: typedef

+

+
+ + +

Requires type definitions to exist.

+ + + + + +

Config

+ +

Six arguments may be optionally provided:

+ +
    +
  • "call-signature" checks return type of functions.
  • +
  • "parameter" checks type specifier of function parameters for non-arrow functions.
  • +
  • "arrow-parameter" checks type specifier of function parameters for arrow functions.
  • +
  • "property-declaration" checks return types of interface properties.
  • +
  • "variable-declaration" checks variable declarations.
  • +
  • "member-variable-declaration" checks member variable declarations.
  • +
+ + +
Examples
+ +
"typedef": [true, "call-signature", "parameter", "member-variable-declaration"]
+ + +
Schema
+
{
"type": "list",
"listType": {
"type": "enum",
"enumValues": [
"call-signature",
"parameter",
"arrow-parameter",
"property-declaration",
"variable-declaration",
"member-variable-declaration"
]
}
}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/use-isnan.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/use-isnan.html new file mode 100644 index 0000000..2b8be45 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/use-isnan.html @@ -0,0 +1,33 @@ +

Details

+ + +
+

Rule: use-isnan

+

+
+ + +

Enforces use of the isNaN() function to check for NaN references instead of a comparison to the NaN constant.

+ + + +
Rationale
+ +

Since NaN !== NaN, comparisons with regular operators will produce unexpected results. +So, instead of if (myVar === NaN), do if (isNaN(myVar)).

+ + + + +

Config

+

Not configurable.

+ + +
Examples
+ +
"use-isnan": true
+ + +
Schema
+
{}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/use-strict.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/use-strict.html new file mode 100644 index 0000000..67e26e5 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/use-strict.html @@ -0,0 +1,33 @@ +

Details

+ + +
+

Rule: use-strict

+

+
+ + +

Requires using ECMAScript 5’s strict mode.

+ + + + + +

Config

+ +

Two arguments may be optionally provided:

+ +
    +
  • check-module checks that all top-level modules are using strict mode.
  • +
  • check-function checks that all top-level functions are using strict mode.
  • +
+ + +
Examples
+ +
"use-strict": [true, "check-module"]
+ + +
Schema
+
{
"type": "list",
"listType": {
"type": "enum",
"enumValues": [
"check-module",
"check-function"
]
}
}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/variable-name.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/variable-name.html new file mode 100644 index 0000000..c5a843f --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/variable-name.html @@ -0,0 +1,40 @@ +

Details

+ + +
+

Rule: variable-name

+

+
+ + +

Checks variable names for various errors.

+ + + + + +

Config

+ +

Five arguments may be optionally provided:

+ +
    +
  • "check-format": allows only camelCased or UPPER_CASED variable names +
      +
    • "allow-leading-underscore" allows underscores at the beginning (only has an effect if “check-format” specified)
    • +
    • "allow-trailing-underscore" allows underscores at the end. (only has an effect if “check-format” specified)
    • +
    • "allow-pascal-case allows PascalCase in addtion to camelCase.
    • +
    +
  • +
  • "ban-keywords": disallows the use of certain TypeScript keywords (any, Number, number, String, +string, Boolean, boolean, undefined) as variable or parameter names.
  • +
+ + +
Examples
+ +
"variable-name": [true, "ban-keywords", "check-format", "allow-leading-underscore"]
+ + +
Schema
+
{
"type": "list",
"listType": {
"type": "enum",
"enumValues": [
"check-format",
"allow-leading-underscore",
"allow-trailing-underscore",
"allow-pascal-case",
"ban-keywords"
]
}
}
+ \ No newline at end of file diff --git a/sonar-web-frontend-typescript/src/main/resources/rules/tslint/whitespace.html b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/whitespace.html new file mode 100644 index 0000000..a133bd0 --- /dev/null +++ b/sonar-web-frontend-typescript/src/main/resources/rules/tslint/whitespace.html @@ -0,0 +1,42 @@ +

Details

+ + +
+

Rule: whitespace

+

+
+ + +

Enforces whitespace style conventions.

+ + + +
Rationale
+

Helps maintain a readable, consistent style in your codebase.

+ + + + +

Config

+ +

Seven arguments may be optionally provided:

+ +
    +
  • "check-branch" checks branching statements (if/else/for/while) are followed by whitespace.
  • +
  • "check-decl"checks that variable declarations have whitespace around the equals token.
  • +
  • "check-operator" checks for whitespace around operator tokens.
  • +
  • "check-module" checks for whitespace in import & export statements.
  • +
  • "check-separator" checks for whitespace after separator tokens (,/;).
  • +
  • "check-type" checks for whitespace before a variable type specification.
  • +
  • "check-typecast" checks for whitespace between a typecast and its target.
  • +
+ + +
Examples
+ +
"whitespace": [true, "check-branch", "check-operator", "check-typecast"]
+ + +
Schema
+
{
"type": "list",
"listType": {
"type": "enum",
"enumValues": [
"check-branch",
"check-decl",
"check-operator",
"check-module",
"check-seperator",
"check-type",
"check-typecast"
]
}
}
+ \ No newline at end of file