Closed alexpts closed 8 years ago
Same problem
Can't repro -
$ echo "alert(1);" > test.js
$ jscs test.js --preset airbnb
$ jscs --version
2.11.0
Check how you execute the jscs
I exec: jscs -c .jscsrc server.js
I try run: jscs server.js --preset airbnb
Result: "Unsupported rule: requireSpacesInsideImportedObjectBraces at server.js "
Unsupported rule: requireSpacesInsideImportedObjectBraces at server.js :
1 |alert(1);
--------^
2 |
Working correct:
$ echo "alert(1);" > test.js
$ jscs test.js --preset airbnb
$ jscs --version
2.11.0
But with custom preset
$ echo "alert(1);" > test.js
$ curl -o .jscsrc https://raw.githubusercontent.com/jscs-dev/node-jscs/master/presets/airbnb.json
$ jscs test.js --preset ./.jscsrc
call exeption
Unsupported rule: requireSpacesInsideImportedObjectBraces at test.js :
1 |alert(1);
--------^
2 |
See terminal http://take.ms/LP8uP
I check airbnb preset in installed jscs package. This rule not found.
$cat /usr/local/lib/node_modules/jscs/presets/airbnb.json | grep -i 'requireSpacesInsideImportedObjectBraces'
Yeah, i'm checking, thank you
So, okay, this rule was merged to master
and airbnb
preset also has it, but only in master
.
So how you doing that?
Mac OS X (El Captain)
$npm install -g jscs
...
jscs@2.11.0 /usr/local/lib/node_modules/jscs
$cat /usr/local/lib/node_modules/jscs/presets/airbnb.json | grep -i 'requireSpacesInsideImportedObjectBraces'
$
But
$cat /usr/local/lib/node_modules/jscs/presets/airbnb.json | grep -i 'requirePaddingNewLinesAfterBlocks"'
"requirePaddingNewLinesAfterBlocks": true,
cat /usr/local/lib/node_modules/jscs/presets/airbnb.json | grep -i 'requirePaddingNewLinesAfterBlocks"'
Isn't this command the same in both your examples, so how could you have different results for the same command?
No. Differrent string for search: requireSpacesInsideImportedObjectBraces
vs requirePaddingNewLinesAfterBlocks
Okay, so why you surprised by this output? requirePaddingNewLinesAfterBlocks
is in the preset, while requireSpacesInsideImportedObjectBraces
isn't - https://github.com/jscs-dev/node-jscs/blob/2.x/presets/airbnb.json
Oh.
In Terminal:
cat /usr/local/lib/node_modules/jscs/package.json
Output (sorry, big text):
{
"author": {
"name": "Marat Dulin",
"email": "mdevils@yandex.ru",
"url": "https://github.com/jscs-dev/node-jscs/graphs/contributors"
},
"description": "JavaScript Code Style",
"name": "jscs",
"version": "2.11.0",
"main": "lib/checker",
"homepage": "http://jscs.info",
"keywords": [
"code style",
"formatter",
"lint",
"linter",
"style guide",
"validate"
],
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/jscs-dev/node-jscs.git"
},
"bugs": {
"url": "https://github.com/jscs-dev/node-jscs/issues"
},
"maintainers": [
{
"name": "hzoo",
"email": "hi@henryzoo.com"
},
{
"name": "markelog",
"email": "markelog@gmail.com"
},
{
"name": "mdevils",
"email": "mdevils@yandex.ru"
},
{
"name": "mikesherov",
"email": "mike.sherov@gmail.com"
},
{
"name": "mrjoelkemp",
"email": "joel@mrjoelkemp.com"
},
{
"name": "qfox",
"email": "zxqfox@gmail.com"
}
],
"engines": {
"node": ">= 0.10.0"
},
"dependencies": {
"babel-jscs": "^2.0.0",
"chalk": "~1.1.0",
"cli-table": "~0.3.1",
"commander": "~2.9.0",
"escope": "^3.2.0",
"esprima": "~2.7.0",
"estraverse": "^4.1.0",
"exit": "~0.1.2",
"glob": "^5.0.1",
"htmlparser2": "3.8.3",
"js-yaml": "~3.4.0",
"jscs-jsdoc": "^1.3.1",
"jscs-preset-wikimedia": "~1.0.0",
"jsonlint": "~1.6.2",
"lodash": "~3.10.0",
"minimatch": "~3.0.0",
"natural-compare": "~1.2.2",
"pathval": "~0.1.1",
"prompt": "~0.2.14",
"reserved-words": "^0.1.1",
"resolve": "^1.1.6",
"strip-bom": "^2.0.0",
"strip-json-comments": "~1.0.2",
"to-double-quotes": "^2.0.0",
"to-single-quotes": "^2.0.0",
"vow": "~0.4.8",
"vow-fs": "~0.3.4",
"xmlbuilder": "^3.1.0"
},
"devDependencies": {
"browserify": "^12.0.0",
"chai": "^3.3.0",
"coveralls": "~2.11.2",
"has-ansi": "~2.0.0",
"jshint": "~2.8.0",
"mocha": "^2.2.0",
"regenerate": "~1.2.1",
"rewire": "^2.3.1",
"sinon": "^1.13.0",
"sinon-chai": "^2.8.0",
"unicode-7.0.0": "~0.1.5",
"unit-coverage": "^4.0.1",
"xml2js": "~0.4.4"
},
"bin": {
"jscs": "./bin/jscs"
},
"unit-coverage": {
"common": [
"-a",
"lib",
"-a",
"test",
"-s",
"lib/**/*.js",
"-t",
"test/specs/**/*.js",
"-e",
"lib/cli-config.js",
"-S",
"relative",
"-O",
"sources=lib",
"-O",
"tests=test/specs"
]
},
"scripts": {
"lint": "jshint . && node bin/jscs lib test bin publish",
"pretest": "npm run lint",
"test": "mocha --color",
"autofix-tests": "node test/scripts/integration.js",
"coverage": "unit-coverage run -p common",
"coverage-html": "unit-coverage run -p common -r html -o coverage.html",
"coveralls": "unit-coverage run -p common -r lcov -o out.lcov && cat out.lcov | coveralls",
"browserify": "browserify --standalone JscsStringChecker lib/string-checker.js -o jscs-browser.js",
"changelog": "git log `git describe --tags --abbrev=0`..HEAD --pretty=format:' * %s (%an)' | grep -v 'Merge pull request'",
"release": "node publish/prepublish && npm test && npm publish",
"postpublish": "node publish/postpublish",
"travis": "npm run test && npm run autofix-tests && npm run coveralls"
},
"files": [
"bin",
"lib",
"patterns",
"presets",
"LICENSE",
"jscs-browser.js"
],
"gitHead": "8d25f6dddcb1e4f0cfb1bfeefd297a612b77e86b",
"_id": "jscs@2.11.0",
"_shasum": "6e11ef0caaa07731f9dcc2b2b27d8ecee1ddbcb6",
"_from": "jscs@latest",
"_npmVersion": "3.3.12",
"_nodeVersion": "5.1.0",
"_npmUser": {
"name": "markelog",
"email": "markelog@gmail.com"
},
"dist": {
"shasum": "6e11ef0caaa07731f9dcc2b2b27d8ecee1ddbcb6",
"tarball": "https://registry.npmjs.org/jscs/-/jscs-2.11.0.tgz"
},
"_npmOperationalInternal": {
"host": "packages-13-west.internal.npmjs.com",
"tmp": "tmp/jscs-2.11.0.tgz_1456947181906_0.41519897105172276"
},
"directories": {},
"_resolved": "https://registry.npmjs.org/jscs/-/jscs-2.11.0.tgz",
"readme": "ERROR: No README data found!"
}
See dist
.
Repo https://registry.npmjs.org/jscs/-/jscs-2.11.0.tgz
has incorrect preset for airbnb :(
$curl -o jscs-2.11.0.tgz https://registry.npmjs.org/jscs/-/jscs-2.11.0.tgz
$gunzip -c jscs-2.11.0.tgz | tar xopf -
$cat package/presets/airbnb.json | grep -i 'requireSpacesInsideImportedObjectBraces'
$
Rule not found. And default preset working correct. LOL
Repo https://registry.npmjs.org/jscs/-/jscs-2.11.0.tgz has incorrect preset for airbnb :(
and
Rule not found. And default preset working correct.
I'm confused, so is there something that not needed to be there or not?
Ok.
Preset from master
branch not working with 2.x
branch. Right?
Yep
It's ok?
Default branch from github is master
.
But NPM downloaded 2.x
version by default.
Presets from master
not working with 2.x
.
Really? It breaks the brain.
It's ok?
Yeah, presets from master
depends on code from master
and 2.x presets depend on 2.x code. Not sure what could be confusing about that.
Like if you would use module of say express
package from their master
whereas you installed 3.x version you woudn't expect it to work.
This use-case is strange all the way.
Yep. It's confused. Because 'master' branch should be used as default-active-branch.
Open express.js master
branch.
See package.json
.
Version is 4.13.4
.
And NPM downloaded files one to one as master
.
And it's correct. And not confused.
Thx.
Have no idea what you talking about
How many comments :)
Ok, I get config from release commit. Thanks.
jscs -V // 2.11.0 airbnb preset https://github.com/jscs-dev/node-jscs/blob/master/presets/airbnb.json