-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Conversation
WIP modify lint-css script in package.json Ammend warning for lint-css npm script Add csscolorparser
f70a41a
to
ee56ee5
Compare
@anandthakker - the Circle CI tests are failing but not for my PR issue. |
There was a problem hiding this 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.
debug/access_token.js
Outdated
@@ -1,6 +1,7 @@ | |||
'use strict'; | |||
|
|||
mapboxgl.accessToken = getAccessToken(); | |||
require('dotenv').config() |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
Ah just saw your discussion w @anandthakker on #4584 👍 on adding closes #4584 |
In order to get CI to pass based on I think you'll need to add a line ignoring |
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", |
There was a problem hiding this comment.
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.
@mollymerp Hey Molly! I made all of the following changes:
Let me know if there is anything else I need to do to clean up my PR 👍 |
great! thank you so much @asantos3026!! |
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