npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

editorconfig-tools

v0.1.1

Published

Tools for verifying/fixing code style based on an EditorConfig file

Downloads

29,354

Readme

editorconfig-tools

Build Status NPM version NPM license

This tool-set is for validating or fixing code that doesn't adhere to settings defined in .editorconfig. It also is able to infer settings from existing code and generate an .editorconfig file that matches all the files that are passed to it. See the EditorConfig Project for details about the .editorconfig file.

CLI

The CLI is (currently) the only way of using editorconfig-tools. The following sections detail the 3 subcommands that editorconfig-tools provides.

infer

Infer .editorconfig settings from one or more files and generate an .editorconfig file that matches all the files that are passed to it.

Here's an example using the files from this project. It is assumed that you have globstar enabled in your shell. While editorconfig-tools itself doesn't require it, these examples do use it to pass whole directories of files to editorconfig-tools.

$ editorconfig-tools infer ./* ./lib/**/* ./test/**/*
[*]
end_of_line = lf
indent_style = space
indent_size = 2
insert_final_newline = true
max_line_length = 80
trim_trailing_whitespace = true

[{./test/fixtures/end-of-line/file}]
end_of_line = crlf

[{./Makefile,./test/fixtures/indent-char-tab/file}]
indent_style: tab

[{./test/fixtures/insert-final-newline-false/file}]
insert_final_newline = false

As you can see, a set of rules has been generated that matches all of the files that we passed in. If we were making an .editorconfig file for a project that doesn't already have one, we might want to write this out to a file:

$ editorconfig-tools infer ./* ./lib/**/* ./test/**/* > .editorconfig

We would still probably want to add root = true to the file (if this is saved at the root of the project), but editorconfig-tools has done most of the work required to make an .editorconfig file.

check

Check (validate) that file(s) adhere to .editorconfig settings and return a non-zero exit code if errors are encountered (making it suitable for running as a test). For example, if we added some trailing whitespace to our readme, this would be the result:

$ editorconfig-tools check README.md
README.md failed trim_trailing_whitespace on line 46: found setting 'false', should be 'true'

fix

Fix formatting errors that disobey .editorconfig settings. This will modify your files without warning, so you should ensure that your project is under version control before running it.

For example, if we write a file with 4-space indentation, and then run the fix command (using the settings of this particular project) we will get back a 2-space indented file:

$ echo -e 'line one\n    line two' > example-file
$ editorconfig-tools fix ./example-file
$ cat example-file
line one
  line two

Similar Tools