Skip to content
This repository was archived by the owner on Aug 7, 2023. It is now read-only.

Commit 553f454

Browse files
author
Spain
committed
🚥 CI: Update configs for CI services
* Setup CI for a lint, build, test sequence * Remove ucompiler, just use babel directly * Add command for publishing with apm (`npm run apm-publish -- <bump>`)
1 parent 6e016ab commit 553f454

File tree

13 files changed

+145
-209
lines changed

13 files changed

+145
-209
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
spec/fixtures/**/*.js
2+
lib/**/*.js

.gitignore

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
node_modules
1+
/lib/
2+
/node_modules/
23
*.log
34
.idea
4-
5-
# Keep node_modules test fixtures
6-
!spec/fixtures/local-eslint/node_modules

.travis.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,7 @@ notifications:
1010
on_failure: change
1111
os: osx
1212

13-
script: 'curl -s https://raw.githubusercontent.com/atom/ci/master/build-package.sh | sh'
13+
script:
14+
- npm i
15+
- npm run compile
16+
- 'curl -s https://raw.githubusercontent.com/atom/ci/master/build-package.sh | sh'

appveyor.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,7 @@ build_script:
1414
- cd %APPVEYOR_BUILD_FOLDER%
1515
- SET PATH=%LOCALAPPDATA%\atom\bin;%PATH%
1616
- apm clean
17+
- npm i
18+
- npm run compile
1719
- apm install
1820
- apm test

circle.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
dependencies:
2-
override:
3-
- wget -O atom-amd64.deb https://atom.io/download/deb
2+
pre:
43
- sudo apt-get update
4+
- sudo apt-get install wget
5+
post:
6+
- wget -O atom-amd64.deb https://atom.io/download/deb
57
- sudo dpkg --install atom-amd64.deb || true
68
- sudo apt-get -f install -y
7-
- atom -v
8-
- apm install
99
test:
1010
override:
11-
- ./node_modules/.bin/eslint lib
12-
- ./node_modules/.bin/eslint spec
11+
- npm run lint
12+
- npm run compile
13+
- atom -v
14+
- apm install
1315
- apm test

lib/helpers.js

Lines changed: 34 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,19 @@
1-
'use strict';
21
'use babel';
32

4-
Object.defineProperty(exports, "__esModule", {
5-
value: true
6-
});
7-
exports.spawnWorker = spawnWorker;
8-
exports.getModulesDirectory = getModulesDirectory;
9-
exports.getIgnoresFile = getIgnoresFile;
10-
exports.getEslintFromDirectory = getEslintFromDirectory;
11-
exports.getNodePrefixPath = getNodePrefixPath;
12-
exports.getBundledEslintDirectory = getBundledEslintDirectory;
13-
exports.getEslintDirectory = getEslintDirectory;
14-
exports.getEslintConfig = getEslintConfig;
15-
exports.getEslint = getEslint;
3+
import Path from 'path';
4+
import FS from 'fs';
5+
import ChildProcess from 'child_process';
6+
import CP from 'childprocess-promise';
7+
import { findFile as find } from 'atom-linter';
168

