Giter VIP home page Giter VIP logo

angular-eslint-stylelint-builder's Introduction

Angular ESLint + Stylelint Linter

npm version node workflow node workflow angular versions

An Angular CLI builder inspired by @angular-eslint/builder for linting Angular applications using ESLint and stylelint in one easy step.

Prerequisites

Before using this linter, please ensure that you have already installed and configured eslint and stylelint, for example, by setting up .eslintrc and .stylelintrc files. For more information on converting TSLint to ESLint in Angular projects, please check out the @angular-eslint project.

Install

npm install --save-dev @krema/angular-eslint-stylelint-builder

Usage

Add the builder @krema/angular-eslint-stylelint-builder:lint to the lint task in your angular.json.

angular.json

projects → <my-project> → architect → lint

Replace the builder of @angular-eslint with @krema/angular-eslint-stylelint-builder:

 "lint": {
-    "builder": "@angular-eslint/builder:lint",
+    "builder": "@krema/angular-eslint-stylelint-builder:lint",
     "options": {
-        "lintFilePatterns": ["**/*.ts"]
+        "eslintFilePatterns": ["**/*.ts"],
+        "stylelintFilePatterns": ["**/*.scss"]
     }
 }

Run ng lint:

Configuration

You can configure the following options:

Name Default Value Description Required Linter
Basic configuration:
eslintFilePatterns [] One or more files/dirs/globs to pass directly to ESLint's lintFiles() method. i.e. ["src/**/*.ts"] true eslint
eslintConfig Use this configuration, overriding .eslintrc.*config options if present eslint
stylelintFilePatterns [] One or more files/dirs/globs to pass directly to stylelint's lint() method. ["src/**/*.scss"] true stylelint
stylelintConfig   Path to the stylelint configuration file stylelint
noEslintrc false Disables use of configuration from .eslintrc.* and package.json files. eslint
fix false Automatically fix, where possible, violations reported by rules (may overwrite linted files) eslint, stylelint
Cache-related:
eslintCache false Store the results of processed files so that ESLint only operates on the changed ones eslint
stylelintCache false Store the results of processed files so that stylelint only operates on the changed ones stylelint
eslintCacheLocation .eslintcache Path to the cache file or directory eslint
stylelintCacheLocation .stylelintcache Path to the cache file or directory stylelint
eslintCacheStrategy metadata Strategy to use for detecting changed files in the cache. Can be either metadata or content eslint
File Enumeration:
eslintIgnorePath A path to a file containing patterns describing files to ignore instead of $CWD/.eslintignore eslint
stylelintIgnorePath A path to a file containing patterns describing files to ignore instead of $CWD/.stylelintignore stylelint
eslintRulesDir [] This option allows you to specify another directory from which to load rules files eslint
eslintResolvePluginsRelativeTo Changes the folder where plugins are resolved from eslint
Output:
outputFile File to write report to instead of the console eslint, stylelint
format stylish The output is formatted by using the ESLint Output formatter eslint, stylelint
silent false Hide output text eslint, stylelint
Handling warnings:
quiet false Only register violations for rules with an "error"-level severity (ignore "warning"-level) eslint, stylelint
maxWarnings -1 Number of warnings to trigger nonzero exit code eslint, stylelint
force false Succeeds even if there was linting errors eslint, stylelint

angular-eslint-stylelint-builder's People

Contributors

dependabot[bot] avatar henryruhs avatar krema avatar semantic-release-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

angular-eslint-stylelint-builder's Issues

The automated release is failing 🚨

🚨 The automated release from the main branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you can benefit from your bug fixes and new features again.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can fix this 💪.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the main branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here are some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


Invalid npm token.

The npm token configured in the NPM_TOKEN environment variable must be a valid token allowing to publish to the registry https://registry.npmjs.org/.

If you are using Two Factor Authentication for your account, set its level to "Authorization only" in your account settings. semantic-release cannot publish with the default "
Authorization and writes" level.

Please make sure to set the NPM_TOKEN environment variable in your CI with the exact value of the npm token.


Good luck with your project ✨

Your semantic-release bot 📦🚀

Support for Stylelint 15

Hey, could you provide support for Stylelint 15? The imports are different from my experience.

import stylelint, { LinterResult } from 'stylelint';

const { lint } : typeof stylelint = stylelint;

Not working on Windows10

I have issue running on windows 10, it throws me an error:
An unhandled exception occurred: No files matching the pattern project\src***.scss" were found.

Provide tsConfig in options

It would be nice to have this option, because sometimes you need to provide different configs for linting. In my projects I usualy have to add cypress types to the main tsconfig.json so the lint command is passing. Not ideal...

"options": {
	"tsConfig": "tsconfig.lint.json"
}

Autofix not working

This feature has properly never been implemented but it would be good to support autofix for eslint and stylelint using ng lint --fix. Thanks

Edit: Once the fix option is set inside angular.json the whole linting does not work at all!

Not working with Angular 13

I have to use npm install with --legacy-peer-deps to get this installed as of this (falsy) dependencies. A temporary solution is .npmrc with force=trueso you don't have to adjust your CI pipelines and daily usage.

"dependencies": {
    "@angular-devkit/architect": "^0.1202.11",
    "@angular-devkit/core": "^12.2.11"
  }

This should either have >or you move it to the peerDependencies of the package. The engine property is something that could not work on higher nodejs versions aswell.

Looking for a hotfix release soon as I love to use this package.

Suggestion for default cache locations

I'd like to suggest this default values:

"options: {
	"eslintCacheLocation": "./.angular/cache/.eslintcache",
	"stylelintCacheLocation": "./.angular/cache/.stylelintcache"
}

Would come in handy as most people set .angular to .gitignore already.

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.