Skip to content

Commit facff67

Browse files
committed
Open source commit
0 parents  commit facff67

File tree

6 files changed

+119
-0
lines changed

6 files changed

+119
-0
lines changed

Diff for: .codeclimate.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
engines:
2+
rubocop:
3+
enabled: true
4+
ratings:
5+
paths:
6+
- "**.rb"

Diff for: Dockerfile

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM mhart/alpine-node
2+
3+
WORKDIR /usr/src/app
4+
COPY package.json /usr/src/app/
5+
6+
RUN npm install
7+
8+
COPY . /usr/src/app
9+
10+
CMD ["/usr/src/app/bin/eslint"]

Diff for: LICENSE

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2015 Code Climate, Inc.
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

Diff for: README.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Code Climate ESLint Engine
2+
3+
[![Code Climate](https://codeclimate.com/repos/55841b7a6956801212006c92/badges/92d8261f1b6200f19af5/gpa.svg)](https://codeclimate.com/repos/55841b7a6956801212006c92/feed)
4+
5+
`codeclimate-eslint` is a Code Climate engine that wraps [ESLint](https://github.com/eslint/eslint). You can run it on your command line using the Code Climate CLI, or on our hosted analysis platform.
6+
7+
ESLint is a tool for identifying and reporting on patterns found in ECMAScript/JavaScript code. It can be configured using a [configuration file](https://github.com/eslint/eslint#usage).
8+
9+
### Installation
10+
11+
1. If you haven't already, [install the Code Climate CLI](https://github.com/codeclimate/codeclimate).
12+
2. Run `codeclimate engines:enable eslint`. This command both installs the engine and enables it in your `.codeclimate.yml` file.
13+
3. You're ready to analyze! Browse into your project's folder and run `codeclimate analyze`.
14+
15+
### Need help?
16+
17+
For help with ESLint, [check out their documentation](https://github.com/eslint/eslint).
18+
19+
If you're running into a Code Climate issue, first look over this project's [GitHub Issues](https://github.com/codeclimate/codeclimate-eslint/issues), as your question may have already been covered. If not, [go ahead and open a support ticket with us](https://codeclimate.com/help).

Diff for: bin/eslint

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env node
2+
3+
var CLIEngine = require("eslint").CLIEngine;
4+
5+
function buildIssueJson(message, path) {
6+
var issue = {
7+
type: "issue",
8+
categories: ["Style"],
9+
check_name: message.ruleId,
10+
description: message.message,
11+
location: {
12+
path: path,
13+
positions: {
14+
begin: {
15+
line: message.line,
16+
column: message.column
17+
},
18+
end: {
19+
line: message.line,
20+
column: message.column
21+
}
22+
}
23+
}
24+
};
25+
return JSON.stringify(issue);
26+
}
27+
28+
var options = {
29+
extensions: ['.js'], ignore: true, reset: false, useEslintrc: true
30+
};
31+
var ignores = []
32+
if (process.env.ENGINE_CONFIG) {
33+
var engineConfig = JSON.parse(process.env.ENGINE_CONFIG);
34+
if (engineConfig['config']) {
35+
options['configFile'] = "/code/" + engineConfig['config'];
36+
}
37+
if (engineConfig['exclude_paths']) {
38+
ignores = engineConfig['exclude_paths'];
39+
}
40+
}
41+
var cli = new CLIEngine(options);
42+
var report = cli.executeOnFiles(["/code"]);
43+
report.results.forEach(function(result, _, _) {
44+
var path = result.filePath.replace(/^\/code\//, '');
45+
if (ignores.indexOf(path) === -1) {
46+
result.messages.forEach(function(message, _, _) {
47+
var issueJson = buildIssueJson(message, path);
48+
console.log(issueJson + "\u0000");
49+
});
50+
}
51+
});

Diff for: package.json

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "codeclimate-eslint",
3+
"version": "0.0.1",
4+
"description": "eslint",
5+
"author": "Code Climate",
6+
"repository" : {
7+
"type" : "git",
8+
"url" : "http://github.com/codeclimate/codeclimate-eslint.git"
9+
},
10+
"dependencies": {
11+
"eslint": "0.22.1"
12+
},
13+
"engine": "node >= 0.12.4"
14+
}

0 commit comments

Comments
 (0)