Giter VIP home page Giter VIP logo

grunt-plugins's Introduction

@Nevware21 GruntJS Plugins

This Monorepo is aimed at providing additional GruntTS support tasks for TypeScript

GitHub Workflow Status (main)

Current Plugins

Plugin Description Version
grunt-ts-plugin Grunt-ts-plugin is an npm package that provides a TypeScript compilation task for GruntJS build scripts. Changelog
npm version
downloads
grunt-eslint-ts Grunt-eslint-ts provides a wrapper for running eslint using the @typescript-eslint parser for processing TypeScript files. Changelog
npm version
downloads

Note: These plugins have currently only been tested with the Grunt 1.4.0.

Quickstart

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

Required packages

Package Descriptpion
TypeScript npm install typescript --save-dev - if you don't have TypeScript installed in your project, run
GruntJS npm install grunt --save-dev - if you don't have GruntJS installed in your project
Grunt-Cli npm 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:

module.exports = function(grunt) {
  grunt.initConfig({
    ts: {
      options : {
        debug: false
      },
      default: {
        tsconfig: './default/tsconfig.json'
      },
      task1: {
        // Just use the tsconfig
        tsconfig: './task1/tsconfig.json'
      },
      task2: {
        // Use the tsconfig and add the additional src files, you *could* call a function to return
        // a dynamic array with the src files. The task doesn't call the function it expects a string[].
        tsconfig: './task1/tsconfig.json',
        src: [
          './src/**/*.ts'
        ]
      },
      task3: {
        // As with task2, but also concatenate the output into a single file, this is the same as defining
        // the out or outFile paramater in the compileOptions within the tsconfig.json.
        // If you have both outDir in the tsConfig.json and this parameter -- this value will be ignored.
        tsconfig: './task1/tsconfig.json',
        src: [
          './src/**/*.ts'
        ],
        out: './out/task1-dist.js'
      }
    }
  });
  grunt.loadNpmTasks("@nevware21/grunt-ts-plugin");
  grunt.registerTask("default", ["ts"]);
  grunt.registerTask("task1", ["ts:task1"]);
  grunt.registerTask("task2", ["ts:task2"]);
  grunt.registerTask("task3", ["ts:task3"]);
};

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

Package Descriptpion
ESLint npm install eslint --save-dev - if you don't have ESLint installed in your project, run
@typescript-eslint/eslint-plugin npm install @typescript-eslint/eslint-plugin --save-dev - if you don't have the @typescript plugin installed
@typescript-eslint/parser npm 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
TypeScript npm install typescript --save-dev - if you don't have TypeScript installed in your project, run
GruntJS npm install grunt --save-dev - if you don't have GruntJS installed in your project
Grunt-Cli npm 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:

module.exports = function(grunt) {
  grunt.initConfig({
    "eslint-ts": {
        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("lint", [ "eslint-ts:shared", "eslint-ts:ts_plugin", "eslint-ts:eslint_ts" ]);
  grunt.registerTask("lint-fix", [ "eslint-ts:shared-fix", "eslint-ts:ts_plugin-fix", "eslint-ts:eslint_ts-fix" ]);
};

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.

grunt-plugins's People

Contributors

dependabot[bot] avatar msnev avatar nev21 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

grunt-plugins's Issues

[BUG] tsplugin does not fail when both type and external type errors are detected

>> 6 non-emit-preventing type warnings  9 external non-emit-preventing type warnings  >> Type only errors detected -- If you want to not fail the build on these type of errors set the 'failOnTypeErrors' option to false (defaults to true)
>> External Type errors identified.

We have a build where both external (node_modules) and internal type failures are occurring, however, the build does not fail because the isSuccess is defaulting to true from the presence of the externally detected errors.

TypeScript.ts L232

isSuccess: !chkResponse.isError || (chkResponse.isOnlyTypeErrors && !options.failOnTypeErrors) || (chkResponse.isExternalTypeErrors && !options.failOnExternalTypeErrors),

[Feature] Add support to inline the tsconfig.json within the grunt config

Allow the tsconfig.json to be inlined into the grunt config file rather than just a reference to a pre-existing file.

Support extending the tsconfig setting so that rather than just a string it can be an object which is written as the tsconfig.json during compilation. Would also be nice to allow dynamic updates.

May also need an option to specify the path where this file will be located to support mono-repo's as the location often can form the source / out and outDir root paths.

And include the option to generate multiple tsconfig instances so that multiple sets can be generated, fo creating multiple outputs with different compiler options, target, entrypoints (files).

[BUG] v0.2.1 - rootDir and temp tsconfig are not being calculated correctly

It looks like the common path calculation for the included files from grunt is being too aggressive in normalizing them.

Grunt ts definition

            aiskutests: {
                tsconfig: './AISKU/Tests/tsconfig.json',
                src: [
                    'AISKU/Tests/Selenium/*.ts',
                    'AISKU/Tests/*.ts'
                ],
                out: 'AISKU/Tests/Selenium/appinsights-sdk.tests.js'
            },

Source tsconfig.json

{
    "compilerOptions": {
        "sourceMap": true,
        "inlineSources": true,
        "noImplicitAny": false,
        "module": "amd",
        "moduleResolution": "Node",
        "target": "es5",
        "alwaysStrict": true,
        "declaration": true,
        "out": "Tests/Selenium/appinsights-sdk.tests.js"
    },
    "include": [
        "Tests/Selenium/*.ts",
        "Tests/*.ts"
    ],
    "exclude": [
        "node_modules/"
    ]
}

Resulting temporary tsconfig.json with the complete logged debug details

Running "ts:aiskutests" (ts) task
Using tsc version: 2.5.3
Temp TsConfig.json [AISKU\Tests\tsconfig.json-45f0d4ef.tmp]:
{
    "compilerOptions": {
        "sourceMap": true,
        "inlineSources": true,
        "noImplicitAny": false,
        "module": "amd",
        "moduleResolution": "Node",
        "target": "es5",
        "alwaysStrict": true,
        "declaration": true,
        "out": "Tests/Selenium/appinsights-sdk.tests.js"
    },
    "include": [
        "Tests/Selenium/*.ts",
        "Tests/*.ts",
        "./Selenium/*.ts",
        "./*.ts"
    ],
    "exclude": [
        "node_modules/"
    ]
}
Ts-Plugin Invoking: D:\MSNev1\ApplicationInsights-JS\node_modules\typescript\bin\tsc @tscommand-2dfdfbbe.tmp
 Contents...
    --project AISKU\Tests\tsconfig.json-45f0d4ef.tmp

Recommend Projects

  • React photo React

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

  • Vue.js photo Vue.js

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

  • Typescript photo Typescript

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

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

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

  • web

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

  • server

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

  • Machine learning

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

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

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

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.