All Projects → srowhani → sass-lint-auto-fix

srowhani / sass-lint-auto-fix

Licence: MIT license
Automatically resolve s(a|c)ss linting issues

Programming Languages

typescript
32286 projects
SCSS
7915 projects
Sass
350 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to sass-lint-auto-fix

BBob
⚡️Blazing-fast js-bbcode-parser, bbcode js, that transforms and parses to AST with plugin support in pure javascript, no dependencies
Stars: ✭ 133 (+43.01%)
Mutual labels:  ast
DupeFix-Project
A mod for Minecraft 1.12.2 that fixes dupes in other mods.
Stars: ✭ 32 (-65.59%)
Mutual labels:  fix
Manhunt-fix-Windows-10
Manhunt fix for Windows 10 Updated for Windows 10 latest versions
Stars: ✭ 24 (-74.19%)
Mutual labels:  fix
TypeScriptAST
.NET port of Microsoft's TypeScript parser for simple AST manipulation
Stars: ✭ 37 (-60.22%)
Mutual labels:  ast
open-fortran-parser-xml
XML output generator for Open Fortran Parser, and Python wrapper for it.
Stars: ✭ 21 (-77.42%)
Mutual labels:  ast
snapdragon-util
Utilities for the snapdragon parser/compiler.
Stars: ✭ 17 (-81.72%)
Mutual labels:  ast
symfony-intl-fix
Provides the symfony/intl fix for new php version in symfony 2.8
Stars: ✭ 20 (-78.49%)
Mutual labels:  fix
MarkdownSyntax
☄️ A Type-safe Markdown parser in Swift.
Stars: ✭ 65 (-30.11%)
Mutual labels:  ast
pyfixmsg
pyfixmsg is a library for parsing, manipulating and serialising FIX messages, primarily geared towards testing.
Stars: ✭ 50 (-46.24%)
Mutual labels:  fix
vscode-ast
Show JavaScript / TypeScript Abstract Syntax Tree
Stars: ✭ 34 (-63.44%)
Mutual labels:  ast
fix4log4j
No description or website provided.
Stars: ✭ 21 (-77.42%)
Mutual labels:  fix
subpy
Python subsets
Stars: ✭ 41 (-55.91%)
Mutual labels:  ast
language-rust
Parser and pretty-printer for the Rust language
Stars: ✭ 78 (-16.13%)
Mutual labels:  ast
deco
Minimalist Function Decorators for Elixir
Stars: ✭ 21 (-77.42%)
Mutual labels:  ast
rector-doctrine
Rector upgrades rules for Doctrine
Stars: ✭ 37 (-60.22%)
Mutual labels:  ast
parser-reflection
Parser Reflection API - Provides source code analysis without loading classes into the PHP memory
Stars: ✭ 97 (+4.3%)
Mutual labels:  ast
lilt
LILT: noun, A characteristic rising and falling of the voice when speaking; a pleasant gentle accent.
Stars: ✭ 18 (-80.65%)
Mutual labels:  ast
sql-parser
Parse SQL (select) statements into abstract syntax tree (AST) and convert ASTs back to SQL.
Stars: ✭ 230 (+147.31%)
Mutual labels:  ast
codeparser
Parse Wolfram Language source code as abstract syntax trees (ASTs) or concrete syntax trees (CSTs)
Stars: ✭ 84 (-9.68%)
Mutual labels:  ast
nast
A block-based intermediate representation for document-like content.
Stars: ✭ 35 (-62.37%)
Mutual labels:  ast

Sass Lint Auto Fix

NPM Version npm Build Status dependencies Status Coverage Status semantic-release

Description

This package serves as a complement to sass-lint, giving you the ability to resolve simple linting issues with an easy to use command line interface. Issues are resolved by parsing the s(a|c)ss as an ast, traversing through it, and modifying certain branches to be in accordance to the .sass-lint.yml standards.

Getting Started

Usage

  Usage: sass-lint-auto-fix "<pattern>" [options]

  Options:

    -V, --version                    output the version number
    -c, --config <path>              custom config path (e.g /path/to/.sass-lint-auto-fix.yml)
    --config-sass-lint <path>        custom sass lint config path (e.g /path/to/.sass-lint.yml
    -s, --silent                     runs in silent mode
    -d, --debug                      runs in debug mode
    -h, --help                       output usage information

Installing as a dependency

To begin install the package as a dev-dependency for your repository.

npm install --save-dev sass-lint-auto-fix

Modify package.json scripts to include lint:fix

{
  ...,
  "scripts": {
    "lint": "sass-lint -v",
    "lint:fix": "sass-lint-auto-fix"
  }
}

lint:fix works really well with husky, which allows you to run commands on hooks that fire when running git commands

Add the following to your package.json

{
  "husky": {
    "hooks": {
      "pre-commit": "yarn lint:fix && yarn lint",
      "pre-push": "yarn test",
      "...": "..."
    }
  }
}

Installing globally

npm install -g sass-lint-auto-fix

Configuration

Configuration can be provided through as either json, yml, or js.

The generic structure of the configuration file you would provide would look something like this:

interface Ruleset {
  [ruleName: string]: number | { [ruleOption: string]: any };
}

interface ConfigOpts {
  logger: Logger;
  slRules?: any;
  slConfig?: any;
  files: {
    include: string;
    ignore?: string;
  };
  syntax: {
    include: (keyof typeof ValidFileType)[];
  };
  resolvers: Ruleset;
  options: {
    optOut: boolean;
  };
}

An example of this in yaml.

files:
  include: "**/*.s+(a|c)ss"
  ignore:
    - node_modules/**
syntax:
    include:
      - scss
      - sass
resolvers:
  property-sort-order: 1
  attribute-quotes: 1
  border-zero: 1
  no-color-keywords: 1
  no-css-comments: 0
  no-important: 0
  no-trailing-zero: 1
  space-after-bang: 1
  space-before-bang: 1
  space-after-colon: 1
  space-before-colon: 1
  hex-length: 1
  empty-line-between-blocks: 1
  url-quotes: 1
  zero-unit: 1
  hex-notation: 1
  indentation: 0
  final-newline: 1
options:
  optOut: false

Disabling Rules

resolvers:
  property-sort-order: 1
  attribute-quotes: 0

By default, all rule "resolvers" are enabled. If you wish to change that, specify a config file when running. Configuration of resolvers only allows you to enable or disable rules.

  sass-lint-auto-fix -c path/to/config.file

Configuring which rules to run against

By default, sass-lint will look for a .sass-lint.yml or .sasslintrc, or an entry in your package.json. When applying the resolver to a given rule, configuration is parsed from one of the above files..

More information is specified here.

In this snippet example, the only rule enabled is property-sort-order. If you wish to manually enable certain resolvers, you would do so for each one you wish to include.

For more information about the rules themselves, you can read the documentation from sass-lint

Opt out of error reporting

By default, all errors captured while attempting to resolve issues are reported by sentry.

You can opt out by adding a optOut flag in your sass-lint-auto-fix config file (yml, json, js, ts)

E.g

files:
  include: "**/*.s+(a|c)ss"
  ignore:
    - node_modules/**
syntax:
    include:
      - scss
resolvers:
  property-sort-order: 1
  attribute-quotes: 1
  ...
options:
  optOut: true

Developing

Setup

git clone https://github.com/srowhani/sass-lint-auto-fix.git;
yarn install;
yarn build;

Contributing

This project uses semantic-release. Scope of the commit's included in a pull request will decide whether a new release is warranted.

More information can be found here.

Testing

yarn test
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].