Skip to content
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

(WIP) Add eslint config and test target, plus lint and bug fixes #57395

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ before_install:
install:
- case "$TRAVIS_OS_NAME" in
linux)
$HOME/.nvm/nvm.sh &&
nvm install stable &&
nvm use stable &&
npm install eslint;
travis_retry curl -fo $HOME/stamp https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/2017-03-17-stamp-x86_64-unknown-linux-musl &&
chmod +x $HOME/stamp &&
export PATH=$PATH:$HOME
Expand Down
4 changes: 4 additions & 0 deletions config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@
# target when running tests, otherwise this can be omitted.
#nodejs = "node"

# The eslint executable to use. Note that this is only used for linting js files
# during the test phase. It can be omitted.
#eslint = "eslint"

# Python interpreter to use for various tasks throughout the build, notably
# rustdoc tests, the lldb python interpreter, and some dist bits and pieces.
# Note that Python 2 is currently required.
Expand Down
3 changes: 3 additions & 0 deletions src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ pub struct Config {
pub libdir: Option<PathBuf>,
pub mandir: Option<PathBuf>,
pub codegen_tests: bool,
pub eslint: Option<PathBuf>,
pub nodejs: Option<PathBuf>,
pub gdb: Option<PathBuf>,
pub python: Option<PathBuf>,
Expand Down Expand Up @@ -202,6 +203,7 @@ struct Build {
gdb: Option<String>,
locked_deps: Option<bool>,
vendor: Option<bool>,
eslint: Option<String>,
nodejs: Option<String>,
python: Option<String>,
full_bootstrap: Option<bool>,
Expand Down Expand Up @@ -444,6 +446,7 @@ impl Config {
};


config.eslint = build.eslint.map(PathBuf::from);
config.nodejs = build.nodejs.map(PathBuf::from);
config.gdb = build.gdb.map(PathBuf::from);
config.python = build.python.map(PathBuf::from);
Expand Down
8 changes: 8 additions & 0 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,14 @@ impl Step for RustdocJS {
"No nodejs found, skipping \"src/test/rustdoc-js\" tests"
);
}

if let Some(ref eslint) = builder.config.eslint {
let mut command = Command::new(eslint);
command.args(&["src/librustdoc/html/static"]);
builder.run(&mut command);
} else {
builder.info("No eslint found, skipping js linting");
}
}
}

Expand Down
6 changes: 5 additions & 1 deletion src/librustdoc/html/static/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = {
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 2015,
"sourceType": "module"
"sourceType": "script"
},
"rules": {
"linebreak-style": [
Expand All @@ -16,6 +16,10 @@ module.exports = {
"semi": [
"error",
"always"
],
"no-constant-condition": [
"error",
{ "checkLoops": false }
]
}
};
Loading