From 5ceec4031e04988baedb284bfaa2ef8a7f1a1a47 Mon Sep 17 00:00:00 2001 From: Aileen Santos Date: Tue, 25 Apr 2017 10:06:48 -0700 Subject: [PATCH] Add stylelinting to ensure `mapboxgl-` prefix on all classes (#4584) * Add stylelint CLI and Add mapbox class name rule in stylelintrc * # This is a combination of 3 commits. # This is the 1st commit message: Stylelint works for application # This is the commit message #2: WIP modify lint-css script in package.json # This is the commit message #3: Ammend warning for lint-css npm script * Stylelint implemented for application WIP modify lint-css script in package.json Ammend warning for lint-css npm script Add csscolorparser * Add lintx to script file * Took out lintx * Took out lintx * Resolve comments to 4584 PR * Resolve PR comments * Ignore stylelint in .flowconfig and remove true from scripts --- .flowconfig | 1 + .stylelintrc | 5 +++++ package.json | 4 +++- 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 .stylelintrc diff --git a/.flowconfig b/.flowconfig index 510c8f3349c..f6d0d168e55 100644 --- a/.flowconfig +++ b/.flowconfig @@ -2,6 +2,7 @@ .*/node_modules/jsonlint/.* .*/node_modules/jsonlint-lines-primitives/.* +.*node_modules.*/stylelint.* .*/node_modules/unflowify/.* .*/test/unit/style-spec/fixture/invalidjson.input.json diff --git a/.stylelintrc b/.stylelintrc new file mode 100644 index 00000000000..b6be878d702 --- /dev/null +++ b/.stylelintrc @@ -0,0 +1,5 @@ +{ + "rules": { + "selector-class-pattern": "mapboxgl-[a-z-]+" + } +} diff --git a/package.json b/package.json index b213f818992..e5b336143d8 100644 --- a/package.json +++ b/package.json @@ -71,6 +71,7 @@ "request": "^2.79.0", "sinon": "^2.1.0", "st": "^1.2.0", + "stylelint": "^7.10.1", "tap": "^10.3.0", "vinyl": "^2.0.1", "vinyl-fs": "^2.4.4", @@ -115,8 +116,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 'dist/mapbox-gl.css'", "open-changed-examples": "git diff --name-only mb-pages HEAD -- docs/_posts/examples/*.html | awk '{print \"http://127.0.0.1:4000/mapbox-gl-js/example/\" substr($0,33,length($0)-37)}' | xargs open", - "test": "run-s lint test-unit test-flow", + "test": "run-s lint lint-css test-unit test-flow", "test-suite": "run-s test-render test-query", "test-suite-clean": "find test/integration/*-tests -mindepth 2 -type d -not \\( -exec test -e \"{}/style.json\" \\; \\) -print | xargs -t rm -r", "test-unit": "tap --reporter dot --no-coverage test/unit",