jednano / eclint Goto Github PK
View Code? Open in Web Editor NEWValidate or fix code that doesn't adhere to EditorConfig settings or infer settings from existing code.
License: MIT License
Validate or fix code that doesn't adhere to EditorConfig settings or infer settings from existing code.
License: MIT License
For example, block comments in CSS:
/* block
comment */
This fails to pass with these options:
[*.css]
block_comment_start = /*
block_comment_end = */
Another issue with above block is that it fails the indent_size
rule when it is set to 2 or 4, while I think it should be accepted. I'd suggest to disable indent_size
checks inside block comments.
running eclint check **/*.js
against the esformatter repository, with setting:
[lib/**]
indent_style = space
indent_size = 2
it says:
lib/indent.js: line 69: invalid indent size: 5, expected: 2
lib/indent.js: line 70: invalid indent size: 5, expected: 2
lib/indent.js: line 71: invalid indent size: 5, expected: 2
source file: https://github.com/millermedeiros/esformatter/blob/b4dfb14a2ddaca8d1d5bc095f969f20c1114003a/lib/indent.js#L69-L71
// #if _DEBUG
const apiServers = {
rd: 'http://sharechargapi.jmstatic.com/index.php',
pub: 'http://api-pub.ankerjiedian.com/index.php',
prod: 'https://api.ankerjiedian.com/index.php'
};
/* #else
const apiServers = {
prod: 'https://api.ankerjiedian.com/index.php'
};
// #endif */
src/config/index.js
14:01 ❌️ invalid indent size: 0, expected: 3 (EditorConfig indent_size http://t.cn/Ro8MlrH)
15:01 ❌️ invalid indent size: 2, expected: 3 (EditorConfig indent_size http://t.cn/Ro8MlrH)
16:01 ❌️ invalid indent size: 0, expected: 3 (EditorConfig indent_size http://t.cn/Ro8MlrH)
17:01 ❌️ invalid indent size: 0, expected: 3 (EditorConfig indent_size http://t.cn/Ro8MlrH)
24:01 ❌️ invalid indent size: 0, expected: 3 (EditorConfig indent_size http://t.cn/Ro8MlrH)
25:01 ❌️ invalid indent size: 0, expected: 3 (EditorConfig indent_size http://t.cn/Ro8MlrH)
42:01 ❌️ invalid indent size: 2, expected: 5 (EditorConfig indent_size http://t.cn/Ro8MlrH)
43:01 ❌️ invalid indent size: 2, expected: 5 (EditorConfig indent_size http://t.cn/Ro8MlrH)
Hi, I think eclint is good tool and useful to me 🎉 . Thank you for developing this tool.
Now, I tried to execute following steps and got error, So I just report it in this issue.
in macOS sierra
, and os lang is ja_JP
$ npm install -g eclint
$ cd path/to/project
$ eclint ( or eclint --help or eclint --version )
After executed above steps, empty jp_JP.json is generated.
/usr/local/lib/node_modules/eclint/locales/:[]: ls
result
en.json ja_JP.json zh_CN.json zh_TW.json
and that is empty file.
$ wc ja_JP.json
0 0 0 ja_JP.json
After executed this steps, any commands dump parse errors.
$ eclint
/usr/local/lib/node_modules/eclint/node_modules/y18n/index.js:79
else throw err
^
SyntaxError: syntax error in /usr/local/lib/node_modules/eclint/locales/ja_JP.json
at JSON.parse (<anonymous>)
at Y18N._readLocaleFile (/usr/local/lib/node_modules/eclint/node_modules/y18n/index.js:72:25)
at Y18N.__ (/usr/local/lib/node_modules/eclint/node_modules/y18n/index.js:26:38)
at Object.<anonymous> (/usr/local/lib/node_modules/eclint/dist/cli.js:187:12)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/usr/local/lib/node_modules/eclint/bin/eclint.js:3:11)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
If execute eclint check
command in first, jp_JP.json file is generated that include en
contents.
$ cat ja_JP.json
{
"Usage: $0 <command> [files...] [options]": "Usage: $0 <command> [files...] [options]",
"Validate that file(s) adhere to .editorconfig settings": "Validate that file(s) adhere to .editorconfig settings",
"Fix formatting errors that disobey .editorconfig settings": "Fix formatting errors that disobey .editorconfig settings",
"Infer .editorconfig settings from one or more files": "Infer .editorconfig settings from one or more files",
"CommandError: Missing required sub-command.": "CommandError: Missing required sub-command.",
"Indentation Style": "Indentation Style",
"Indentation Size (in single-spaced characters)": "Indentation Size (in single-spaced characters)",
"Width of a single tabstop character": "Width of a single tabstop character",
"Line ending file format (Unix, DOS, Mac)": "Line ending file format (Unix, DOS, Mac)",
"File character encoding": "File character encoding",
"Denotes whether whitespace is allowed at the end of lines": "Denotes whether whitespace is allowed at the end of lines",
"Denotes whether file should end with a newline": "Denotes whether file should end with a newline",
"Forces hard line wrapping after the amount of characters specified": "Forces hard line wrapping after the amount of characters specified",
"Block comments start with": "Block comments start with",
"Lines in block comment start with": "Lines in block comment start with",
"Block comments end with": "Block comments end with"
}
After executed eclint check
command in first, Any commands are normally work.
Thanks. 😄
If any errors are reported, the Node process will exit with a status code of 1…
This doesn’t work when multiple files are globbed and errors are reported only in some of these files.
$ eclint check '**/*'; echo $?
test-me.adoc: line 2: trailing whitespace found
0
$ node --version
v0.12.7
While running sudo npm install -g
npm ERR! Error: ENOENT, chmod '/usr/local/lib/node_modules/eclint/eclint.js'
npm ERR! If you need help, you may report this log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <[email protected]>
npm ERR! System Linux 3.8.0-30-generic
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "-g" "install" "."
npm ERR! cwd /home/trey/repos/node/eclint
npm ERR! node -v v0.10.17
npm ERR! npm -v 1.3.8
npm ERR! path /usr/local/lib/node_modules/eclint/eclint.js
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/trey/repos/node/eclint/npm-debug.log
npm ERR! not ok code 0
Is this expected behavior?
# .editorconfig
insert_final_newline = true
$ touch empty.md
## Expected
$ eclint check empty.md
(no warning)
# exit code = 0
## Actual
$ eclint check empty.md
empty.md: expected final newline
# exit code = 1
My environments:
eclint v0.2.6
node.js v0.12.7
OS X 10.9.5
The error is as follows :
/opt/pclm/lib/ui/node_modules/vinyl-fs/lib/src/index.js:32
throw new Error('Invalid glob argument: ' + glob);
^
Error: Invalid glob argument:
at Object.src (/opt/pclm/lib/ui/node_modules/vinyl-fs/lib/src/index.js:32:11)
at Command._action (/opt/pclm/lib/ui/node_modules/eclint/dist/cli.js:79:22)
at Command.parse (/opt/pclm/lib/ui/node_modules/gitlike-cli/lib/Command.js:284:18)
at Command.tryParseSubcommand (/opt/pclm/lib/ui/node_modules/gitlike-cli/lib/Command.js:318:17)
at Command.parse (/opt/pclm/lib/ui/node_modules/gitlike-cli/lib/Command.js:269:22)
at Object.<anonymous> (/opt/pclm/lib/ui/node_modules/eclint/bin/eclint.js:4:5)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:427:7)
at startup (bootstrap_node.js:151:9)
at bootstrap_node.js:542:3
My pre-commit hook is just :
#!/bin/bash
./node_modules/.bin/eclint check
It works well if I run this in a normal console.
After searching a bit, I found out that the problem comes from args.files not being empty :
check.action(function (args, options) {
console.log(args.files);
}
If I do that, I get "undefined" if I run it from a shell, but I get a big result when I run it from my pre-commit hook :
[ Socket {
connecting: false,
_hadError: false,
_handle:
Pipe {
bytesRead: 0,
_externalStream: [External],
fd: 0,
writeQueueSize: 0,
owner: [Circular],
onread: [Function: onread],
reading: false },
_parent: null,
_host: null,
_readableState:
ReadableState {
objectMode: false,
highWaterMark: 16384,
buffer: [Object],
length: 0,
pipes: null,
pipesCount: 0,
flowing: null,
ended: false,
endEmitted: false,
reading: false,
sync: false,
needReadable: true,
emittedReadable: false,
readableListening: false,
resumeScheduled: false,
destroyed: false,
defaultEncoding: 'utf8',
awaitDrain: 0,
readingMore: false,
decoder: null,
encoding: null },
readable: true,
domain: null,
_events:
{ end: [Object],
finish: [Function: onSocketFinish],
_socketEnd: [Function: onSocketEnd],
pause: [Function] },
_eventsCount: 4,
_maxListeners: undefined,
_writableState:
WritableState {
objectMode: false,
highWaterMark: 16384,
finalCalled: false,
needDrain: false,
ending: false,
ended: true,
finished: false,
destroyed: false,
decodeStrings: false,
defaultEncoding: 'utf8',
length: 0,
writing: false,
corked: 0,
sync: true,
bufferProcessing: false,
onwrite: [Function: bound onwrite],
writecb: null,
writelen: 0,
bufferedRequest: null,
lastBufferedRequest: null,
pendingcb: 0,
prefinished: false,
errorEmitted: false,
bufferedRequestCount: 0,
corkedRequestsFree: [Object] },
writable: false,
allowHalfOpen: false,
_bytesDispatched: 0,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: null,
_server: null,
fd: 0,
[Symbol(asyncId)]: 11,
[Symbol(bytesRead)]: 0 } ]
I don't have a clue what "Sockets" have to do with that, but I think it is very likely a bug either in eclint or in git-like-cli.
insert_final_newline=false
all empty final lines are removed that is the expected behaviour.insert_final_newline=true
a new empty line is added if it does not exist previously that is the expected behaviour.What happens when more than one empty line exists and the end of the file and insert_final_newline=true
is not well documented, and different users can have different expectations, but I think that most of the tools (i checked atom and emacs EditorConfig plugins) remove the extra lines. But eclint keeps the empty lines when there is more than one.
I think that it will be great if this tool removes the extra lines
BTW. This is a great tool.
building eclint stops with error
[16:39:21] Starting 'scripts'...
node_modules/linez/linez.d.ts(2,25): error TS2307: Cannot find module 'd.ts/linez'.
steps before:
git clone ...
cd eclint
npm install
I'm doing anything wrong or forget something?
FYI: I'll need to locally modify eclint to handle block-comments correctly for me ... (these with leading space in front of "*" at 2nd line):
/**
* description
*/
give error on check with settings
indent_style = tab
tab_width = 4
in .editorconfig
many thanks in advance
It'd be neat if one could pass a directory and files inside would get enumerated. For example
├── dir
│ ├── file1.txt
│ ├── file2.txt
eclint check dir
should check both files. Currently it does nothing in this case.
In javascript (and many others), this is a common way to declare some documentation for a certain piece of code:
/**
* Comment
*/
This exemple uses one space indentation, so if you set into your .editorconfig
indent_size = 2
and then you run eclint check on that exemple, it will give you this error:
invalid indent size: 1, expected: 2
I think it should be a way to ignore comments
Should I use the official eclint, or the fork https://github.com/slang800/editorconfig-tools ?
charset | signature | behavior |
---|---|---|
latin1 | none | errors if utf-8 chars found |
utf-8 | none | inferred default, can have bytes in 80-FF range |
utf-8-bom | \u00EF\u00BB\u00BF | |
utf-16be | \u00FE\u00FF | |
utf-16le | \u00FF\u00FE | same start as utf-32le |
utf-32be | \u0000\u0000\u00FE\u00FF | |
utf-32le | \u00FF\u00FE\u0000\u0000 | must check before utf-16le |
clang_complete is an auto completion tool for C projects. It uses .clang_complete
file as its configuration file. If one specifies:
c_complete_flags = -I auto -D something
Do you think it's a good idea to generate a .clang_complete
file at the root?
Hello
I cannot get eclint working.
These steps I used to install eclint:
$ ./install.sh
$ grunt build
Check command error:
$ ./bin/eclint.js check some-project/**/*
/Users/sergey/Projects/eclint/lib/commands/check.js:44
rule.check(reporter, setting, data);
^
TypeError: Object function EndOfLineRule() {
} has no method 'check'
at /Users/sergey/Projects/eclint/lib/commands/check.js:44:22
at fs.js:266:14
at Object.oncomplete (fs.js:107:15)
Infer and fix returns nothing:
$ ./bin/eclint.js infer some-project/*
$ ./bin/eclint.js fix some-project/**/*
I'm finding your application very useful. Could you help to find the working revision or fix current errors?
UPDATE
Sorry, it seems that fix command is working. But stilI there are some issues. I have been testing .editorsconfig's indent_style property on the generator-marionette source. It cannot be changed in json files, files that starts with /*jshint latedef:false */
, test/tests.js file and 'use strict'
lines.
PRs #32 and #33 only modify the source.
I did not notice that the project has build artifacts in the repository.
Please consider #33 and then rebuild to ensure that the JavaScript version is updated.
Consider not keeping build artifacts in the repository. Although not universally accepted, I'd say it's a generally accepted practice.
Sorry for the inconvenience.
echo test > test
eclint fix -c utf-8-bom test
eclint check -c utf-8-bom test
output:
test: expected charset: utf-8-bom
It seems eclint fix
add bom successfully, but eclint check
fail to recognize it... 😨
In light of your recent comment and resistance to add features, perhaps you would consider mentioning an alternative package in your descriptions so people could find them easier if they choose to?
I have chosen to move on to lintspaces, which seems to be pretty popular, supports .editorconfig
files and ignore option I needed.
That’s not to say your package was not awesome, thanks for it!
What is the correct setting to allow C-style block comments with documentation?
/**
* ...
*/
eclint check with indent_size = 4 gives me many errors such as "invalid indent size: 5, expected: 4" on lines with one space more inside comments.
Hi!
I saw that you think this tool doesn't suposse to fix indent spaces, but that's all why I downloaded it in the first place. I also try editorconfig-tools but it does not support wildcards out the box (I'm on Windows).
editorconfig-tools says that I can fix the indent spaces. Why this cannot? The .editorcofig file it's all about common configuration. Even if there is something wrong with the fix, there is nothing you can do, they just got the configuration wrong themselfs. I think that at least.
Thanks you!
$ eclint check $(git ls-files)
Unhandled rejection TypeError: Object # h has no method 'equals'
at detectCharset (/home/travis/.nvm/v0.10.36/lib/node_modules/eclint/node_modules/linez/js/linez.js:35:41)
at linez (/home/travis/.nvm/v0.10.36/lib/node_modules/eclint/node_modules/linez/js/linez.js:19:19)
at /home/travis/.nvm/v0.10.36/lib/node_modules/eclint/js/eclint.js:69:27
at tryCatcher (/home/travis/.nvm/v0.10.36/lib/node_modules/eclint/node_modules/editorconfig/node_modules/bluebird/js/main/util.js:26:23)
at Promise._settlePromiseFromHandler (/home/travis/.nvm/v0.10.36/lib/node_modules/eclint/node_modules/editorconfig/node_modules/bluebird/js/main/promise.js:503:31)
at Promise._settlePromiseAt (/home/travis/.nvm/v0.10.36/lib/node_modules/eclint/node_modules/editorconfig/node_modules/bluebird/js/main/promise.js:577:18)
at Async._drainQueue (/home/travis/.nvm/v0.10.36/lib/node_modules/eclint/node_modules/editorconfig/node_modules/bluebird/js/main/async.js:128:12)
at Async._drainQueues (/home/travis/.nvm/v0.10.36/lib/node_modules/eclint/node_modules/editorconfig/node_modules/bluebird/js/main/async.js:133:10)
at Async.drainQueues (/home/travis/.nvm/v0.10.36/lib/node_modules/eclint/node_modules/editorconfig/node_modules/bluebird/js/main/async.js:15:14)
at process._tickCallback (node.js:442:13)
I'm applying eclint to this file here: https://github.com/eisber/vowpal_wabbit/blob/master/vowpalwabbit/gd.cc.
'check' showed some issues and 'fix' fixed some of them. Running 'check' again still shows there are more issues, but now 'fix' doesn't do anything to the file. Any ideas? The editorconfig file being used is here: https://github.com/eisber/vowpal_wabbit/blob/master/.editorconfig
I'm on Ubuntu 14.04, npm 1.4.28, node v0.10.40, installed eclint by 'sudo npm install -g eclint'
https://github.com/treyhunner/editorconfig-tools ... in case you wanna borrow code or work together or something
If I were to run
$ eclint check *
eclint runs on all binary files, but these should be ignored, perhaps using is-binary-path
as a blacklist or is-text-path
as a whitelist
Please support files that just have extensions
> eclint fix **/*
events.js:160
throw er; // Unhandled 'error' event
^
Error: EPERM: operation not permitted, open 'MyApplication\.vs\MyApplication\v14\.suo'
at Error (native)
i would like to do eclint fix .
and use a .eclintignore
to ignore node modules, etc. this is similar to how i use eslint.
It looks like newlines are meant to be trimmed when fixing, but nothing seems to happen.
I have a Django Project with all sort of files, and I want to check all my files especially for end_of_line
.
If i run eclint check **/*.html
so it find all my html files in all paths (no matter how depth it is), but I can't figure out how to check all files, without have to specify the extension.
For example:
eclint check *
it only checks my root foldereclint check **/*
it only checks the files on "root" of each child-folder BUT NOT on project folder.eclint check **/**/*
it only checks the files on "root" of each child-child-folder BUT NOT on project folder nor on child-folder. (and so on)Run things like eclint check **/*.*
have same results as above.
What am I doing wrong?
.editorconfig
# http://editorconfig.org
root = true
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
trim_trailing_whitespace = true
[*.py]
indent_style = space
indent_size = 4
[*.{html,js}]
indent_style = tab
[*.{yml,scss}]
indent_style = space
indent_size = 2
$ eclint -v
1.1.5
$ npm -v
3.8.7
$ node -v
v5.11.0
As a Node.js newbie, I want eclint published on NPM, so that it's easy to install with npm [-g] eclint
.
@jedmao notes that eclint lacks support for checking soft tab (spaces) indentation width against configuration. Is this true?
It seems there's an error when trying to get BOM.
As far as I can see, this might be a problem in linez module, or the way it's implemented here.
I've got a js file that starts with jQuery.extend({
and another php file starting with <?php
This is the output I get:
$ ./node_modules/.bin/eclint fix file.js
Unhandled rejection TypeError: Object jQu has no method 'equals'
$ ./node_modules/.bin/eclint file.php
Unhandled rejection TypeError: Object <?p has no method 'equals'
Here's the backtrace for both:
at detectCharset (/node_modules/eclint/node_modules/linez/js/linez.js:35:41)
at linez (/node_modules/eclint/node_modules/linez/js/linez.js:19:19)
at /node_modules/eclint/js/eclint.js:114:27
at tryCatcher (/node_modules/eclint/node_modules/editorconfig/node_modules/bluebird/js/main/util.js:24:31)
at Promise._settlePromiseFromHandler (/node_modules/eclint/node_modules/editorconfig/node_modules/bluebird/js/main/promise.js:454:31)
at Promise._settlePromiseAt (/node_modules/eclint/node_modules/editorconfig/node_modules/bluebird/js/main/promise.js:530:18)
at Async._drainQueue (/node_modules/eclint/node_modules/editorconfig/node_modules/bluebird/js/main/async.js:182:12)
at Async._drainQueues (/node_modules/eclint/node_modules/editorconfig/node_modules/bluebird/js/main/async.js:187:10)
at Async.drainQueues (/node_modules/eclint/node_modules/editorconfig/node_modules/bluebird/js/main/async.js:15:14)
at process._tickCallback (node.js:415:13)
When installing the new release (v2) the command isn't available in node_modules/.bin
. Version 1.1.5 worked fine for me. It seems that the new release isn't linking the cli command to .bin
?
See here for the failing build: https://travis-ci.org/ismay/ismaywolff.nl/builds/213686565#L467
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.