Skip to content

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

Merged
mollymerp merged 9 commits into
mapbox:masterfrom
ai-santos:css-prefixes-stylelint
Apr 25, 2017
Merged

mollymerp merged 9 commits into
mapbox:masterfrom
ai-santos:css-prefixes-stylelint

Conversation

@ai-santos

Copy link
Copy Markdown
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
ai-santos force-pushed the css-prefixes-stylelint branch from f70a41a to ee56ee5 Compare April 13, 2017 00:36
@ai-santos

Copy link
Copy Markdown
Contributor Author

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

@mollymerp mollymerp left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread debug/access_token.js Outdated
'use strict';

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

Copy link
Copy Markdown
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?

@ai-santos ai-santos Apr 13, 2017 •

Copy link
Copy Markdown
Contributor Author

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.

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

Copy link
Copy Markdown
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
Copy Markdown
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

Comment thread package.json Outdated
"@mapbox/whoots-js": "^3.0.0",
"brfs": "^1.4.0",
"bubleify": "^0.7.0",
"dotenv": "^4.0.0",

Copy link
Copy Markdown
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
Copy Markdown
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

Comment thread package.json Outdated
"clipboard": "^1.5.12",
"concat-stream": "^1.6.0",
"coveralls": "^2.11.8",
"csscolorparser": "^1.0.3",

Copy link
Copy Markdown
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
Copy Markdown
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

Comment thread package.json Outdated
"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
Copy Markdown
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.

Comment thread src/.env Outdated
@@ -0,0 +1 @@
MAPBOX_ACCESS_TOKEN=sk.eyJ1IjoiYXNhbnRvczMwMjYiLCJhIjoiY2oxY293bGk4MDA2NDMzcGRxNGdyc3lpbSJ9.uxcZ_o19abopWFm2vwstmg No newline at end of file

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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)

Comment thread package.json Outdated
"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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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