Skip to content

ESLint 3 preparation for master #178

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

Merged
merged 47 commits into from
Feb 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
1c53766
Monkey patch eslint, instead of modifying it
Feb 24, 2016
d5f6d02
Use eslint-2.4.0
pbrisbin May 26, 2016
42254a2
Comment loadPackage override
pbrisbin May 26, 2016
a21ea81
Update babel-eslint to v6
pbrisbin May 26, 2016
9b8a73e
Update dependencies
dblandin May 27, 2016
4f840fe
Add standard style plugin and shared config
dblandin Jun 2, 2016
5c285e9
Vendor additional Standard Style config packages (#102)
dblandin Jun 20, 2016
b23ad06
Add eslint-config-google as available plugin
pbrisbin Jul 15, 2016
f7af77a
Added supporto for ESLint plugin Flowtype
leonardfactory Jul 21, 2016
2ad7153
Add task to update npm-shrinkwrap.json
pbrisbin Jul 21, 2016
80f79a7
Add support for eslint-config-angular
leftees Jul 21, 2016
5b09532
Update package.json (#112)
leftees Aug 2, 2016
e22cc0c
add eslint-config-ember package
Aug 11, 2016
c1fbcf9
Switch base image to avoid Segfault
gdiggs Aug 15, 2016
bf5ea90
Update babel-eslint & eslint-flowtype
Aug 16, 2016
f44fcfe
Add --gecos "" to avoid adduser prompt
pbrisbin Aug 17, 2016
e5f70ba
add hapi config support
idoshamun Aug 21, 2016
f64346d
Add eslint-config-airbnb-base as a top-level dep
chadxz Aug 30, 2016
8bdadf4
Update circle to trigger build
Sep 7, 2016
6c39e02
Upgrade to Node 6.5.0
dblandin Sep 8, 2016
720c5ee
Update packages for ESLint 3
dblandin Sep 8, 2016
2895f99
eslint-3: Added ESLint plugins (#131)
kunagpal Sep 22, 2016
62235a9
Bump eslint to 3.6.1 & eslint-plugin-import to 1.16.0 (#136)
wfleming Sep 30, 2016
f276b74
Support eslint-plugin-ember-suave. (#140)
Oct 13, 2016
4621b9e
Allow ignoring warnings from configuration.
blimmer Oct 16, 2016
7a131a1
Add CONTRIBUTING.md.
blimmer Oct 23, 2016
fb3f96a
Add ignore_warnings to README
Oct 29, 2016
8f5101f
Update README.md
Nov 6, 2016
a3803a8
Update project README
dblandin Nov 7, 2016
1d5d3b2
Upgrade ESLint & some packages
wfleming Nov 9, 2016
09d4548
Add support for eslint-plugin-react-intl plugin (#154)
leftees Nov 28, 2016
60d56b8
docs(CONTRIBUTING): fix .codeclimate.yml example
SebastienElet Nov 29, 2016
46ac7e9
chore(packages): upgrade eslint
SebastienElet Nov 29, 2016
13bf377
feat(config): add eslint-config-simplifield
SebastienElet Nov 29, 2016
01df6be
Switch to yarn for installing dependencies
maxjacobson Dec 14, 2016
bd6cd99
Upgrade eslint-config-google to 0.7.1
Dec 12, 2016
358cb84
Add eslint-plugin-meteor
maxjacobson Dec 14, 2016
a340d0b
Add eslint-plugin-immutable
maxjacobson Dec 16, 2016
93ce7d6
Add eslint-plugin-import-order
maxjacobson Dec 16, 2016
6ebc84f
Add eslint-plugin-jasmine
maxjacobson Dec 16, 2016
dd8ea2a
Add eslint-config-semistandard
rodneyrehm Dec 30, 2016
c754592
Yarn add eslint-config-react-app
dannyc5 Jan 23, 2017
d2c8bd5
added eslint-plugin-xogroup plugin
Jan 28, 2017
4dec276
Upgrade eslint
maxjacobson Feb 3, 2017
58df490
add support for eslint prettier plugin
Feb 14, 2017
31f1e2b
Add config upgrader
pointlessone Feb 17, 2017
1b6188d
Fix null-config issue with upgrader
pointlessone Feb 23, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ engines:
ratings:
paths:
- bin/eslint.js
- lib/checks.js
- lib/*.js
exclude_paths:
- "node_modules/**"
- "test/**"
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"env": {
"node": true,
"mocha": true
"mocha": true,
"es6": true
},
"rules": {
"block-spacing": 2,
Expand Down
40 changes: 40 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Contributing

## Adding and upgrading plugins

When adding or upgrading a plugin, we should see changes in both `package.json`
and `yarn.lock`.

Make sure to run `make image` before running these commands.

Add a plugin:

```
bin/yarn add eslint-config-google
```

Upgrade a plugin:

```
bin/yarn upgrade eslint-config-google
```

## Testing Changes

Changes made to the engine can be tested locally.

1. Install [the CodeClimate CLI](https://github.com/codeclimate/codeclimate).
1. Create the image (customizing the `IMAGE_NAME` as needed):
```bash
IMAGE_NAME=codeclimate/codeclimate-eslint-test make image
```
1. Add the engine to your test `.codeclimate.yml`:
```yaml
engines:
eslint-test:
enabled: true
```
1. Run analyze via the CLI:
```bash
codeclimate analyze --dev
```
25 changes: 18 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
FROM mhart/alpine-node:5.4
FROM node:6.5.0-slim
MAINTAINER Code Climate <hello@codeclimate.com>

WORKDIR /usr/src/app
COPY npm-shrinkwrap.json /usr/src/app/
COPY package.json /usr/src/app/
COPY package.json yarn.lock /usr/src/app/

RUN apk --update add git && \
npm install && \
apk del --purge git
RUN apt-key adv --fetch-keys http://dl.yarnpkg.com/debian/pubkey.gpg && \
echo "deb http://nightly.yarnpkg.com/debian/ nightly main" | tee /etc/apt/sources.list.d/yarn-nightly.list && \
apt-get update && \
apt-get install -y git jq yarn && \
yarn install && \
git clone https://github.com/eslint/eslint.git && \
ESLINT_DOCS_VERSION=`npm -j ls eslint | jq -r .dependencies.eslint.version` && \
cd eslint && \
git checkout v$ESLINT_DOCS_VERSION && \
cd .. && \
mkdir -p /usr/src/app/lib/docs/rules/ && \
cp ./eslint/docs/rules/* /usr/src/app/lib/docs/rules/ && \
rm -rf eslint && \
apt-get purge -y git jq && \
apt-get autoremove -y

RUN adduser -u 9000 -D app
RUN adduser -u 9000 --gecos "" --disabled-password app
COPY . /usr/src/app
RUN chown -R app:app /usr/src/app

Expand Down
54 changes: 46 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,57 @@
# Code Climate ESLint Engine

[![Code Climate](https://codeclimate.com/github/codeclimate/codeclimate-eslint/badges/gpa.svg)](https://codeclimate.com/github/codeclimate/codeclimate-eslint)
[![Code Climate][badge]][repo]

`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.
[badge]: https://codeclimate.com/github/codeclimate/codeclimate-eslint/badges/gpa.svg
[repo]: https://codeclimate.com/repos/github/codeclimate-eslint

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).
`codeclimate-eslint` is a Code Climate engine that wraps [ESLint][]. You can run
it on your command line using the Code Climate CLI, or on our hosted analysis
platform.

ESLint is a tool for identifying and reporting on patterns found in
ECMAScript/JavaScript code. It can be configured using a [configuration
file][config].

[config]: http://eslint.org/docs/user-guide/configuring#using-configuration-files

### Installation

1. If you haven't already, [install the Code Climate CLI](https://github.com/codeclimate/codeclimate).
2. Run `codeclimate engines:enable eslint`. This command both installs the engine and enables it in your `.codeclimate.yml` file.
3. You're ready to analyze! Browse into your project's folder and run `codeclimate analyze`.
1. If you haven't already, [install the Code Climate CLI][CLI]

2. Run `codeclimate engines:enable eslint`. This command both installs the
engine and enables it in your `.codeclimate.yml` file

3. You're ready to analyze! Browse into your project's folder and run
`codeclimate analyze`

[cli]: https://github.com/codeclimate/codeclimate

### Configuration

#### `ignore_warnings`

By default, this engine will emit both ESLint errors and warnings as Code
Climate issues. If you prefer, you can ignore warning-level violations by
setting the `ignore_warnings` configuration option:

```yaml
eslint:
enabled: true
config:
ignore_warnings: true
```

### Need help?

For help with ESLint, [check out their documentation](https://github.com/eslint/eslint).
For help with ESLint, [check out their documentation][eslint-docs].

If you're running into a Code Climate issue, first look over this project's
[GitHub Issues][issues], as your question may have already been covered. If not,
[go ahead and open a support ticket with us][help].

[issues]: https://github.com/codeclimate/codeclimate-eslint/issues
[help]: https://codeclimate.com/help

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).
[eslint]: http://eslint.org
[eslint-docs]: http://eslint.org/docs/user-guide/
19 changes: 17 additions & 2 deletions bin/eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,22 @@ process.chdir(CODE_DIR);
var stdout = console.log;
console.log = console.error;

var CLIEngine = require("eslint").CLIEngine;
var docs = require("eslint").docs;
var eslint = require('../lib/eslint-patch')(require('eslint'));

var CLIEngine = eslint.CLIEngine;
var docs = eslint.docs;
var fs = require("fs");
var glob = require("glob");
var options = { extensions: [".js"], ignore: true, reset: false, useEslintrc: true };
var cli; // instantiation delayed until after options are (potentially) modified
var debug = false;
var BatchSanitizer = require("../lib/batch_sanitizer");
var ignoreWarnings = false;
var ESLINT_WARNING_SEVERITY = 1;
var checks = require("../lib/checks");
var validateConfig = require("../lib/validate_config");
var computeFingerprint = require("../lib/compute_fingerprint");
const ConfigUpgrader = require("../lib/config_upgrader");

// a wrapper for emitting perf timing
function runWithTiming(name, fn) {
Expand Down Expand Up @@ -172,6 +177,10 @@ runWithTiming("engineConfig", function () {
options.ignorePath = userConfig.ignore_path;
}

if (userConfig.ignore_warnings) {
ignoreWarnings = true;
}

if (userConfig.debug) {
debug = true;
}
Expand Down Expand Up @@ -207,6 +216,8 @@ function analyzeFiles() {
var path = result.filePath.replace(/^\/code\//, "");

result.messages.forEach(function(message) {
if (ignoreWarnings && message.severity === ESLINT_WARNING_SEVERITY) { return; }

var issueJson = buildIssueJson(message, path);
process.stdout.write(issueJson + "\u0000\n");
});
Expand All @@ -225,6 +236,10 @@ function analyzeFiles() {
if (validateConfig(options.configFile)) {
console.error("ESLint is running with the " + cli.getConfigForFile(null).parser + " parser.");

for (const line of ConfigUpgrader.upgradeInstructions(analysisFiles, process.cwd())) {
console.error(line);
}

analyzeFiles();
} else {
console.error("No rules are configured. Make sure you have added a config file with rules enabled.");
Expand Down
6 changes: 6 additions & 0 deletions bin/yarn
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

set -e

IMAGE_NAME=${IMAGE_NAME:-codeclimate/codeclimate-eslint}
docker run --rm --volume "$PWD:/usr/src/app" "$IMAGE_NAME" sh -c "cd /usr/src/app && yarn $*"
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ test:

deployment:
registry:
branch: master
branch: /master|channel\/[\w-]+/
commands:
- >
docker run
Expand Down
Loading