Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 6ce09af

Browse files
committed
Rerwrite in JavaScript
We-re maintaining our own fork of CSSLink because we need to make some changes to make the output compatible with the Spec. This makes CSSLint updates hard and as a result the engine lags behind the upstream. CSSLint provides APIs that we can use directly to augment output but they're only exposed in JavaScript. This rewrite is targeted towards using the upstream CSSLint and only maintaining the custom parts that in the engine. This should make CSSLint updates trivial as long as the API stays stable. As a bonus it drops Ruby from dependencies making the overal image smaller.
1 parent 8f3aed0 commit 6ce09af

26 files changed

+806
-402
lines changed

.codeclimate.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
engines:
2-
rubocop:
2+
eslint:
33
enabled: true
4-
ratings:
5-
paths:
6-
- "**.rb"
4+
channel: eslint-4
75
exclude_paths:
8-
- spec/**/*
6+
- test/**/*
7+
- node_modules/**/*

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.git
22
Makefile
3+
node_modules

.eslintrc

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"env": {
3+
"node": true,
4+
"mocha": true,
5+
"es6": true
6+
},
7+
"rules": {
8+
"block-spacing": 2,
9+
"brace-style": [2, "1tbs", { "allowSingleLine": true }],
10+
"comma-dangle": [2, "never"],
11+
"comma-style": [2, "first", { exceptions: {ArrayExpression: true, ObjectExpression: true} }],
12+
"complexity": [2, 6],
13+
"curly": 2,
14+
"eqeqeq": [2, "allow-null"],
15+
"max-statements": [2, 30],
16+
"no-shadow-restricted-names": 2,
17+
"no-undef": 2,
18+
"no-use-before-define": 2,
19+
"radix": 2,
20+
"semi": 2,
21+
"space-infix-ops": 2,
22+
"strict": 0
23+
},
24+
"globals": {
25+
"AnalysisView": true,
26+
"PollingView": true,
27+
"Prism": true,
28+
"Spinner": true,
29+
"Timer": true,
30+
"moment": true
31+
}
32+
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/

.rubocop.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.

.ruby-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

Dockerfile

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
FROM codeclimate/alpine-ruby:b38
1+
FROM node:alpine
2+
3+
RUN adduser -u 9000 -D app
24

35
WORKDIR /usr/src/app
4-
COPY Gemfile /usr/src/app/
5-
COPY Gemfile.lock /usr/src/app/
66

7-
RUN apk --update add nodejs git zlib zlib-dev ruby ruby-dev ruby-bundler less build-base && \
8-
bundle install -j 4 && \
9-
apk del --purge build-base zlib zlib-dev && rm -fr /usr/share/ri
7+
COPY package.json yarn.lock ./
108

11-
ENV CSSLINT_SHA=87aa604a4cbc5125db979576f1b09b35980fcf08
12-
RUN npm install -g codeclimate/csslint.git#$CSSLINT_SHA
9+
RUN yarn install && \
10+
chown -R app:app ./
11+
12+
COPY . ./
1313

14-
RUN adduser -u 9000 -D app
1514
USER app
1615

1716
COPY . /usr/src/app

Gemfile

Lines changed: 0 additions & 10 deletions
This file was deleted.

Gemfile.lock

Lines changed: 0 additions & 44 deletions
This file was deleted.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ image:
44
docker build -t codeclimate/codeclimate-csslint .
55

66
test: image
7-
docker run --rm codeclimate/codeclimate-csslint rspec $(RSPEC_ARGS)
7+
docker run --rm codeclimate/codeclimate-csslint npm run test

Rakefile

Lines changed: 0 additions & 5 deletions
This file was deleted.

bin/csslint

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
#!/usr/bin/env ruby
2-
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), "../lib")))
1+
#!/usr/local/bin/node --expose-gc
32

4-
require 'cc/engine/csslint'
3+
const fs = require("fs");
4+
const Engine = require("../lib/csslint");
55

6-
if File.exists?("/config.json")
7-
engine_config = JSON.parse(File.read("/config.json"))
8-
else
9-
engine_config = {}
10-
end
6+
const CONFIG_PATH = "/config.json";
7+
let config = JSON.parse(fs.readFileSync(CONFIG_PATH));
118

12-
CC::Engine::CSSlint.new(
13-
directory: "/code", engine_config: engine_config, io: STDOUT
14-
).run
9+
const CODE_DIR = "/code";
10+
new Engine(CODE_DIR, console, config).run();

bin/csslint.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env ruby
2+
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), "../lib")))
3+
4+
require 'cc/engine/csslint'
5+
6+
if File.exists?("/config.json")
7+
engine_config = JSON.parse(File.read("/config.json"))
8+
else
9+
engine_config = {}
10+
end
11+
12+
CC::Engine::CSSlint.new(
13+
directory: "/code", engine_config: engine_config, io: STDOUT
14+
).run

lib/cc/engine/csslint.rb

Lines changed: 0 additions & 92 deletions
This file was deleted.

lib/cc/engine/csslint/check_details.rb

Lines changed: 0 additions & 54 deletions
This file was deleted.

0 commit comments

Comments
 (0)