standard / semistandard Goto Github PK
View Code? Open in Web Editor NEW:icecream: All the goodness of `standard/standard` with semicolons sprinkled on top.
License: MIT License
:icecream: All the goodness of `standard/standard` with semicolons sprinkled on top.
License: MIT License
If standard
is already installed in a package, npm's deduping will not install it to the expected location for the postinstall
script.
That's a pretty janky implementation strategy - perhaps we should switch to a proper fork instead.
node-osa> npm install semistandard --save-dev
> [email protected] postinstall /Users/brandonhorst/projects/node-osa/node_modules/semistandard
> node postinstall.js
fs.js:691
return binding.lstat(pathModule._makeLong(path));
^
Error: ENOENT, no such file or directory '/Users/brandonhorst/projects/node-osa/node_modules/semistandard/node_modules/standard/rc/.eslintrc'
at Object.fs.lstatSync (fs.js:691:18)
at replacizeFileSync (/Users/brandonhorst/projects/node-osa/node_modules/semistandard/node_modules/replace/replace.js:121:22)
at module.exports (/Users/brandonhorst/projects/node-osa/node_modules/semistandard/node_modules/replace/replace.js:64:13)
at Object.<anonymous> (/Users/brandonhorst/projects/node-osa/node_modules/semistandard/postinstall.js:4:1)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
should read betterstandard ;)
semistandard
used to work fine for me, but I recently switched to a new machine with updated npm
, and whenever I try to use it, I keep getting dependency errors.
This is an example error:
semistandard: Unexpected linter output:
Error: Failed to load plugin react: Cannot find module 'eslint-plugin-react'
If I install all the dependencies
of semistandard
as devDependencies
for my project, I simply get new error related to other internal dependencies.
I tried with downgraded npm
, reinstalled npm
, and other methods but nothing works.
npm -v
-> 5.2.0
node -v
-> v6.11.3
Maybe this is not a valid problem, but I tried running "semistandard" with my Web Component and it doesn't pass because HTMLElement isn't defined. Is this something semistandard is doing or it's because my version of Node doesn't support webcomponents?
semistandard
name looks like it's a sub-step of standard
, so I suggest renaming this project and properly documenting it not just as a copy/paste of standard
. I can help a with the documentation. As the name for the library I propose:
default
PS, this is exactly what I was looking for. I love everything from standard except for the no semicolons rule, which seems idiotic to have to write this:
foo()
;[1,2,3].forEach(bar)
standard.ignore
property inside package.json
file. I have tried doing that, but semistandard does not ignore the files.It doesn't mean this style checker is any less “standard” just because someone grabbed a fancier name first.
Checking for standard
in npm scripts doesn't mean checking for someone else's standard, it means checking for the standard style for the project you're working on.
"url": "http://twitter.com/flettre"
},
"bin": {
- "semistandard": "./bin/cmd.js"
+ "standard": "./bin/cmd.js"
},
"bugs": {
"url": "https://github.com/Flet/semistandard/issues"
With version 10.0.0 if I wanted to exclude global variables like "angular" or "$" I had to put this in package.json:
"semistandard": { "globals": ["angular","$"] },
But after the 12.0.0 update I keep getting "[semistandard] angular (or $) is not defined.. (no-undef)" instead of excluding "angular" and "$" global variables. Is it a bug?
This fix looks awesome.
Fixing up old javascripts by hand sucks.
I found #111 but still not clear or getting 'it' working.
invoking with:
$ ./node_modules/.bin/semistandard --verbose | ./node_modules/.bin/snazzy
and in the directory where that command is invoked, I tried having both an .eslintrc
and a eslintrc.json
with this config:
{
"extends": "standard",
"rules": {
"camelcase": "off"
}
}
But camel case is still an error. How to proceed? Thank you
npm install semistandard -g
With --fix
added in now, should we remove the --format
option and instead rely on --fix
?
standard
has already done the same thing. The benefit here would be a lot less dependencies to install, resulting in faster installs for folks who include semistandard
in their devDependencies.
$ cat a.js
#!/usr/bin/env node
'use strict';
$ semistandard a.js
semistandard: Semicolons For All! (https://github.com/Flet/semistandard)
~/a.js:1:1: Expected space or tab after "//" in comment.
semistandard is throwing an error on the following code, claiming that super
is never called. It doesn't appear to be accounting for super.apply
.
class Child extends Base {
constructor() {
super.apply(null, arguments);
}
};
Unfortunately Node@4 doesn't support the spread operator or I would have just used that.
My guess is semistandard
only differs from "standard" in regard of semicolon issues; therefore, can it be reflected in semistandard
's version number that which upstream version it corresponds to? For example esprima-fb is using some weird-looking yet effective version scheme to indicate its relationship with the upsteam.
Tried adding this line to .vimrc
let g:syntastic_javascript_checkers = ['semistandard']
But it doesn't report errors on saving a .js file in Vim. Am I missing something here?
P.S. semistandard
is installed globally
Hello,
I'm opening this issue as a question regarding configuration for WebStorm and other JetBrains IDEs.
I find very clear how to set standardjs with different editors or IDEs, but in semistandard I don't see a section with information regarding JetBrains. Is the basically the same as standardjs (natively supported) or do we have to do some tweaks?
Thank you!
I try to run semistandard and I hit this error:
semistandard: Unexpected linter output:
TypeError: Cannot read property 'type' of undefined
at markPropTypesAsDeclared (/usr/local/lib/node_modules/semistandard/node_modules/eslint-plugin-react/lib/rules/prop-types.js:449:27)
at /usr/local/lib/node_modules/semistandard/node_modules/eslint-plugin-react/lib/rules/prop-types.js:571:9
at Array.forEach (native)
at EventEmitter.ObjectExpression (/usr/local/lib/node_modules/semistandard/node_modules/eslint-plugin-react/lib/rules/prop-types.js:567:23)
at EventEmitter.emit (events.js:129:20)
at Controller.controller.traverse.enter (/usr/local/lib/node_modules/semistandard/node_modules/standard-engine/node_modules/eslint/lib/eslint.js:724:25)
at Controller.__execute (/usr/local/lib/node_modules/semistandard/node_modules/standard-engine/node_modules/eslint/node_modules/estraverse/estraverse.js:397:31)
at Controller.traverse (/usr/local/lib/node_modules/semistandard/node_modules/standard-engine/node_modules/eslint/node_modules/estraverse/estraverse.js:495:28)
at EventEmitter.module.exports.api.verify (/usr/local/lib/node_modules/semistandard/node_modules/standard-engine/node_modules/eslint/lib/eslint.js:717:24)
at processText (/usr/local/lib/node_modules/semistandard/node_modules/standard-engine/node_modules/eslint/lib/cli-engine.js:201:27)
It's odd because it works fine on another machine of mine. Any insight on what exactly is going on here?
Running a fresh install of 8.0.0 on the following:
const Foo = 123
Foo + 454
Getting the following output:
$ semistandard --version && semistandard
8.0.0
semistandard: Semicolons For All! (https://github.com/Flet/semistandard)
/Users/me/dev/test/test.js:1:16: Missing semicolon.
/Users/me/dev/test/test.js:2:10: Missing semicolon.
Should I put a eslintrc.json in my project?
https://github.com/Flet/semistandard/blob/master/eslintrc.json
user@host:~/src/test$ semistandard --version
9.1.0
user@host:~/src/test$ cat bug.js
var promise = new Promise();
promise = promise.then(() => { });
promise = promise.then(() => { });
user@host:~/src/test$ semistandard
semistandard: Semicolons For All! (https://github.com/Flet/semistandard)
/home/user/src/test/bug.js:1:5: 'promise' is defined but never used.
user@host:~/src/test$
promise
is, however, used repeatedly !
Either I'm missing something obvious or this is a bug ...
Adding RegExp with named group produces this error:
error Parsing error: Invalid regular expression: /(?<main>.*\s+)(?<remain>[^\s]+)/: Invalid group null
Here is the corresponding code:
const textMatch = text.match(/(?<main>.*\s+)(?<remain>[^\s]+)/);
On SemiStandard Version: 12.0.1
On Node Version: v10.9.0
I'm the standard-formatter for Atom (Atom/GitHub) in semi-standard mode, and it is removing semicolons in my commented lines when I actiavte the plugin. I voiced my concern in an issue in that repo, and was redirected here, so will you take a look at what I'm describing?
eslint seems to have configuration cascade feature.
http://eslint.org/docs/user-guide/configuring#configuration-cascading-and-hierarchy
It works like:
The configuration cascade works by using the closest .eslintrc file to the file being linted as the highest priority, then any configuration files in the parent directory, and so on. When you run ESLint on this project, all files in lib/ will use the .eslintrc file at the root of the project as their configuration. When ESLint traverses into the tests/ directory, it will then use your-project/tests/.eslintrc in addition to your-project/.eslintrc
I'm curious whether semistandard has this (or similar) feature. In our use case, we want to apply env: ['mocha']
option to only test/
directory and env: ['browser']
option to only browser/
(browser specific directory) etc.
Getting
Parsing error: Cannot read property 'ecmaFeatures' of undefined
Tell us about your environment
ESLint Version: 5.1.0
Node Version: 10.6.0
**npm Version:**6.1.0"
my eslintrc
env:
node: true
es6: true
jquery: false
browser: false
extends:
rules:
curly: off
This is kind of a strange issue because I can't see anything obvious that changed in the v13.0.0 release but all our Greenkeeper update PRs are failing in Travis CI on Node 6 on the semistandard --fix
command with:
> semistandard --fix
/usr/bin/env: node: No such file or directory
let oldObject = {
someString: 'hello world',
someObj: {
booleanValue: false,
someInteger: 5
}
};
let newObject = { ...oldObject.someObj, someProperty: true };
this throws an error in Atom,
Error: Unexpected token ... at line xx col xx
this is with babel-eslint
installed and set as a parser in package.json,
"semistandard": {
"parser": "babel-eslint"
}
is there something I'm misunderstanding ?
When running semistandard with @babel 7 it fails on this error. I have tried installing @babel/types as a dev dependency but it does not work. I assume this is peer dependency problem and I tried running npm install inside of node_modules/@babel-types but this has not worked.
semistandard: Semicolons For All! (https://github.com/Flet/semistandard)
/azk/start-hapiness/Azkfile.js:6:1: Definition for rule 'react/jsx-no-duplicate-props' was not found
/azk/start-hapiness/controllers/todo.js:1:1: Definition for rule 'react/jsx-no-duplicate-props' was not found
/azk/start-hapiness/index.js:1:1: Definition for rule 'react/jsx-no-duplicate-props' was not found
/azk/start-hapiness/lib/database.js:1:1: Definition for rule 'react/jsx-no-duplicate-props' was not found
/azk/start-hapiness/lib/loader.js:1:1: Definition for rule 'react/jsx-no-duplicate-props' was not found
/azk/start-hapiness/lib/server.js:1:1: Definition for rule 'react/jsx-no-duplicate-props' was not found
/azk/start-hapiness/models/todo.js:1:1: Definition for rule 'react/jsx-no-duplicate-props' was not found
/azk/start-hapiness/routes/todo.js:1:1: Definition for rule 'react/jsx-no-duplicate-props' was not found
/azk/start-hapiness/test/routes/todo.spec.js:1:1: Definition for rule 'react/jsx-no-duplicate-props' was not found
/azk/start-hapiness/validators/todo.js:1:1: Definition for rule 'react/jsx-no-duplicate-props' was not found
npm ERR! Test failed. See above for more details.
I got this error when I running my linter. Someone can help me to fix this?
Hi @Flet,
Since upgrading to the latest version of Semistandard
(8.0.0
)
we are getting a lot of "Identifier 'variable_name' is not in camel case"
...
But we want to use snake_case
for our variables so they are easy to distinguish.
How do we set this in package.json
?
Tried:
"semistandard": {
"rules": {
"camelcase": false
},
}
But no luck.
Can you please help and/or point us to the place in the docs where its explained how to ignore a certain rule? thanks!
$ semistandard
semistandard: Use Semicolons For All! (https://github.com/Flet/semistandard)
/Users/kaylee/Projects/GitHub/gsklee/frontier/source/scripts/main.js:0:0: Cannot find module 'babel-eslint'
/Users/kaylee/Projects/GitHub/gsklee/frontier/source/scripts/test/test.js:0:0: Cannot find module 'babel-eslint'
$ npm ls --depth=0 -g
/Users/kaylee/.nvm/versions/io.js/v3.3.0/lib
├── [email protected]
├── [email protected]
└── [email protected]
Any ideas?
cc @feross
am I supposed to be able to run this in a top level directory and have it recursively search and test all of my js files? If I run it from the top level of this repo, I get:
➜ nanomsg git:(master) ✗ semistandard
Error: spawn ENOENT
at errnoException (child_process.js:988:11)
at Process.ChildProcess._handle.onexit (child_process.js:779:34)
So I have this piece of code, which I removed some of the code to make it simpler:
(function () {
'use strict';
angular.module('dm.popular.selection')
.controller('PopularSelectionController', PopularSelectionController);
/* ngInject */
function PopularSelectionController (PopularSelectionService) {
var vm = this;
function getSelections () {
vm.selection = [];
PopularSelectionService.getSelections()
.success(function (data) {
vm.selectionItems = data.items;
vm.selectionEngage = data.dateEngage;
vm.processing = false;
}).error(function (data) {
vm.processing = false; //problem here
vm.dmFormErrors = data; // and here
});
}
}
}());
So as you can see, vm.processing
and vm.dmFormErrors
should have more two spaces. So I add them:
}).error(function (data) {
vm.processing = false; //problem here solved
vm.dmFormErrors = data; // and here also solved
});
Now if I run semistandard --verbose | snazzy
everything is great and there are no errors, but if I run semistandard --format | snazzy
it changes my file again to this:
}).error(function (data) {
vm.processing = false; //problem here again
vm.dmFormErrors = data; // and here again
});
It removes the two spaces that I added and then throws an error saying that I should add two spaces.
It remembers me when I was young and ask my parents to go out, my Mom would say yes and my Dad would say no and that makes me sad.
Does anyone know if there's something wrong with that specific code or if it's an edge case?
How to disable jsx
This is nearly there ..
{
"brace_style": "collapse",
"break_chained_methods": false,
"eval_code": false,
"indent_char": " ",
"indent_level": 0,
"indent_size": 2,
"indent_with_tabs": false,
"jslint_happy": true,
"keep_array_indentation": false,
"keep_function_indentation": false,
"max_preserve_newlines": 2,
"preserve_newlines": true,
"space_before_conditional": true,
"unescape_strings": false,
"wrap_line_length": 0
}
I get this error after re-installing semistandard with rm node_modules/semistandard && npm install semistandard
:
TypeError: Error while loading rule 'spaced-comment': Cannot read property 'length' of undefined
at module.exports (C:\r\larsthorup\amaze\node_modules\semistandard\node_modules\standard-engine\node_modules\eslint\lib\rules\spaced-comment.js:26:28)
at C:\r\larsthorup\amaze\node_modules\semistandard\node_modules\standard-engine\node_modules\eslint\lib\eslint.js:629:32
at Array.forEach (native)
at EventEmitter.module.exports.api.verify (C:\r\larsthorup\amaze\node_modules\semistandard\node_modules\standard-engine\node_modules\eslint\lib\eslint.js:620:16)
at processText (C:\r\larsthorup\amaze\node_modules\semistandard\node_modules\standard-engine\node_modules\eslint\lib\cli-engine.js:200:27)
at processFile (C:\r\larsthorup\amaze\node_modules\semistandard\node_modules\standard-engine\node_modules\eslint\lib\cli-engine.js:225:12)
at C:\r\larsthorup\amaze\node_modules\semistandard\node_modules\standard-engine\node_modules\eslint\lib\cli-engine.js:317:26
at walk (C:\r\larsthorup\amaze\node_modules\semistandard\node_modules\standard-engine\node_modules\eslint\lib\util\traverse.js:81:9)
at C:\r\larsthorup\amaze\node_modules\semistandard\node_modules\standard-engine\node_modules\eslint\lib\util\traverse.js:102:9
at Array.forEach (native)
It looks like semistandard will use the latest eslint (0.24.0) but the embedded standard-engine will use a specific commit off of 0.22.1, as npm ls eslint
gives:
[email protected] C:\r\larsthorup\temp\amaze
└─┬ [email protected]
├── [email protected]
└─┬ [email protected]
└── [email protected] (git://github.com/eslint/eslint.git#fff52aecaf1d073952201b3f128e6664f529a24e)
If I update node_modules/semistandard/node_modules/standard-engine/node_modules/eslint to a copy of the one in node_modules/semistandard/node_modules/eslint this error goes away.
To reproduce:
git clone git://github.com/larsthorup/amaze.git
cd amaze
git checkout 7fb4c3
npm install
npm test
Let me know if you need me to assemble a smaller repro scenario.
For example, I get this when I've installed semistandard into my project and am calling it in package.json
:
Error: Failed to load plugin react: Cannot find module 'eslint-plugin-react'
This is because it is getting installed in the node_modules
of semistandard
and therefore, eslint
cannot find it.
The correct way to do this would be to specify the eslint
plugins as peer depencies, not as normal dependencies.
I'd be happy to make a PR for this...
Maybe some of the snark could be removed 😇.
➜ nanomsg git:(formatting) ✗ semistandard -h
Usage:
standard <flags>
Flags:
-v, --verbose Show error codes (so you can ignore specific rules)
--stdin Force processing input from stdin
--version Display the current version
-F --format EXPERIMENTIAL: format code using standard-format before linting
(will not work with stdin)
-h, --help Display the help and usage details
Report bugs: https://github.com/feross/standard/issues
Input:
foo[0]
bar
Actual:
foo[0];bar;
Expected:
foo[0];
bar;
Cheers :)
Using semistandard today all of a sudden results in "Definition for rule 'react/jsx-no-duplicate-props' was not found" errors.
I have the following code:
var o = {
get foo() {
return 1;
}
};
console.log(o);
running semistandard -F
on it, gives me:
semistandard: Semicolons For All! (https://github.com/Flet/semistandard)
/home/timo/FluentFlow/testStandard.js:2:10: Missing space before function parentheses.
That's ok. But if I add that missing space, it will be removed again by the "format option" and the error stays the same.
Is there any way to display 2-space indentations as if it's 4-space wide for common editors (Atom, Sublime, Vim, etc.)?
My team is interested in adapting Semistandard but the enforcement on purely personal preference (ie. indentation depth) is holding them off. We're looking for a way to introduce Semistandard into our workflow but allowing different indentation depth at the same time. Tweaking the width of indentation space characters seems to be a way of doing it.
semistandard
always seems to resolves paths against the current working directory, regardless of whether they are absolute or relative, and consequently fails to read absolute file paths. E.g.:
vagrant@flycheck-test:/flycheck$ semistandard --version
4.2.0
vagrant@flycheck-test:/flycheck$ semistandard test/resources/checkers/javascript-style.js
semistandard: Use Semicolons For All! (https://github.com/Flet/semistandard)
/flycheck/test/resources/checkers/javascript-style.js:3:9: Missing space before function parentheses.
/flycheck/test/resources/checkers/javascript-style.js:4:2: Expected indentation of 2 characters.
/flycheck/test/resources/checkers/javascript-style.js:4:5: foo is defined but never used
/flycheck/test/resources/checkers/javascript-style.js:4:12: Strings must use singlequote.
vagrant@flycheck-test:/flycheck$ semistandard /flycheck/test/resources/checkers/javascript-style.js
semistandard: Unexpected linter output:
Error: ENOENT, no such file or directory '/flycheck/flycheck/test/resources/checkers/javascript-style.js'
at Object.fs.statSync (fs.js:696:18)
at walk (/usr/lib/node_modules/semistandard/node_modules/standard-engine/node_modules/eslint/lib/util/traverse.js:36:15)
at /usr/lib/node_modules/semistandard/node_modules/standard-engine/node_modules/eslint/lib/util/traverse.js:102:9
at Array.forEach (native)
at traverse (/usr/lib/node_modules/semistandard/node_modules/standard-engine/node_modules/eslint/lib/util/traverse.js:101:11)
at CLIEngine.executeOnFiles (/usr/lib/node_modules/semistandard/node_modules/standard-engine/node_modules/eslint/lib/cli-engine.js:323:9)
at /usr/lib/node_modules/semistandard/node_modules/standard-engine/index.js:117:56
at zalgoSafe (/usr/lib/node_modules/semistandard/node_modules/standard-engine/node_modules/dezalgo/dezalgo.js:20:10)
at done (/usr/lib/node_modules/semistandard/node_modules/standard-engine/node_modules/run-parallel/index.js:18:15)
at f (/usr/lib/node_modules/semistandard/node_modules/standard-engine/node_modules/glob/node_modules/once/once.js:17:25)
If you think this is a bug in `semistandard`, open an issue: https://github.com/Flet/semistandard/issues
standard
works fine.
standard-*
has updated per eslint 2.0 release, please update the dependencies.
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.