Skip to content

Commit cb766b2

Browse files
author
Mike Taylor
authored
Merge pull request #2039 from webcompat/refactor
The BIG Refactor
2 parents 406bd20 + 2711abe commit cb766b2

File tree

312 files changed

+7067
-4850
lines changed

Some content is hidden

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

312 files changed

+7067
-4850
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ uploads/
1313
.vscode/
1414
config/secrets.py
1515
package-lock.json
16+
tmp/
1617

1718
# The data folder contains information that shouldn't live in version control.
1819
data/*
@@ -26,8 +27,7 @@ webcompat/static/js/issue-list.js
2627
webcompat/static/js/user-activity.js
2728
webcompat/static/js/templates.js
2829
webcompat/**/*.min.js
29-
webcompat/**/*.min.css
30-
webcompat/**/*.dev.css
30+
webcompat/**/**/*.min.css
3131

3232
#selenium server
3333
*.jar

.stylelintrc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"color-hex-length": "short",
99
"color-named": "never",
1010
"selector-no-qualifying-type": [ true, {"ignore": "attribute"} ],
11-
"selector-no-id": true,
12-
"selector-no-attribute": true,
11+
"selector-max-id": 1,
12+
"selector-max-attribute": 1,
1313
"selector-combinator-space-after": "always",
1414
"selector-attribute-quotes": "always",
1515
"selector-attribute-operator-space-before": "always",
@@ -23,7 +23,6 @@
2323
"value-no-vendor-prefix": true,
2424
"number-leading-zero": "never",
2525
"function-url-quotes": "always",
26-
"function-url-data-uris": "never",
2726
"font-weight-notation": "numeric",
2827
"font-family-name-quotes": "always-where-recommended",
2928
"comment-whitespace-inside": "always",
@@ -42,8 +41,8 @@
4241
"selector-pseudo-element-colon-notation": "double",
4342
"selector-pseudo-class-parentheses-space-inside": "never",
4443
"selector-no-vendor-prefix": true,
45-
"selector-no-universal": true,
46-
"selector-no-type": true,
44+
"selector-max-universal": 1,
45+
"selector-max-type": 1,
4746
"media-feature-range-operator-space-before": "always",
4847
"media-feature-range-operator-space-after": "always",
4948
"media-feature-parentheses-space-inside": "never",

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,4 @@ before_script:
5555
# now run the tests!
5656
script:
5757
- nosetests
58-
- node ./tests/functional/_intern.js reporters="runner"
58+
- npm run test:js -- --reporters="runner"

Gruntfile.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ module.exports = function(grunt) {
2929
"concat",
3030
"uglify",
3131
"postcss",
32-
"cssmin"
32+
"cssmin",
33+
"purifycss"
3334
]);
3435

3536
// Task used before doing a deploy (same as default, but does image optimization)

README.md

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,4 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
3535

3636
### Icons
3737

38-
All icons are public domain or licensed from The Noun Project.
39-
40-
[Lightbulb icon](http://thenounproject.com/term/light-bulb/5370/) designed by Jean-Philippe Cabaroc. (Licensed)
41-
42-
[Bee icon](http://thenounproject.com/term/bee/26569/) designed by Peter Silk. (Licensed)
43-
44-
[Arrow icon](http://thenounproject.com/term/arrow/5438/) designed by Jamison Wieser. (Licensed)
45-
46-
[Form icon](http://thenounproject.com/term/list/14362/) designed by banoshi. (Licensed)
47-
48-
[Diagnose bugs icon](https://thenounproject.com/rockicon/collection/office-line/?i=450639) designed by Rockicon (Licensed)
49-
50-
[Reach out to sites icon](https://thenounproject.com/term/heart-care/518087/) designed by ProSymbols. (Licensed)
51-
52-
[Lightswitch](http://thenounproject.com/term/light-switch/2235/) designed by Jeremy Lloyd. (Public domain)
53-
54-
[Contribute icon](https://thenounproject.com/search/?q=group&i=876004) designed by Tjaša Kimovec. (Licensed)
38+
All icons are from the [Feather icon set](https://github.com/feathericons/feather#feather) and published under the [MIT License](https://github.com/feathericons/feather/blob/master/LICENSE).

config/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ def convert_milestones(milestones_content):
124124
Category = namedtuple('Category', ['name', 'dataAttribute', 'label'])
125125
CATEGORIES = []
126126
cat_labels = [('needstriage', 'needstriage', 'Needs Triage'),
127-
('needsDiagnosis', 'needsdiagnosis', 'Needs Diagnosis'),
128-
('needsContact', 'needscontact', 'Needs Contact'),
127+
('needsdiagnosis', 'needsdiagnosis', 'Needs Diagnosis'),
128+
('needscontact', 'needscontact', 'Needs Contact'),
129129
('ready', 'contactready', 'Ready for Outreach'),
130130
('sitewait', 'sitewait', 'Site Contacted'),
131131
('close', 'closed', 'Closed')]

config/environment.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@
2525
# BUG STATUS
2626
# The id will be initialized when the app is started.
2727
STATUSES = {
28-
u'needstriage': {'id': 0, 'order': 1, 'state': 'open', 'color': '#ff9900'},
29-
u'needsdiagnosis': {'id': 0, 'order': 2, 'state': 'open', 'color': '#ff8364'},
30-
u'needscontact': {'id': 0, 'order': 3, 'state': 'open', 'color': '#e11d21'},
31-
u'contactready': {'id': 0, 'order': 4, 'state': 'open', 'color': '#a1ebbf'},
32-
u'sitewait': {'id': 0, 'order': 5, 'state': 'open', 'color': '#006b75'},
33-
u'duplicate': {'id': 0, 'order': 1, 'state': 'closed', 'color': '#cccccc'},
34-
u'fixed': {'id': 0, 'order': 2, 'state': 'closed', 'color': '#009800'},
35-
u'incomplete': {'id': 0, 'order': 3, 'state': 'closed', 'color': '#d93f0b'},
36-
u'invalid': {'id': 0, 'order': 4, 'state': 'closed', 'color': '#e6e6e6'},
37-
u'non-compat': {'id': 0, 'order': 5, 'state': 'closed', 'color': '#b60205'},
38-
u'wontfix': {'id': 0, 'order': 6, 'state': 'closed', 'color': '#000000'},
39-
u'worksforme': {'id': 0, 'order': 7, 'state': 'closed', 'color': '#d4c5f9'}
28+
u'needstriage': {'id': 0, 'order': 1, 'state': 'open'},
29+
u'needsdiagnosis': {'id': 0, 'order': 2, 'state': 'open'},
30+
u'needscontact': {'id': 0, 'order': 3, 'state': 'open'},
31+
u'contactready': {'id': 0, 'order': 4, 'state': 'open'},
32+
u'sitewait': {'id': 0, 'order': 5, 'state': 'open'},
33+
u'duplicate': {'id': 0, 'order': 1, 'state': 'closed'},
34+
u'fixed': {'id': 0, 'order': 2, 'state': 'closed'},
35+
u'incomplete': {'id': 0, 'order': 3, 'state': 'closed'},
36+
u'invalid': {'id': 0, 'order': 4, 'state': 'closed'},
37+
u'non-compat': {'id': 0, 'order': 5, 'state': 'closed'},
38+
u'wontfix': {'id': 0, 'order': 6, 'state': 'closed'},
39+
u'worksforme': {'id': 0, 'order': 7, 'state': 'closed'}
4040
}
4141

4242
# We don't need to compute for every requests.

docs/pr-coding-guidelines.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ In order to avoid errors during a Pull Request, `npm run lint` will be executed
159159
`npm run lint` checks all relevant JavaScript and CSS files and displays, if something needs to be fixed.
160160
161161
If you get an error displayed, there are two ways to fix it.
162-
1. You can run `npm run fix` automatically (only for JavaScript), which is great for small issues like missing spaces or lines in various files.
162+
1. You can run `npm run lint:fix` automatically, which is great for small issues like missing spaces or lines in various files.
163163
2. You can correct it manually as every error message includes the file and line of the error as well as the rule which was violated will be displayed..
164164
165165
Hopefully this will help you clear up a few struggles.

docs/tests.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,6 @@ npm run start:test
8080
In a separate terminal window or tab, run the tests:
8181

8282
```bash
83-
node_modules/.bin/intern-runner config=tests/intern
84-
85-
or
86-
8783
npm run test:js
8884
```
8985

@@ -97,18 +93,24 @@ Shortly after running this command, you should see the browser open and various
9793

9894
To run a single test suite, where foo.js is the file found in the `tests/functional` directory:
9995

96+
Note: the extra `--` is how you pass arguments to the npm script. Don't forget it!
97+
10098
```bash
101-
node_modules/.bin/intern-runner config=tests/intern functionalSuites=tests/functional/foo.js
99+
npm run test:js -- --functionalSuites=tests/functional/foo.js
102100
```
103101

104-
Right now the tests are running in Firefox as a default. You can specify which browsers you want to test with using the `browsers` argument. Like this:
102+
To filter which tests *within* a single test suite you run, you can use the `--grep` argument:
105103

106104
```bash
107-
npm run test:js browsers=chrome,firefox
105+
npm run test:js -- --functionalSuites=tests/functional/foo.js --grep=tacos
106+
```
107+
108+
This will run any test within the foo.js suite that has "tacos" in its name.
108109

109-
or
110+
Right now the tests are running in Firefox as a default. You can specify which browsers you want to test with using the `browsers` argument. Like this:
110111

111-
node_modules/.bin/intern-runner config=tests/intern browsers=safari,firefox
112+
```bash
113+
npm run test:js -- --browsers=chrome,firefox
112114
```
113115

114116
For a list of the recognized browser names, just refer to [Browser enum](http://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/index_exports_Browser.html)

grunt-tasks/cssmin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module.exports = function(grunt) {
1010
combine: {
1111
files: {
1212
// output
13-
"<%= cssPath %>/webcompat.min.css": [
13+
"<%= cssPath %>/dist/webcompat.min.css": [
1414
// input
1515
"<%= cssPath %>/webcompat.dev.css"
1616
]

grunt-tasks/cssnext.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module.exports = function(grunt) {
2323
},
2424
dist: {
2525
files: {
26-
"<%= cssPath %>/webcompat.dev.css": "<%= cssPath %>/development/main.css"
26+
"<%= cssPath %>/dist/webcompat.min.css": "<%= cssPath %>/webcompat.dev.css"
2727
}
2828
}
2929
});

grunt-tasks/purifycss.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
module.exports = function(grunt) {
6+
grunt.config("purifycss", {
7+
options: {
8+
rejected: true,
9+
info: true
10+
},
11+
target: {
12+
src: [
13+
"webcompat/templates/*.html",
14+
"webcompat/templates/**/*.html",
15+
"webcompat/templates/**/*.jst",
16+
"webcompat/static/js/*.js"
17+
],
18+
css: ["webcompat/static/css/*.css", "webcompat/static/css/src/*.css"],
19+
dest: "tmp/purestyles.css"
20+
}
21+
});
22+
};

grunt-tasks/watch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
module.exports = function(grunt) {
66
grunt.config("watch", {
77
css: {
8-
files: "<%= cssPath %>/development/**/*.css",
8+
files: "<%= cssPath %>/**/*.css",
99
tasks: ["postcss"]
1010
},
1111
templates: {

package.json

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
"cssrecipes-reset": "^0.5.0",
2222
"cssrecipes-utils": "^0.6.2",
2323
"suitcss-utils-align": "^1.0.0",
24-
"suitcss-utils-display": "^1.0.2"
24+
"suitcss-utils-display": "^1.0.2",
25+
"yargs": "^11.0.0"
2526
},
2627
"devDependencies": {
2728
"eslint": "~3.19.0",
@@ -37,6 +38,7 @@
3738
"grunt-contrib-uglify": "^2.3.0",
3839
"grunt-contrib-watch": "^1.0.0",
3940
"grunt-postcss": "^0.8.0",
41+
"grunt-purifycss": "^0.1.2",
4042
"husky": "^0.13.4",
4143
"intern": "^4.1.4",
4244
"lint-staged": "^3.6.1",
@@ -48,19 +50,26 @@
4850
"postcss-reporter": "^3.0.0",
4951
"postcss-url": "^5.1.2",
5052
"prettier": "1.1.0",
51-
"stylelint": "^7.13.0",
52-
"stylelint-config-standard": "^16.0.0"
53+
"stylelint": "^8.4.0",
54+
"stylelint-config-standard": "^18.0.0",
55+
"svg-sprite-generator": "0.0.7",
56+
"svgo": "^0.7.2"
5357
},
5458
"scripts": {
5559
"setup": "npm run virtualenv && npm install && npm run config",
60+
"clean:css": "grunt purifycss --min",
5661
"watch": "grunt watch",
5762
"build": "grunt",
63+
"build:svg": "npm run build:svg:clean-svg && npm run build:svg:svg-sprite && rm -rf ./webcompat/static/img/svg/tmp",
64+
"build:svg:clean-svg": "svgo -f ./webcompat/static/img/svg/icons -o ./webcompat/static/img/svg/tmp",
65+
"build:svg:svg-sprite": "svg-sprite-generate -d ./webcompat/static/img/svg/tmp -o ./webcompat/static/img/svg/sprite.svg",
5866
"jst": "grunt jst",
59-
"lint": "npm run lint:JS && npm run lint:CSS",
60-
"lint:JS": "eslint ./Gruntfile.js ./tests ./grunt-tasks ./webcompat/static/js/lib",
61-
"lint:CSS": "stylelint './webcompat/static/css/development/**/*.css'",
62-
"fix": "npm run lint:fix:JS",
63-
"lint:fix:JS": "eslint --fix ./Gruntfile.js ./tests ./grunt-tasks ./webcompat/static/js/lib",
67+
"lint": "npm run lint:js && npm run lint:css",
68+
"lint:js": "eslint ./Gruntfile.js ./tests ./grunt-tasks ./webcompat/static/js/lib",
69+
"lint:css": "stylelint './webcompat/static/css/src/**/*.css' './webcompat/static/css/webcompat.dev.css'",
70+
"lint:fix": "npm run lint:fix:js && npm run lint:fix:css",
71+
"lint:fix:js": "eslint --fix ./Gruntfile.js ./tests ./grunt-tasks ./webcompat/static/js/lib",
72+
"lint:fix:css": "stylelint './webcompat/static/css/src/**/*.css' './webcompat/static/css/webcompat.dev.css' --fix",
6473
"imagemin": "grunt imagemin",
6574
"prestart": "npm run build",
6675
"start": "source env/bin/activate || . env/bin/activate && python run.py",
@@ -75,8 +84,8 @@
7584
"test:python": "nosetests"
7685
},
7786
"lint-staged": {
78-
"*.js": "lint:JS",
79-
"*.css": "lint:CSS"
87+
"*.js": "lint:js",
88+
"*.css": "lint:css"
8089
},
8190
"license": "MPL-2.0"
8291
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"_fixture": true,
3+
"total_count": 0,
4+
"incomplete_results": false,
5+
"items": []
6+
}

0 commit comments

Comments
 (0)