File tree Expand file tree Collapse file tree 10 files changed +296
-164
lines changed
packages/stylelint-config Expand file tree Collapse file tree 10 files changed +296
-164
lines changed Original file line number Diff line number Diff line change 5656 - npm install --legacy-peer-deps
5757 - cd ../..
5858 script :
59- - npm test
59+ - npm run test:eslint
60+ - language : node_js
61+ node_js : 16
62+ install :
63+ - npm install
64+ - cd packages/stylelint-config
65+ - npm install
66+ - cd ../..
67+ script :
68+ - npm run test:stylelint
Original file line number Diff line number Diff line change 7878 "publish:dev" : " lerna publish --dist-tag next" ,
7979 "publish:legacy" : " lerna publish --dist-tag legacy" ,
8080 "publish:prod" : " lerna publish" ,
81- "test" : " npm run lint-pkg-json && npm run test:packages" ,
82- "test:packages" : " cd packages/eslint-config-humanmade && npm test"
81+ "test" : " npm run lint-pkg-json && npm run test:eslint && npm run test:stylelint" ,
82+ "test:eslint" : " cd packages/eslint-config-humanmade && npm test" ,
83+ "test:stylelint" : " cd packages/stylelint-config && npm test"
8384 }
8485}
Original file line number Diff line number Diff line change 1+ /* Bad BEM syntax */
2+ .foo__bar__foo ,
3+ .foo--bar--foo ,
4+ .foo--bar__foo {
5+ display : block;
6+ }
Original file line number Diff line number Diff line change 1+ // Max nesting depth.
2+ .element {
3+ display : block ;
4+
5+ .child-element {
6+ display : block ;
7+
8+ .child-element {
9+ display : block ;
10+
11+ .child-element {
12+ display : block ;
13+ }
14+ }
15+ }
16+ }
Original file line number Diff line number Diff line change 1+ .element {
2+ background : red;
3+ }
Original file line number Diff line number Diff line change 1+ /* No color-named */
2+ .element {
3+ background : # f00 ;
4+ }
5+
6+ /* Valid BEM syntax */
7+ .block__element ,
8+ .block__element--modifier ,
9+ .block--modifier {
10+ display : block;
11+ }
Original file line number Diff line number Diff line change 1+ // Max nesting depth.
2+ .element {
3+ display : block ;
4+
5+ // Nesting depth: 1
6+ .child-element {
7+ display : block ;
8+
9+ // Nesting depth: 2. Maximum allowed.
10+ .child-element {
11+ display : block ;
12+ }
13+
14+ // Allowed to be nested deeper because it's within a media query.
15+ @media screen {
16+ .child-element {
17+ display : block ;
18+ }
19+ }
20+ }
21+ }
Original file line number Diff line number Diff line change 1+ const stylelint = require ( 'stylelint' ) ;
2+ const chalk = require ( 'chalk' ) ;
3+ const path = require ( 'path' ) ;
4+
5+ stylelint . lint ( {
6+ files : 'fixtures/pass/**/*.{css,scss}'
7+ } ) . then ( ( resultObject ) => {
8+ if ( resultObject . errored ) {
9+ console . log ( chalk . bold . red ( 'Stylelint detected the following errors in the test files that are expected to pass.' ) ) ;
10+ resultObject . results . forEach ( result => {
11+ if ( ! result . errored ) {
12+ return ;
13+ }
14+
15+ console . log ( '• ' + path . relative ( process . cwd ( ) , result . source ) ) ;
16+ result . warnings . forEach ( result => {
17+ console . log ( ` • ${ result . text } . Line: ${ result . line } .` ) ;
18+ } ) ;
19+ } ) ;
20+ process . exitCode = 1 ;
21+ } else {
22+ console . log ( chalk . green ( 'No errors detected in files that are expected to pass.' ) ) ;
23+ }
24+ } ) ;
25+
26+ stylelint . lint ( {
27+ files : 'fixtures/fail/**/*.{css,scss}'
28+ } ) . then ( ( resultObject ) => {
29+ if ( ! resultObject . errored ) {
30+ console . log ( chalk . bold . red ( 'The following files did not produce errors:' ) ) ;
31+ resultObject . results . forEach ( result => {
32+ if ( result . errored ) {
33+ return ;
34+ }
35+
36+ console . log ( ' ' + result . source ) ;
37+ } ) ;
38+ process . exitCode = 1 ;
39+ } else {
40+ console . log ( chalk . green ( 'All files that should fail log errors as expected.' ) ) ;
41+ }
42+ } ) ;
You can’t perform that action at this time.
0 commit comments