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

Add stylelint CLI and Add mapbox class name rule in stylelintrc #4584

Merged
merged 9 commits into from
Apr 25, 2017

Conversation

ai-santos
Copy link
Contributor

Launch Checklist

  • added stylelint as a dev dependency

  • added npm script lint-css

  • added rule in stylelintrc to make sure all selectors begin with mapbox

  • tested npm script in CLI to make sure it works

  • amended npm warning by adding || true to the script

  • briefly describe the changes in this PR

# This is the 1st commit message:
Stylelint works for application

# This is the commit message mapbox#2:

WIP modify lint-css script in package.json

# This is the commit message mapbox#3:

Ammend warning for lint-css npm script
WIP modify lint-css script in package.json

Ammend warning for lint-css npm script

Add csscolorparser
@ai-santos
Copy link
Contributor Author

@anandthakker - the Circle CI tests are failing but not for my PR issue.

Copy link
Contributor

@mollymerp mollymerp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for contributing to Mapbox GL JS @asantos3026!

The CI tests appear to be failing due to a missing flow type within the stylelint module. We do want to make sure that all css classes in dist/mapbox-gl.css are prefixed with mapboxgl-, am hesitant to add three new dependencies to solve this gap in coverage.

@@ -1,6 +1,7 @@
'use strict';

mapboxgl.accessToken = getAccessToken();
require('dotenv').config()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what was the reason for adding this change?

Copy link
Contributor Author

@ai-santos ai-santos Apr 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to access the mapbox API via a .env file that would include my keys. I realize I do not need to do that because I use the command line to get access to the API. I deleted line 4 above.

.stylelintrc Outdated
{
"rules": {
"selector-class-pattern": "mapbox[a-z-]+",
"color-hex-case": "lower",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we need the color rules. we rarely change dist/mapbox-gl.css and we don't deal with much color in there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took out the color rules

package.json Outdated
@@ -18,6 +18,7 @@
"@mapbox/whoots-js": "^3.0.0",
"brfs": "^1.4.0",
"bubleify": "^0.7.0",
"dotenv": "^4.0.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think we need this dependency

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

took out the dotenv dependency

package.json Outdated
@@ -45,6 +46,7 @@
"clipboard": "^1.5.12",
"concat-stream": "^1.6.0",
"coveralls": "^2.11.8",
"csscolorparser": "^1.0.3",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can do without this dependency too

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

took out this dependency

package.json Outdated
@@ -115,8 +118,9 @@
"start-docs": "npm run build-min && npm run build-docs && jekyll serve --watch",
"lint": "eslint --cache --ignore-path .gitignore src test bench docs/_posts/examples/*.html debug/*.html",
"lint-docs": "documentation lint src/index.js",
"lint-css": "stylelint 'docs/*.css' || true",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should be pointing the linter at dist/mapbox-gl.css and not the docs/ css files. We only enforce the mapboxgl- prefex for css classes that ship with the library distribution. The CSS in the docs/ folder is only for the mapbox documentation website - www.mapbox.com/mapbox-gl-js/api
That change might also remove the need for the || true statement, although I'm not 100% clear on what that is doing in this case.

src/.env Outdated
@@ -0,0 +1 @@
MAPBOX_ACCESS_TOKEN=sk.eyJ1IjoiYXNhbnRvczMwMjYiLCJhIjoiY2oxY293bGk4MDA2NDMzcGRxNGdyc3lpbSJ9.uxcZ_o19abopWFm2vwstmg
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd like to avoid committing personal access tokens to the GitHub repo. Developers will need to use their own token with the library.

@mollymerp
Copy link
Contributor

Ah just saw your discussion w @anandthakker on #4584 👍 on adding stylelint but would like to avoid the other two dependencies in this PR. Thanks again!

closes #4584

@mollymerp
Copy link
Contributor

In order to get CI to pass based on I think you'll need to add a line ignoring stylelint in the .flowconfig file based on stylelint/stylelint#2322 (comment)

package.json Outdated
@@ -115,14 +116,15 @@
"start-docs": "npm run build-min && npm run build-docs && jekyll serve --watch",
"lint": "eslint --cache --ignore-path .gitignore src test bench docs/_posts/examples/*.html debug/*.html",
"lint-docs": "documentation lint src/index.js",
"lint-css": "stylelint 'dist/mapbox-gl.css' || true",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we remove the || true statements from here and the test-flow command – I'm afraid they will prevent the tests from failing if there are errors.

@ai-santos
Copy link
Contributor Author

@mollymerp Hey Molly! I made all of the following changes:

  • removed true statement from test-flow and stylelint scripts
  • added stylelint to be ignored in the .flowconfig file

Let me know if there is anything else I need to do to clean up my PR 👍

@mollymerp
Copy link
Contributor

great! thank you so much @asantos3026!!

@mollymerp mollymerp merged commit 5ceec40 into mapbox:master Apr 25, 2017
This was referenced Apr 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants