Skip to content

Commit

Permalink
Refine and add new rules to eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
julienw committed Jun 29, 2017
1 parent 8908ace commit b0af43a
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 5 deletions.
45 changes: 43 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ module.exports = {
"eslint:recommended",
"plugin:react/recommended",
"plugin:flowtype/recommended",
"plugin:react/recommended",
"prettier",
"prettier/flowtype",
"prettier/react"
],
"parserOptions": {
"ecmaVersion": "2017",
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
"jsx": true
Expand All @@ -32,7 +32,48 @@ module.exports = {
"import/no-duplicates": "error",
"import/no-unresolved": "error",
"import/named": "error",
"prettier/prettier": ["error", { singleQuote: true, trailingComma: "es5" }]
"prettier/prettier": ["error", { singleQuote: true, trailingComma: "es5" }],

"flowtype/no-types-missing-file-annotation": "off", // wait for https://github.com/gajus/eslint-plugin-flowtype/issues/248

// overriding recommended rules
"no-constant-condition": ["error", { checkLoops: false }],
"no-console": [ "error", { allow: ["log", "warn", "error"] } ],

// possible errors
"array-callback-return": "error",
"consistent-return": "error",
// "default-case": "error", // to be enabled after fixing issues in our code
"dot-notation": "error",
"eqeqeq": "error",
// "for-direction": "error", // to be enabled after we upgrade eslint
"no-alert": "error",
"no-caller": "error",
"no-eval": "error",
"no-extend-native": "error",
"no-extra-bind": "error",
"no-extra-label": "error",
"no-implied-eval": "error",
"no-invalid-this": "error",
"no-return-await": "error",
"no-self-compare": "error",
"no-throw-literal": "error",
"no-unmodified-loop-condition": "error",
// "no-unused-expression": "error", // to be enabled after we upgrade eslint
// "no-use-before-define": "error", // to be enabled after fixing issues in our code
"no-useless-call": "error",
"no-useless-computed-key": "error",
"no-useless-concat": "error",
"no-useless-constructor": "error",
"no-useless-rename": "error",
"no-useless-return": "error",
"no-var": "error",
"no-void": "error",
"no-with": "error",
"prefer-const": "error",
// "prefer-promise-reject-errors": "error", // to be enabled after fixing issues in our code
// "prefer-rest-params": "error", // to be enabled after fixing issues in our code
"prefer-spread": "error",
},
"settings": {
"react": {
Expand Down
2 changes: 2 additions & 0 deletions src/profile-logic/gecko-profile-versioning.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ function _archFromAbi(abi) {

// _upgraders[i] converts from version i - 1 to version i.
// Every "upgrader" takes the profile as its single argument and mutates it.
/* eslint-disable no-useless-computed-key */
const _upgraders = {
[1]: () => {
throw new Error(
Expand Down Expand Up @@ -184,3 +185,4 @@ const _upgraders = {
convertToVersionSixRecursive(profile);
},
};
/* eslint-enable no-useless-computed-key */
2 changes: 2 additions & 0 deletions src/profile-logic/processed-profile-versioning.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ function _getRealScriptURI(url) {

// _upgraders[i] converts from version i - 1 to version i.
// Every "upgrader" takes the profile as its single argument and mutates it.
/* eslint-disable no-useless-computed-key */
const _upgraders = {
[1]: profile => {
// Starting with version 1, markers are sorted.
Expand Down Expand Up @@ -276,3 +277,4 @@ const _upgraders = {
}
},
};
/* eslint-enable no-useless-computed-key */
2 changes: 1 addition & 1 deletion src/test/fixtures/mocks/canvas-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function mockCanvasContext() {
return jest.fn((...args) => {
log.push([name, ...args]);
if (fn) {
return fn.apply(null, args);
return fn(...args);
}
return undefined;
});
Expand Down
2 changes: 1 addition & 1 deletion src/test/store/fixtures/profiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function getProfileWithMarkers(markers: TestDefinedMarkers): Profile {
data: [],
length: 0,
};
markers.map(([name, time, data]) => {
markers.forEach(([name, time, data]) => {
markersTable.name.push(stringTable.indexForString(name));
markersTable.time.push(time);
markersTable.data.push(data);
Expand Down
2 changes: 1 addition & 1 deletion src/utils/uintarray-encoding.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

const encodingChars =
'0123456789abcdefghijklmnopqrstuv' + 'wxyzABCDEFGHIJKLMNOPQRSTUVWXYZ._';
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ._';

function uintToString(value) {
let x = value;
Expand Down

0 comments on commit b0af43a

Please sign in to comment.