Skip to content

Commit

Permalink
Custom linter to check code quality (#2753)
Browse files Browse the repository at this point in the history
  • Loading branch information
scottnonnenberg-signal committed Sep 20, 2018
1 parent 366401f commit ecb126e
Show file tree
Hide file tree
Showing 13 changed files with 7,467 additions and 66 deletions.
2 changes: 2 additions & 0 deletions .prettierignore
Expand Up @@ -16,8 +16,10 @@ ts/**/*.js
ts/protobuf/*.d.ts
ts/protobuf/*.js
stylesheets/manifest.css
ts/util/lint/exceptions.json

# Third-party files
node_modules/**
components/**
js/Mp3LameEncoder.min.js
js/WebAudioRecorderMp3.js
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -9,6 +9,7 @@ install:
script:
- yarn generate
- yarn lint
- yarn lint-deps
- yarn test-node
- yarn nsp check
- yarn prepare-beta-build
Expand Down
2 changes: 2 additions & 0 deletions Gruntfile.js
Expand Up @@ -7,6 +7,7 @@ const spectron = require('spectron');
const asar = require('asar');
const fs = require('fs');
const assert = require('assert');
const sass = require('node-sass');

/* eslint-disable more/no-then, no-console */

Expand Down Expand Up @@ -98,6 +99,7 @@ module.exports = grunt => {
},
sass: {
options: {
implementation: sass,
sourceMap: true,
importer: importOnce,
},
Expand Down
1 change: 1 addition & 0 deletions appveyor.yml
Expand Up @@ -14,6 +14,7 @@ install:
build_script:
- yarn generate
- yarn lint-windows
- yarn lint-deps
- yarn test-node
- yarn nsp check
- node build\grunt.js
Expand Down
7 changes: 5 additions & 2 deletions package.json
Expand Up @@ -32,6 +32,7 @@
"eslint": "eslint .",
"lint": "yarn format --list-different && yarn lint-windows",
"lint-windows": "yarn eslint && yarn tslint",
"lint-deps": "node ts/util/lint/linter.js",
"tslint": "tslint --format stylish --project .",
"format": "prettier --write \"*.{css,js,json,md,scss,ts,tsx}\" \"./**/*.{css,js,json,md,scss,ts,tsx}\"",
"transpile": "tsc",
Expand Down Expand Up @@ -73,9 +74,11 @@
"moment": "^2.21.0",
"mustache": "^2.3.0",
"node-fetch": "https://github.com/scottnonnenberg-signal/node-fetch.git#3e5f51e08c647ee5f20c43b15cf2d352d61c36b4",
"node-gyp": "^3.8.0",
"node-sass": "^4.9.3",
"os-locale": "^2.1.0",
"pify": "^3.0.0",
"protobufjs": "^6.8.6",
"protobufjs": "~6.8.6",
"proxy-agent": "^2.1.0",
"react": "^16.2.0",
"react-contextmenu": "^2.9.2",
Expand Down Expand Up @@ -126,7 +129,7 @@
"grunt-contrib-watch": "^1.0.0",
"grunt-exec": "^3.0.0",
"grunt-gitinfo": "^0.1.7",
"grunt-sass": "^2.0.0",
"grunt-sass": "^3.0.1",
"mocha": "^4.1.0",
"mocha-testcheck": "^1.0.0-rc.0",
"node-sass-import-once": "^1.2.0",
Expand Down
29 changes: 29 additions & 0 deletions ts/util/lint/analyze_exceptions.ts
@@ -0,0 +1,29 @@
// tslint:disable no-console

import { join } from 'path';

import { fromPairs, groupBy, map } from 'lodash';

import { ExceptionType } from './types';
import { loadJSON } from './util';

const exceptionsPath = join(__dirname, 'exceptions.json');
const exceptions: Array<ExceptionType> = loadJSON(exceptionsPath);
const byRule = groupBy(exceptions, 'rule');

const byRuleThenByCategory = fromPairs(
map(byRule, (list, ruleName) => {
const byCategory = groupBy(list, 'reasonCategory');

return [
ruleName,
fromPairs(
map(byCategory, (innerList, categoryName) => {
return [categoryName, innerList.length];
})
),
];
})
);

console.log(JSON.stringify(byRuleThenByCategory, null, ' '));

0 comments on commit ecb126e

Please sign in to comment.