New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@nevware21/grunt-eslint-ts

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nevware21/grunt-eslint-ts

ESLint TypeScript Validation Plugin for GruntJS

  • 0.2.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
186
increased by21.57%
Maintainers
1
Weekly downloads
 
Created
Source

@Nevware21 grunt-eslint-ts

GitHub Workflow Status (main) npm version downloads

Grunt-eslint-ts provides a Grunt-compatible wrapper for running eslint using the @typescript-eslint parser for processing TypeScript files, and provides some additional options that improves the TypeScript development workflow.

Grunt-eslint-ts-plugin Features

TBD...

Unsupported Grunt features

  • Path Mapping feature as it is not supported by tsc from the command-line
  • Grunt dest target property, use the src options instead.
  • Grunt files property for identifying files to be compiled (*.ts), planned future feature (#18 - [Feature] Add support for Grunt files object)

Quickstart

Install the npm packare: npm install @nevware21/grunt-eslint-ts --save-dev

PackageDescriptpion
ESLintnpm install eslint --save-dev - if you don't have ESLint installed in your project, run
@typescript-eslint/eslint-pluginnpm install @typescript-eslint/eslint-plugin --save-dev - if you don't have the @typescript plugin installed
@typescript-eslint/parsernpm install @typescript-eslint/parser --save-dev - if you dont have the parser installed
eslint-plugin-security (Optional)npm install eslint-plugin-security --save-dev - If you want to auto inject the extra security plugin
TypeScriptnpm install typescript --save-dev - if you don't have TypeScript installed in your project, run
GruntJSnpm install grunt --save-dev - if you don't have GruntJS installed in your project
Grunt-Clinpm install grunt-cli --save-dev - Suggested, if you have never used Grunt on your system

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

Mininimal

module.exports = function(grunt) {
  grunt.initConfig({
    lint: {
      default : {
        tsconfig: './tsconfig.json'
      }
    }
  });
  grunt.loadNpmTasks("@nevware21/grunt-eslint-ts");
  grunt.registerTask("default", ["lint"]);
};

Options

The options can be specified at the global options, task options or directly on the task level, with the task level values overridding any value defined in the global options

Task only level options
NameTypeDescription
ignoreFailuresbooleanIgnore failures and continue, useful for initial linting runs for mono-repo's
Common options: Global and Task
NameTypeDescription
parserIESLintParserOverride the parser and plugin to use, defaults to { plugin: "@typescript-eslint"; name: "@typescript-eslint/parser" }, set to null to block the defaults from getting injected
additionalConfigLinter.ConfigAdditional Config that will be used to override the base Configuration, any additionalConfig will override any defaults
rulesLinter.RulesRecordAdditional specific rules to pass as overrides
logOutputbooleanLog the output (stdout, stderr) of the execute command eslint response
suppressWarningsbooleanOnly include errors in the output
fixbooleanFix all fixable errors and warnings
debugbooleanLog additional debug messages some are only display with grunt verbose messages enabled
quietbooleanDon't output the report to the console / grunt output
outputFilestringOutput the results to the provided file
formatstringSpecify the format of the eslint report, defaults to codeframe
tsconfigstringThe path to the tsConfig file to use, when specified
maxWarningsnumberIf more than this number of warnings are reported failed the task
srcstringstring[]
IEsLintParser
NameTypeDescription
namestringThe name of the parser to use for the eslint configuration, defaults to @typescript-eslint/parser if the @typescript-eslint/parser package exists in the node_modules
pluginsstring | string[]The plugin(s) to include for the eslint configuration, defaults to @typescript-eslint if the @typescript-eslint parser / plugin package exists in the node_modules, when the plugin is detected this also injects the plugin:@typescript-eslint/recommended rules extension (This may change in a future release to be a configuration).
parserOptionsLinter.ParserOptionsAdditional parser options to apply for the eslint configuration

eslint-plugin-security

When the eslint-plugin-security package is detected in the node_modules this will be automatically injected into the eslint configuration during linting with the plugin:security/recommended rules. (This may change in a future release to be a configuration)

Example showing some option combinations

module.exports = function(grunt) {
  grunt.initConfig({
    "lint": {
        options: {
            format: "codeframe",
            suppressWarnings: false
        },
        "shared": {
            tsconfig: "./shared/tsconfig.json",
            ignoreFailures: true,
            src: [
                // Adds extra source files above those listed in the tsconfig.json
                './shared/src/**/*.ts'
            ]
        },
        "ts_plugin": {
            tsconfig: "./ts-plugin/tsconfig.json",
            ignoreFailures: true
        },
        "eslint_ts": {
            tsconfig: "./eslint-ts-plugin/tsconfig.json",
            ignoreFailures: true
        },
        "shared-fix": {
            // You can specify the options, either in an options object like there or directly in the task
            // definition like those above
            options: {
                tsconfig: "./shared/tsconfig.json",
                fix: true,
                src: [
                    './shared/src/**/*.ts'
                ]                
            }
        },
        "ts_plugin-fix": {
            options: {
                tsconfig: "./ts-plugin/tsconfig.json",
                fix: true
            }
        },
        "eslint_ts-fix": {
            options: {
                tsconfig: "./eslint-ts-plugin/tsconfig.json",
                fix: true,
            }
        }
    }
  });

  grunt.loadNpmTasks("@nevware21/grunt-eslint-ts");
  grunt.registerTask("dolint", [ "lint:shared", "lint:ts_plugin", "lint:eslint_ts" ]);
  grunt.registerTask("lint-fix", [ "lint:shared-fix", "lint:ts_plugin-fix", "lint:eslint_ts-fix" ]);
};

Version 0.1.0 used a taskname of eslint-ts, while 0.2.0 changes the primary taskname to lint but includes an alias task eslint-ts for backward compatibility. Will likely be removed prior to v1.0.0.

Contributing

Read our contributing guide to learn about our development process, how to propose bugfixes and improvements, and how to build and test your changes.

Release History

See The ChangeLog

Keywords

FAQs

Package last updated on 15 Jul 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc