Skip to content
This repository was archived by the owner on Jul 3, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
js/deps/
js/modules/inherits.js
55 changes: 55 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
extends:
- airbnb-base

globals:
debug: true
__SYSCALL: true
runtime: true

env:
es6: true
node: true

rules:
strict:
- 2
- 'global'
max-len:
- 1
-
code: 100
tabWidth: 2
ignoreComments: true
ignoreUrls: true
consistent-return: 0
no-underscore-dangle: 0
global-require: 0
import/no-extraneous-dependencies: 0
no-return-assign: 1
new-cap: 1
no-console: 0
wrap-iife:
- 2
- 'inside'
no-use-before-define:
- 2
-
functions: false
classes: true
no-param-reassign:
- 2
-
props: false

parserOptions:
ecmaVersion: 6
sourceType: 'script'
ecmaFeatures:
modules: false
defaultParams: true
classes: true
arrowFunctions: true
blockBindings: true
forOf: true
spread: true
templateStrings: true
32 changes: 32 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Contributing to runtime.js

First off, thanks for deciding to contribute! :+1:

## Got an issue?

* Make sure the issue isn't already reported by checking in [Issues](https://github.com/runtimejs/runtime/issues).
* Include the version of the kernel and JavaScript library in the issue description.
* Include a description of what happens and what the expected behavior is.

## Cool feature request?

* Make sure the feature isn't already requested by checking in [Issues](https://github.com/runtimejs/runtime/issues).
* Include good reasons for why you think it should be added and why it'd be a good feature.
* If possible, include resources (links, examples, etc.) for anyone planning to add the feature.

## Something to improve, add, or fix?

### Kernel change (C++)

Make sure that:
* the kernel is compilable by running `scons` (more information [here](https://github.com/runtimejs/runtime/wiki/Build)).
* the system can still boot up normally.
* the new/fixed/changed feature/bug works (of course, :smile:).

### Library change (JavaScript)

Make sure that:
* you run `npm run lint` at the root of repository (you'll also need to have installed dependencies beforehand with `npm install`) and get rid of any lint before commiting.
* the system can still boot up normally.
* the new/fixed/changed feature/bug works.
* the code is written in as much ES6 as possible and it conforms to the style guide found [here](https://github.com/airbnb/javascript) (with a [few exceptions](docs/code-style-exceptions.md)).
71 changes: 71 additions & 0 deletions docs/code-style-exceptions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Code Style Exceptions

The JavaScript code adheres to the style guide found [here](https://github.com/airbnb/javascript), but with some exceptions:

## No ES6 Modules

V8 support for native ES6 modules is under development, so for now use `require` like you would in Node.
All other ES6 features (classes, destructuring, default parameters, etc.) can be used freely.

## Using `for-of` and `for-in`

You're free to use `for-of` and `for-in` as necessary, however it's better to use `for (let value of object)` for values and `for (let key of Object.keys(object))` for keys.
You can still use `for-in`, just be sure you know [the catch](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...in#Iterating_over_own_properties_only) when using it.

## Using 'dangling' underscores

You *can* use 'dangling' underscores to denote a private member on an object or class.
Some APIs were written before this style was adopted which use underscores for private members and probably won't be changed for compatibility.
However, for any new APIs, it'd be preferred to use a [`Symbol`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol) instead, like:

```js
const somePrivateVarName = Symbol('somePrivateVarName');

class Demo {
constructor() {
this[somePrivateVarName] = 'my value';
}
getMyPrivateVar() {
return this[somePrivateVarName];
}
}
```

## Using `get` and `set`

You can (and should) use ES6 `get` and `set` in new APIs, it's already used in various runtime.js APIs.

## Assigning to functions parameters

You cannot reassign *functions parameters*, but you can assign to *properties of* function parameters.
```js
// yes
const demo = (myObject) => {
myObject.someProperty = 'my value';
// ...
}

// no
const demo = (myObject) => {
myObject = {
someProperty: 'my value'
};
// ...
}
```

## Wrapping an IIFE

The invocation should be *outside* the parentheses, not inside.

```js
// yes
(function() {
// ...
})();

// no
(function() {

}());
```
2 changes: 0 additions & 2 deletions js/.eslintignore

This file was deleted.

9 changes: 0 additions & 9 deletions js/.eslintrc

This file was deleted.

Loading