17-
var _path = require('path');
18-
19-
var _path2 = _interopRequireDefault(_path);
20-
21-
var _fs = require('fs');
22-
23-
var _fs2 = _interopRequireDefault(_fs);
24-
25-
var _child_process = require('child_process');
26-
27-
var _child_process2 = _interopRequireDefault(_child_process);
28-
29-
var _childprocessPromise = require('childprocess-promise');
30-
31-
var _childprocessPromise2 = _interopRequireDefault(_childprocessPromise);
32-
33-
var _atomLinter = require('atom-linter');
34-
35-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
36-
37-
function spawnWorker() {
9+
export function spawnWorker() {
3810
let shouldLive = true;
3911
const env = Object.create(process.env);
4012
delete env.NODE_PATH;
4113
delete env.NODE_ENV;
4214
const data = { stdout: [], stderr: [] };
43-
const child = _child_process2.default.fork(__dirname + '/worker.js', [], { env: env, silent: true });
44-
const worker = new _childprocessPromise2.default(child);
15+
const child = ChildProcess.fork(__dirname + '/worker.js', [], { env, silent: true });
16+
const worker = new CP(child);
4517
function killer() {
4618
shouldLive = false;
4719
child.kill();
@@ -60,23 +32,23 @@ function spawnWorker() {
6032
child.emit('exit-linter', shouldLive);
6133
});
6234
process.on('exit', killer);
63-
return { child: child, worker: worker, subscription: { dispose: function () {
35+
return { child, worker, subscription: { dispose: function () {
6436
killer();
6537
process.removeListener('exit', killer);
6638
} } };
6739
}
6840

69-
function getModulesDirectory(fileDir) {
70-
return (0, _atomLinter.findFile)(fileDir, 'node_modules');
41+
export function getModulesDirectory(fileDir) {
42+
return find(fileDir, 'node_modules');
7143
}
7244

73-
function getIgnoresFile(fileDir) {
74-
return _path2.default.dirname((0, _atomLinter.findFile)(fileDir, '.eslintignore'));
45+
export function getIgnoresFile(fileDir) {
46+
return Path.dirname(find(fileDir, '.eslintignore'));
7547
}
7648

77-
function getEslintFromDirectory(path) {
49+
export function getEslintFromDirectory(path) {
7850
try {
79-
return require(_path2.default.join(path, 'lib', 'cli.js'));
51+
return require(Path.join(path, 'lib', 'cli.js'));
8052
} catch (e) {
8153
if (e.code === 'MODULE_NOT_FOUND') {
8254
throw new Error('ESLint not found, Please install or make sure Atom is getting $PATH correctly');
@@ -86,11 +58,11 @@ function getEslintFromDirectory(path) {
8658

8759
let nodePrefixPath = null;
8860

89-
function getNodePrefixPath() {
61+
export function getNodePrefixPath() {
9062
if (nodePrefixPath === null) {
9163
const npmCommand = process.platform === 'win32' ? 'npm.cmd' : 'npm';
9264
try {
93-
nodePrefixPath = _child_process2.default.spawnSync(npmCommand, ['get', 'prefix']).output[1].toString().trim();
65+
nodePrefixPath = ChildProcess.spawnSync(npmCommand, ['get', 'prefix']).output[1].toString().trim();
9466
} catch (e) {
9567
throw new Error('Unable to execute `npm get prefix`. Please make sure Atom is getting $PATH correctly');
9668
}
@@ -100,41 +72,37 @@ function getNodePrefixPath() {
10072

10173
let bundledEslintDirectory = null;
10274

103-
function getBundledEslintDirectory() {
75+
export function getBundledEslintDirectory() {
10476
if (bundledEslintDirectory === null) {
105-
bundledEslintDirectory = _path2.default.normalize(_path2.default.join(__dirname, '..', 'node_modules', 'eslint'));
77+
bundledEslintDirectory = Path.normalize(Path.join(__dirname, '..', 'node_modules', 'eslint'));
10678
}
10779
return bundledEslintDirectory;
10880
}
10981

110-
function getEslintDirectory(params) {
111-
let modulesPath = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1];
112-
82+
export function getEslintDirectory(params, modulesPath = null) {
11383
if (params.global) {
11484
const prefixPath = getNodePrefixPath();
11585
if (process.platform === 'win32') {
116-
return _path2.default.join(params.nodePath || prefixPath, 'node_modules', 'eslint');
117-
} else {
118-
return _path2.default.join(params.nodePath || prefixPath, 'lib', 'node_modules', 'eslint');
119-
}
120-
} else {
121-
const eslintPath = _path2.default.join(modulesPath || getModulesDirectory(params.fileDir), 'eslint');
122-
try {
123-
_fs2.default.accessSync(eslintPath, _fs2.default.R_OK);
124-
return eslintPath;
125-
} catch (_) {
126-
return getBundledEslintDirectory();
86+
return Path.join(params.nodePath || prefixPath, 'node_modules', 'eslint');
12787
}
88+
return Path.join(params.nodePath || prefixPath, 'lib', 'node_modules', 'eslint');
89+
}
90+
const eslintPath = Path.join(modulesPath || getModulesDirectory(params.fileDir), 'eslint');
91+
try {
92+
FS.accessSync(eslintPath, FS.R_OK);
93+
return eslintPath;
94+
} catch (_) {
95+
return getBundledEslintDirectory();
12896
}
12997
}
13098

131-
function getEslintConfig(params) {
132-
const configFile = (0, _atomLinter.findFile)(params.fileDir, ['.eslintrc.js', '.eslintrc.yaml', '.eslintrc.yml', '.eslintrc.json', '.eslintrc']) || null;
99+
export function getEslintConfig(params) {
100+
const configFile = find(params.fileDir, ['.eslintrc.js', '.eslintrc.yaml', '.eslintrc.yml', '.eslintrc.json', '.eslintrc']) || null;
133101
if (configFile) {
134102
return configFile;
135103
}
136104

137-
const packagePath = (0, _atomLinter.findFile)(params.fileDir, 'package.json');
105+
const packagePath = find(params.fileDir, 'package.json');
138106
if (packagePath && Boolean(require(packagePath).eslintConfig)) {
139107
return packagePath;
140108
}
@@ -152,7 +120,7 @@ let eslint;
152120
let lastEslintDirectory;
153121
let lastModulesPath;
154122

155-
function getEslint(params) {
123+
export function getEslint(params) {
156124
const modulesPath = getModulesDirectory(params.fileDir);
157125
const eslintDirectory = getEslintDirectory(params, modulesPath);
158126
if (eslintDirectory !== lastEslintDirectory) {
@@ -166,5 +134,5 @@ function getEslint(params) {
166134
} else process.env.NODE_PATH = '';
167135
require('module').Module._initPaths();
168136
}
169-
return { eslint: eslint, eslintDirectory: eslintDirectory };
137+
return { eslint, eslintDirectory };
170138
}

lib/main.js

Lines changed: 25 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,11 @@
1-
'use strict';
21
'use babel';
32

4-
Object.defineProperty(exports, "__esModule", {
5-
value: true
6-
});
3+
import Path from 'path';
4+
import { CompositeDisposable } from 'atom';
5+
import { spawnWorker } from './helpers';
6+
import escapeHTML from 'escape-html';
77

8-
var _path = require('path');
9-
10-
var _path2 = _interopRequireDefault(_path);
11-
12-
var _atom = require('atom');
13-
14-
var _helpers = require('./helpers');
15-
16-
var _escapeHtml = require('escape-html');
17-
18-
var _escapeHtml2 = _interopRequireDefault(_escapeHtml);
19-
20-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21-
22-
exports.default = {
8+
export default {
239
config: {
2410
lintHtmlFiles: {
2511
title: 'Lint HTML Files',
@@ -68,38 +54,36 @@ exports.default = {
6854
}
6955
},
7056
activate: function () {
71-
var _this = this;
72-
7357
require('atom-package-deps').install();
7458

75-
this.subscriptions = new _atom.CompositeDisposable();
59+
this.subscriptions = new CompositeDisposable();
7660
this.active = true;
7761
this.worker = null;
7862
this.scopes = ['source.js', 'source.jsx', 'source.js.jsx', 'source.babel', 'source.js-semantic'];
7963

8064
const embeddedScope = 'source.js.embedded.html';
81-
this.subscriptions.add(atom.config.observe('linter-eslint.lintHtmlFiles', function (lintHtmlFiles) {
65+
this.subscriptions.add(atom.config.observe('linter-eslint.lintHtmlFiles', lintHtmlFiles => {
8266
if (lintHtmlFiles) {
83-
_this.scopes.push(embeddedScope);
67+
this.scopes.push(embeddedScope);
8468
} else {
85-
if (_this.scopes.indexOf(embeddedScope) !== -1) {
86-
_this.scopes.splice(_this.scopes.indexOf(embeddedScope), 1);
69+
if (this.scopes.indexOf(embeddedScope) !== -1) {
70+
this.scopes.splice(this.scopes.indexOf(embeddedScope), 1);
8771
}
8872
}
8973
}));
9074
this.subscriptions.add(atom.commands.add('atom-text-editor', {
91-
'linter-eslint:fix-file': function () {
75+
'linter-eslint:fix-file': () => {
9276
const textEditor = atom.workspace.getActiveTextEditor();
9377
const filePath = textEditor.getPath();
94-
const fileDir = _path2.default.dirname(filePath);
78+
const fileDir = Path.dirname(filePath);
9579

9680
if (!textEditor || textEditor.isModified()) {
9781
// Abort for invalid or unsaved text editors
9882
atom.notifications.addError('Linter-ESLint: Please save before fixing');
9983
return;
10084
}
10185

102-
_this.worker.request('FIX', {
86+
this.worker.request('FIX', {
10387
fileDir: fileDir,
10488
filePath: filePath,
10589
global: atom.config.get('linter-eslint.useGlobalEslint'),
@@ -113,18 +97,13 @@ exports.default = {
11397
}
11498
}));
11599

116-
const initializeWorker = function () {
117-
if (_this.active) {
118-
var _spawnWorker = (0, _helpers.spawnWorker)();
119-
120-
const child = _spawnWorker.child;
121-
const worker = _spawnWorker.worker;
122-
const subscription = _spawnWorker.subscription;
123-
124-
_this.worker = worker;
125-
_this.subscriptions.add(subscription);
126-
child.on('exit-linter', function (shouldLive) {
127-
_this.worker = null;
100+
const initializeWorker = () => {
101+
if (this.active) {
102+
const { child, worker, subscription } = spawnWorker();
103+
this.worker = worker;
104+
this.subscriptions.add(subscription);
105+
child.on('exit-linter', shouldLive => {
106+
this.worker = null;
128107
// Respawn if it crashed. See atom/electron#3446
129108
if (shouldLive) {
130109
initializeWorker();
@@ -139,24 +118,22 @@ exports.default = {
139118
this.subscriptions.dispose();
140119
},
141120
provideLinter: function () {
142-
var _this2 = this;
143-
144121
const Helpers = require('atom-linter');
145122
return {
146123
name: 'ESLint',
147124
grammarScopes: this.scopes,
148125
scope: 'file',
149126
lintOnFly: true,
150-
lint: function (textEditor) {
127+
lint: textEditor => {
151128
const text = textEditor.getText();
152129
if (text.length === 0) {
153130
return Promise.resolve([]);
154131
}
155132
const filePath = textEditor.getPath();
156-
const fileDir = _path2.default.dirname(filePath);
133+
const fileDir = Path.dirname(filePath);
157134
const showRule = atom.config.get('linter-eslint.showRuleIdInMessage');
158135

159-
return _this2.worker.request('JOB', {
136+
return this.worker.request('JOB', {
160137
fileDir: fileDir,
161138
filePath: filePath,
162139
contents: text,
@@ -170,13 +147,7 @@ exports.default = {
170147
if (response.length === 1 && response[0].message === 'File ignored because of your .eslintignore file. Use --no-ignore to override.') {
171148
return [];
172149
}
173-
return response.map(function (_ref) {
174-
let message = _ref.message;
175-
let line = _ref.line;
176-
let severity = _ref.severity;
177-
let ruleId = _ref.ruleId;
178-
let column = _ref.column;
179-
150+
return response.map(function ({ message, line, severity, ruleId, column }) {
180151
const range = Helpers.rangeFromLineNumber(textEditor, line - 1);
181152
if (column) {
182153
range[0][1] = column - 1;
@@ -190,7 +161,7 @@ exports.default = {
190161
range: range
191162
};
192163
if (showRule) {
193-
ret.html = `<span class="badge badge-flexible">${ ruleId || 'Fatal' }</span> ${ (0, _escapeHtml2.default)(message) }`;
164+
ret.html = `<span class="badge badge-flexible">${ ruleId || 'Fatal' }</span> ${ escapeHTML(message) }`;
194165
} else {
195166
ret.text = message;
196167
}

lib/reporter.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
'use strict'
1+
'use strict';
22
// This file is used by eslint to hand the errors over to the worker
3-
module.exports = function(results) {
4-
global.__LINTER_RESPONSE = results[0].messages
5-
}
3+
4+
module.exports = function (results) {
5+
global.__LINTER_RESPONSE = results[0].messages;
6+
};

0 commit comments

Comments
 (0)