Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Commit c88ba98

Browse files
committed
New: First commit
0 parents  commit c88ba98

File tree

937 files changed

+163645
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

937 files changed

+163645
-0
lines changed

.eslintrc

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
env:
2+
node: true
3+
4+
extends: eslint

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
build
2+
coverage
3+
node_modules
4+
npm-debug.log
5+
_test.js
6+

.travis.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
language: node_js
2+
sudo: false
3+
node_js:
4+
- "0.10"
5+
- "0.12"
6+
- 4
7+
after_success:
8+
- npm run coveralls

CHANGELOG.md

Whitespace-only changes.

CONTRIBUTING.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Contributing Code
2+
3+
Please sign our [Contributor License Agreement](http://eslint.org/cla)
4+
5+
# Full Documentation
6+
7+
Our full contribution guidelines can be found at:
8+
http://eslint.org/docs/developer-guide/contributing

LICENSE

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Redistribution and use in source and binary forms, with or without
2+
modification, are permitted provided that the following conditions are met:
3+
4+
* Redistributions of source code must retain the above copyright
5+
notice, this list of conditions and the following disclaimer.
6+
* Redistributions in binary form must reproduce the above copyright
7+
notice, this list of conditions and the following disclaimer in the
8+
documentation and/or other materials provided with the distribution.
9+
10+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
11+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
12+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
13+
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
14+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
15+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
16+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
17+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
18+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
19+
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Makefile.js

+286
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,286 @@
1+
/**
2+
* @fileoverview Build file
3+
* @author nzakas
4+
*/
5+
/*global cat, cp, echo, exec, exit, find, mkdir, mv, rm, target, test*/
6+
7+
"use strict";
8+
9+
/* eslint no-console: 0*/
10+
//------------------------------------------------------------------------------
11+
// Requirements
12+
//------------------------------------------------------------------------------
13+
14+
require("shelljs/make");
15+
16+
var checker = require("npm-license"),
17+
dateformat = require("dateformat"),
18+
nodeCLI = require("shelljs-nodecli"),
19+
semver = require("semver");
20+
21+
//------------------------------------------------------------------------------
22+
// Settings
23+
//------------------------------------------------------------------------------
24+
25+
var OPEN_SOURCE_LICENSES = [
26+
/MIT/, /BSD/, /Apache/, /ISC/, /WTF/, /Public Domain/
27+
];
28+
29+
//------------------------------------------------------------------------------
30+
// Data
31+
//------------------------------------------------------------------------------
32+
33+
var NODE_MODULES = "./node_modules/",
34+
TEMP_DIR = "./tmp/",
35+
BUILD_DIR = "./build/",
36+
37+
// Utilities - intentional extra space at the end of each string
38+
MOCHA = NODE_MODULES + "mocha/bin/_mocha ",
39+
40+
// Files
41+
MAKEFILE = "./Makefile.js",
42+
/*eslint-disable no-use-before-define */
43+
JS_FILES = find("lib/").filter(fileType("js")).join(" ") + " espree.js",
44+
TEST_FILES = find("tests/lib/").filter(fileType("js")).join(" ");
45+
/*eslint-enable no-use-before-define */
46+
47+
//------------------------------------------------------------------------------
48+
// Helpers
49+
//------------------------------------------------------------------------------
50+
51+
/**
52+
* Generates a function that matches files with a particular extension.
53+
* @param {string} extension The file extension (i.e. "js")
54+
* @returns {Function} The function to pass into a filter method.
55+
* @private
56+
*/
57+
function fileType(extension) {
58+
return function(filename) {
59+
return filename.substring(filename.lastIndexOf(".") + 1) === extension;
60+
};
61+
}
62+
63+
/**
64+
* Executes a command and returns the output instead of printing it to stdout.
65+
* @param {string} cmd The command string to execute.
66+
* @returns {string} The result of the executed command.
67+
*/
68+
function execSilent(cmd) {
69+
return exec(cmd, { silent: true }).output;
70+
}
71+
72+
/**
73+
* Creates a release version tag and pushes to origin.
74+
* @param {string} type The type of release to do (patch, minor, major)
75+
* @returns {void}
76+
*/
77+
function release(type) {
78+
var newVersion;
79+
80+
target.test();
81+
newVersion = execSilent("npm version " + type).trim();
82+
target.changelog();
83+
84+
// add changelog to commit
85+
exec("git add CHANGELOG.md");
86+
exec("git commit --amend --no-edit");
87+
88+
// replace existing tag
89+
exec("git tag -f " + newVersion);
90+
91+
// push all the things
92+
exec("git push origin master --tags");
93+
exec("npm publish");
94+
}
95+
96+
97+
/**
98+
* Splits a command result to separate lines.
99+
* @param {string} result The command result string.
100+
* @returns {array} The separated lines.
101+
*/
102+
function splitCommandResultToLines(result) {
103+
return result.trim().split("\n");
104+
}
105+
106+
function getVersionTags() {
107+
var tags = splitCommandResultToLines(exec("git tag", { silent: true }).output);
108+
109+
return tags.reduce(function(list, tag) {
110+
if (semver.valid(tag)) {
111+
list.push(tag);
112+
}
113+
return list;
114+
}, []).sort(semver.compare);
115+
}
116+
117+
//------------------------------------------------------------------------------
118+
// Tasks
119+
//------------------------------------------------------------------------------
120+
121+
target.all = function() {
122+
target.test();
123+
};
124+
125+
target.lint = function() {
126+
var errors = 0,
127+
lastReturn;
128+
129+
echo("Validating Makefile.js");
130+
lastReturn = nodeCLI.exec("eslint", MAKEFILE);
131+
if (lastReturn.code !== 0) {
132+
errors++;
133+
}
134+
135+
echo("Validating JavaScript files");
136+
lastReturn = nodeCLI.exec("eslint", JS_FILES);
137+
if (lastReturn.code !== 0) {
138+
errors++;
139+
}
140+
141+
echo("Validating JavaScript test files");
142+
lastReturn = nodeCLI.exec("eslint", TEST_FILES);
143+
if (lastReturn.code !== 0) {
144+
errors++;
145+
}
146+
147+
if (errors) {
148+
exit(1);
149+
}
150+
};
151+
152+
target.test = function() {
153+
// target.lint();
154+
155+
var errors = 0,
156+
lastReturn;
157+
158+
lastReturn = nodeCLI.exec("istanbul", "cover", MOCHA, "-- -c", TEST_FILES);
159+
160+
if (lastReturn.code !== 0) {
161+
errors++;
162+
}
163+
164+
if (errors) {
165+
exit(1);
166+
}
167+
168+
// target.checkLicenses();
169+
};
170+
171+
target.docs = function() {
172+
echo("Generating documentation");
173+
nodeCLI.exec("jsdoc", "-d jsdoc lib");
174+
echo("Documentation has been output to /jsdoc");
175+
};
176+
177+
target.browserify = function() {
178+
179+
// 1. create temp and build directory
180+
if (!test("-d", TEMP_DIR)) {
181+
mkdir(TEMP_DIR);
182+
mkdir(TEMP_DIR + "/lib");
183+
}
184+
185+
if (!test("-d", BUILD_DIR)) {
186+
mkdir(BUILD_DIR);
187+
}
188+
189+
// 2. copy files into temp directory
190+
cp("-r", "lib/*", TEMP_DIR + "/lib");
191+
cp("espree.js", TEMP_DIR);
192+
cp("package.json", TEMP_DIR);
193+
194+
195+
// 3. browserify the temp directory
196+
nodeCLI.exec("browserify", TEMP_DIR + "espree.js", "-o", BUILD_DIR + "espree.js", "-s espree");
197+
198+
// 4. remove temp directory
199+
rm("-r", TEMP_DIR);
200+
};
201+
202+
target.changelog = function() {
203+
204+
// get most recent two tags
205+
var tags = getVersionTags(),
206+
rangeTags = tags.slice(tags.length - 2),
207+
now = new Date(),
208+
timestamp = dateformat(now, "mmmm d, yyyy");
209+
210+
// output header
211+
(rangeTags[1] + " - " + timestamp + "\n").to("CHANGELOG.tmp");
212+
213+
// get log statements
214+
var logs = exec("git log --pretty=format:\"* %s (%an)\" " + rangeTags.join(".."), {silent: true}).output.split(/\n/g);
215+
logs = logs.filter(function(line) {
216+
return line.indexOf("Merge pull request") === -1 && line.indexOf("Merge branch") === -1;
217+
});
218+
logs.push(""); // to create empty lines
219+
logs.unshift("");
220+
221+
// output log statements
222+
logs.join("\n").toEnd("CHANGELOG.tmp");
223+
224+
// switch-o change-o
225+
cat("CHANGELOG.tmp", "CHANGELOG.md").to("CHANGELOG.md.tmp");
226+
rm("CHANGELOG.tmp");
227+
rm("CHANGELOG.md");
228+
mv("CHANGELOG.md.tmp", "CHANGELOG.md");
229+
};
230+
231+
target.checkLicenses = function() {
232+
233+
function isPermissible(dependency) {
234+
var licenses = dependency.licenses;
235+
236+
if (Array.isArray(licenses)) {
237+
return licenses.some(function(license) {
238+
return isPermissible({
239+
name: dependency.name,
240+
licenses: license
241+
});
242+
});
243+
}
244+
245+
return OPEN_SOURCE_LICENSES.some(function(license) {
246+
return license.test(licenses);
247+
});
248+
}
249+
250+
echo("Validating licenses");
251+
252+
checker.init({
253+
start: __dirname
254+
}, function(deps) {
255+
var impermissible = Object.keys(deps).map(function(dependency) {
256+
return {
257+
name: dependency,
258+
licenses: deps[dependency].licenses
259+
};
260+
}).filter(function(dependency) {
261+
return !isPermissible(dependency);
262+
});
263+
264+
if (impermissible.length) {
265+
impermissible.forEach(function (dependency) {
266+
console.error("%s license for %s is impermissible.",
267+
dependency.licenses,
268+
dependency.name
269+
);
270+
});
271+
exit(1);
272+
}
273+
});
274+
};
275+
276+
target.patch = function() {
277+
release("patch");
278+
};
279+
280+
target.minor = function() {
281+
release("minor");
282+
};
283+
284+
target.major = function() {
285+
release("major");
286+
};

README.md

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# TypeScript ESLint Parser (Experimental)
2+
3+
An parser that converts TypeScript into an [ESTree](https://github.com/estree/estree)-compatible form so it can be used in ESLint.
4+
5+
**Important:** This parser is still in the very early stages and is considered experimental. There are likely a lot of bugs. You should not rely on this in a production environment yet.
6+
7+
## Usage
8+
9+
Install:
10+
11+
```
12+
npm i typescript-eslint-parser --save
13+
```
14+
15+
And in your ESLint configuration file:
16+
17+
```
18+
"parser": "typescript-eslint-parser"
19+
```
20+
21+
## Help Wanted!
22+
23+
If you're familiar with TypeScript and ESLint, and you'd like to see this project progress, please consider contributing. We need people with a good knowledge of TypeScript to ensure this parser is useful.
24+
25+
## Contributing
26+
27+
Issues and pull requests will be triaged and responded to as quickly as possible. We operate under the [ESLint Contributor Guidelines](http://eslint.org/docs/developer-guide/contributing), so please be sure to read them before contributing. If you're not sure where to dig in, check out the [issues](https://github.com/eslint/typescript-eslint-parser/issues).
28+
29+
TypeScript ESLint Parser is licensed under a permissive BSD 2-clause license.
30+
31+
## Build Commands
32+
33+
* `npm test` - run all linting and tests
34+
* `npm run lint` - run all linting
35+
36+
## Development Plan
37+
38+
* **Phase 1:** Full ES6 support, stripping out all TypeScript-specific syntax.
39+
* **Phase 2:** Add JSX support.
40+
* **Phase 3:** Add support for top-level TypeScript syntax.
41+
* **Phase 4:** Add support for types.

0 commit comments

Comments
 (0)