-
Notifications
You must be signed in to change notification settings - Fork 93
ESlint 2.0 #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
ESlint 2.0 #92
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
06b6503
Monkey patch eslint, instead of modifying it
1f111fc
Use eslint-2.4.0
pbrisbin 5ca5f43
Comment loadPackage override
pbrisbin 483a24d
Update babel-eslint to v6
pbrisbin d1ff631
Update dependencies
dblandin 70efbc9
Merge pull request #93 from codeclimate/devon/eslint-2
dblandin 20b0ede
Add standard style plugin and shared config
dblandin 5979e0f
COPY npm-shrinkwrap.json before npm install
dblandin 95911b8
Merge pull request #96 from codeclimate/devon/eslint-2-add-standard-p…
dblandin 88215de
Update CircleCI config to use patrick
dblandin bfaa029
Cleanup Dockerfile
dblandin e2dcac7
Merge pull request #98 from codeclimate/devon/pb-eslint-2-update-circ…
dblandin 1b4f231
Vendor additional Standard Style config packages (#102)
dblandin beefd30
Add eslint-config-google as available plugin
pbrisbin df907bc
Merge pull request #104 from codeclimate/pb-google-config
pbrisbin 833aa19
Added supporto for ESLint plugin Flowtype
leonardfactory 31e828e
Merge pull request #106 from favoloso/eslint-2-flowtype-plugin
pbrisbin fe5dfac
Add task to update npm-shrinkwrap.json
pbrisbin 9f2293d
Add support for eslint-config-angular
leftees 2f5cabf
Merge pull request #107 from codeclimate/js-eslint
pbrisbin 4952a9b
Update package.json (#112)
leftees 870d031
Heuristically filter out minified files
187fb76
Merge pull request #114 from codeclimate/abh-wf-skip-minifieds
13dc1a5
add eslint-config-ember package
e18647f
Merge pull request #118 from aaroncraigongithub/eslint2/eslint-config…
pbrisbin 7f3d77b
Switch base image to avoid Segfault
gdiggs 3cb2fa8
Merge pull request #119 from codeclimate/gd-segfault
gdiggs 5a524a5
Update babel-eslint & eslint-flowtype
0ffdd03
Merge pull request #121 from codeclimate/will/bump-babel-and-flowtype
wfleming 7b4c106
Code cleanup
GarthDB a66ec7e
Support for ignore_path in engine config
GarthDB 9da846b
Add --gecos "" to avoid adduser prompt
pbrisbin 54e0d4e
add hapi config support
idoshamun 71f21cf
Merge pull request #124 from elegantmonkeys/pb-eslint-2
49a2b84
Add eslint-config-airbnb-base as a top-level dep
chadxz 5018915
Merge pull request #126 from chadxz/eslint-config-airbnb-base
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,16 @@ | ||
.PHONY: image test | ||
.PHONY: image test citest shrinkwrap | ||
|
||
IMAGE_NAME ?= codeclimate/codeclimate-eslint | ||
|
||
image: | ||
docker build --rm -t $(IMAGE_NAME) . | ||
|
||
test: image | ||
docker run --rm --workdir="/usr/src/app" $(IMAGE_NAME) npm run test | ||
docker run --rm $(IMAGE_NAME) sh -c "cd /usr/src/app && npm run test" | ||
|
||
citest: | ||
docker run --rm $(IMAGE_NAME) sh -c "cd /usr/src/app && npm run test" | ||
|
||
shrinkwrap: image | ||
docker run --rm --workdir /usr/src/app $(IMAGE_NAME) sh -c \ | ||
'npm shrinkwrap >/dev/null && cat npm-shrinkwrap.json' > npm-shrinkwrap.json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
var fs = require("fs"); | ||
|
||
var MINIFIED_AVG_LINE_LENGTH_CUTOFF = 100; | ||
|
||
function BatchSanitizer(files, stderr) { | ||
this.files = files; | ||
this.stderr = stderr || process.stderr; | ||
} | ||
|
||
BatchSanitizer.prototype.sanitizedFiles = function() { | ||
var sanitizedFiles = []; | ||
|
||
for(var i = 0; i < this.files.length; i++) { | ||
if (this.isMinified(this.files[i])) { | ||
this.stderr.write("WARN: Skipping " + this.files[i] + ": it appears to be minified\n"); | ||
} else { | ||
sanitizedFiles.push(this.files[i]); | ||
} | ||
} | ||
|
||
return sanitizedFiles; | ||
}; | ||
|
||
BatchSanitizer.prototype.isMinified = function(path) { | ||
var buf = fs.readFileSync(path) | ||
, newline = "\n".charCodeAt(0) | ||
, lineCount = 0 | ||
, charsSeen = 0; | ||
|
||
for(var i = 0; i < buf.length; i++) { | ||
if (buf[i] === newline) { | ||
lineCount++; | ||
} else { | ||
charsSeen++; | ||
} | ||
} | ||
|
||
return (charsSeen / lineCount) >= MINIFIED_AVG_LINE_LENGTH_CUTOFF; | ||
}; | ||
|
||
module.exports = BatchSanitizer; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* @fileoverview Providing easy access to rule documentation | ||
*/ | ||
|
||
'use strict'; | ||
|
||
var fs = require('fs') | ||
, path = require('path'); | ||
|
||
//------------------------------------------------------------------------------ | ||
// Privates | ||
//------------------------------------------------------------------------------ | ||
|
||
var docs = Object.create(null); | ||
|
||
function load() { | ||
var docsDir = path.join(__dirname, '/docs/rules'); | ||
|
||
fs.readdirSync(docsDir).forEach(function(file) { | ||
var content = fs.readFileSync(docsDir + '/' + file, 'utf8'); | ||
|
||
// Remove the .md extension from the filename | ||
docs[file.slice(0, -3)] = content; | ||
}); | ||
} | ||
|
||
//------------------------------------------------------------------------------ | ||
// Public Interface | ||
//------------------------------------------------------------------------------ | ||
|
||
exports.get = function(ruleId) { | ||
return docs[ruleId]; | ||
}; | ||
|
||
//------------------------------------------------------------------------------ | ||
// Initialization | ||
//------------------------------------------------------------------------------ | ||
|
||
// loads existing docs | ||
load(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
'use strict'; | ||
var meld = require('meld'); | ||
var docs = require('./docs'); | ||
|
||
var supportedPlugins = ['react', 'babel']; | ||
|
||
module.exports = function patcher(eslint) { | ||
|
||
meld.around(eslint.CLIEngine, 'loadPlugins', function(joinPoint) { | ||
var pluginNames = joinPoint.args[0]; | ||
var filteredPluginNames = pluginNames.filter(function(pluginName) { | ||
return supportedPlugins.indexOf(pluginName) >= 0; | ||
}); | ||
return joinPoint.proceed(filteredPluginNames); | ||
}); | ||
|
||
meld.around(eslint.CLIEngine, 'addPlugin', function() { | ||
return; | ||
}); | ||
|
||
// meld.around(eslint.CLIEngine.Config, 'loadPackage', function(joinPoint) { | ||
// var filePath = joinPoint.args[0]; | ||
// if (filePath.match(/^eslint-config-airbnb.*/)) { | ||
// return joinPoint.proceed(); | ||
// } else { | ||
// return {}; | ||
// } | ||
// }); | ||
|
||
eslint.docs = docs; | ||
|
||
return eslint; | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this patch working as intended? I arrived here because I'm seeing
Failed to load plugin
errors for an unsupported plugin, but I think this patch is intended to avoid loading unsupported plugins?I'm questioning whether this does anything because it appears to me that
eslint.CLIEngine
has not had aloadPlugins
method since this commit, and that commit has been around since ESLint 2.0.0?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This patch is not working as intended. It was at the time it was written, but (as you noted) that's no longer the case given the current internals of ESLint.
We're evaluating if we want to accept unsupported plugins causing errors like that, or try to bring back the logic intended to replace that with ignoring them. Unfortunately, this
meld
approach doesn't appear viable on the new internals, so it would require moving back to our own fork of ESLint itself.In the meantime though, we should probably remove this.
EDIT: It may not have even worked when it was written. The history is uncertain here.