Configuring Sass Lint for BEM - sass

So i'm moving to writing my sass to the BEM convention. I've used the sass-lint configuration generator to create my config and only edited the class-name-format's - convention: to strictbem however I'm still having some issues with it.
Maybe I'm misinterpreting BEM?
Error:
[sass-lint] Class '.bus__tyre--front' should be written in BEM (Block
Element Modifier) format (class-name-format)
<element class="bus__tyre--front">
Sass:
.bus {
position: relative;
&__tyre {
position: absolute;
&--front {
bottom: -22px;
right: 3%;
width: 17%;
}
}
}
sass-lint.yml:
# sass-lint config generated by make-sass-lint-config v0.1.2
#
# The following scss-lint Linters are not yet supported by sass-lint:
# DisableLinterReason, ElsePlacement, PropertyCount, SelectorDepth
# SpaceAroundOperator, TrailingWhitespace, UnnecessaryParentReference, Compass::*
#
# The following settings/values are unsupported by sass-lint:
# Linter Indentation, option "allow_non_nested_indentation"
# Linter Indentation, option "character"
# Linter NestingDepth, option "ignore_parent_selectors"
# Linter PropertySortOrder, option "min_properties"
# Linter PropertySortOrder, option "separate_groups"
# Linter SpaceBeforeBrace, option "allow_single_line_padding"
# Linter VendorPrefix, option "identifier_list"
files:
include: '**/*.scss'
options:
formatter: stylish
merge-default-rules: false
rules:
bem-depth:
- 0
- max-depth: 1
border-zero:
- 1
- convention: zero
brace-style:
- 1
- allow-single-line: true
class-name-format:
- 1
- convention: strictbem
clean-import-paths:
- 1
- filename-extension: false
leading-underscore: false
empty-line-between-blocks:
- 1
- ignore-single-line-rulesets: true
extends-before-declarations: 1
extends-before-mixins: 1
final-newline:
- 1
- include: true
force-attribute-nesting: 1
force-element-nesting: 1
force-pseudo-nesting: 1
function-name-format:
- 1
- allow-leading-underscore: true
convention: hyphenatedlowercase
hex-length:
- 1
- style: short
hex-notation:
- 1
- style: lowercase
id-name-format:
- 1
- convention: hyphenatedlowercase
indentation:
- 1
- size: 2
leading-zero:
- 1
- include: false
mixin-name-format:
- 1
- allow-leading-underscore: true
convention: hyphenatedlowercase
mixins-before-declarations: 1
nesting-depth:
- 1
- max-depth: 3
no-color-keywords: 1
no-color-literals: 1
no-css-comments: 1
no-debug: 1
no-duplicate-properties: 1
no-empty-rulesets: 1
no-extends: 0
no-ids: 1
no-important: 1
no-invalid-hex: 1
no-mergeable-selectors: 1
no-misspelled-properties:
- 1
- extra-properties: []
no-qualifying-elements:
- 1
- allow-element-with-attribute: false
allow-element-with-class: false
allow-element-with-id: false
no-trailing-zero: 1
no-transition-all: 0
no-url-protocols: 1
no-vendor-prefixes:
- 1
- additional-identifiers: []
excluded-identifiers: []
placeholder-in-extend: 1
placeholder-name-format:
- 1
- convention: hyphenatedlowercase
property-sort-order:
- 1
- ignore-custom-properties: false
property-units:
- 1
- global:
- ch
- em
- ex
- rem
- cm
- in
- mm
- pc
- pt
- px
- q
- vh
- vw
- vmin
- vmax
- deg
- grad
- rad
- turn
- ms
- s
- Hz
- kHz
- dpi
- dpcm
- dppx
- '%'
per-property: {}
quotes:
- 1
- style: single
shorthand-values:
- 1
- allowed-shorthands:
- 1
- 2
- 3
single-line-per-selector: 1
space-after-bang:
- 1
- include: false
space-after-colon:
- 1
- include: true
space-after-comma:
- 1
- include: true
space-before-bang:
- 1
- include: true
space-before-brace:
- 1
- include: true
space-before-colon: 1
space-between-parens:
- 1
- include: false
trailing-semicolon: 1
url-quotes: 1
variable-for-property:
- 0
- properties: []
variable-name-format:
- 1
- allow-leading-underscore: true
convention: hyphenatedlowercase
zero-unit: 1

Judging by #335 and #319 in the scss-lint repo, it looks like you need to change:
class-name-format:
- 1
- convention: strictbem
to:
class-name-format:
- 1
- convention: hyphenatedbem
I hope that helps!

Instead of hyphenated_BEM it should be hyphenatedbem.
Example from the sass-lint docs

Related

Hierarchical list of name value pairs in YAML

What's the best way to represent a hierarchical list of name value pairs like the following in YAML:
name_1: value_1
subName1_1: subValue1_1
subName1_2: subValue1_2
name_2: value_2
subName2_1: subValue2_1
subName2_2: subValue2_2
name_3: value_3
subName3_1: subValue3_1
subName3_2: subValue3_2
name_4: value_4
subName4_1: subValue4_1
subName4_2: subValue4_2
I am thinking of the following but not sure if this is the best way or not:
- name_1:
ID: 1
subNames:
- subName1_1:
ID: 1
- subName1_2:
ID: 2
- name_2:
ID: 2
subNames:
- subName2_1:
ID: 1
- subName2_2:
ID: 2
or I could also do:
- Name: Name_1
ID: 1
SubNames:
- SubName: subName1_1
ID: 1
- SubName: subName1_2
ID: 2
- Name: Name_2
ID: 2
SubNames:
- SubName: subName2_1
ID: 1
- SubName: subName2_2
ID: 2
I need the name_* to be unique as well as their corresponding values as well so I'd prefer something which python can easily consume to validate there are no duplicates.
Well there's the value key type. It's not part of the standard and defined for YAML 1.1, but it has been designed to solve this problem. It suggests you basically have a value in your mapping named = which contains the default value:
name_1:
=: value_1
subName1_1: subValue1_1
subName1_2: subValue1_2
name_2:
=: value_2
subName2_1: subValue2_1
subName2_2: subValue2_2
name_3:
=: value_3
subName3_1: subValue3_1
subName3_2: subValue3_2
name_4:
=: value_4
subName4_1: subValue4_1
subName4_2: subValue4_2
Alternatively, you could make the values a list with single key_value pairs:
name_1:
- value_1
- subName1_1: subValue1_1
- subName1_2: subValue1_2
name_2:
- value_2
- subName2_1: subValue2_1
- subName2_2: subValue2_2
name_3:
- value_3
- subName3_1: subValue3_1
- subName3_2: subValue3_2
name_4:
- value_4
- subName4_1: subValue4_1
- subName4_2: subValue4_2
You can write this with flow sequences since YAML allows flow sequences to contain single key-value pairs which will be interpreted as implicit mappings:
name_1: [value_1,
subName1_1: subValue1_1,
subName1_2: subValue1_2]
name_2: [value_2,
subName2_1: subValue2_1,
subName2_2: subValue2_2]
name_3: [value_3,
subName3_1: subValue3_1,
subName3_2: subValue3_2]
name_4: [value_4,
subName4_1: subValue4_1,
subName4_2: subValue4_2]
Be aware that when you do this, you can't have any kind of block-style nodes in the subnames, but other flow nodes will be fine.

ruamel - block_seq_indent and indent

I have been struggling with getting my YAML file with correct indentation after using yaml.round_trip_dump. I am trying to figure what is the difference between block_seq_indent and indent. Couldn't really find anything useful in the documentation as well.
indent is the normal indent that ruamel.yaml inherited from PyYAML. It affects both mapping keys and sequences elements. For sequences that means it doesn't affect the hash ('-') before a sequence element.
So if you run:
import sys
import ruamel.yaml
d = dict(a=1, b=[1, 2, {3: [3.1, 3.2, 3.3]}], c=dict(d=1, e=2))
ruamel.yaml.safe_dump(d, sys.stdout, default_flow_style=False, explicit_start=True)
ruamel.yaml.safe_dump(d, sys.stdout, default_flow_style=False, indent=4, explicit_start=True)
The output will be:
---
a: 1
b:
- 1
- 2
- 3:
- 3.1
- 3.2
- 3.3
c:
d: 1
e: 2
---
a: 1
b:
- 1
- 2
- 3:
- 3.1
- 3.2
- 3.3
c:
d: 1
e: 2
If you also provide block_seq_indent you can do:
ruamel.yaml.safe_dump(d, sys.stdout, default_flow_style=False, indent=4,
block_seq_indent=3, explicit_start=True)
to get:
a: 1
b:
- 1
- 2
- 3:
- 3.1
- 3.2
- 3.3
c:
d: 1
e: 2
To have even more control you should use the new ruamel.yaml API where you can do:
yaml = ruamel.yaml.YAML()
yaml.indent(mapping=3, sequence=5, offset=2)
yaml.explicit_start = True
yaml.dump(d, sys.stdout)
to get:
a: 1
b:
- 1
- 2
- 3:
- 3.1
- 3.2
- 3.3
c:
d: 1
e: 2
i.e. you can use offset to position the dash within the spaces that are the indent for the sequence elements.
This is documented here

YAML parsing - c++

I'm very new to YAML and what to parse a file I have made and verified is of correct structure. Here is the YAML:
---
DocType: DAQ Configuration File
# Creation Date: Wed Sep 21 10:34:06 2016
File Settings:
- Configuration Path: /mnt/sigma/daqengine/config/
- Configuration Name: daqengine.yaml
- Build File Path: ./bld
- Log File Path: ./log
- Record H5 Files: true
Engine Data:
- Make: EOS
- Model: M280
- Number of DAQs: 1
DAQ01 Settings:
- IP Address: 192.168.116.223
- Log DAQ Internal Temps: true
- T0 Temp. Limit: 55
- T0 Clear OTC Level Temp.: 50
- T0 Sample Averaging: 5
- T1 Temp. Limit: 60
- T1 Clear OTC Level Temp.: 55
- T1 Sample Averaging: 2
- No. Layers Used: 1
DAQ01 Layer 0 Settings:
- Model: AI-218
- Sample Rate: 50000
- Channels Used: 8
- Channel01: HF Temp
- Channel02: On-Axis PD
- Channel03: Off-Axis PD
- Channel04: X-Position
- Channel05: Y-Position
- Channel06: LDS
- Channel07: Laser Power
- Channel08: Unused
...
I need to extract the sequenced values to each key it is tagged to in C++.

Java: WebSocket server won't send data to client properly

Handshakes are done correctly and the server can decode the data coming from the client, but the client closes the connection when I try to send data to it.
I've been using http://websocket.org/echo.html as the client w. latest versions of Firefox & Chrome.
Here's the data frame I'm trying to send:
129 10000001
4 100
116 1110100
101 1100101
115 1110011
116 1110100
-------
fin:true
opcode:1
len:4
masked:false
masks:[0, 0, 0, 0]
payload:test
?♦test
http://tools.ietf.org/html/rfc6455#section-5
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-------+-+-------------+-------------------------------+
|F|R|R|R| opcode|M| Payload len | Extended payload length |
|I|S|S|S| (4) |A| (7) | (16/64) |
|N|V|V|V| |S| | (if payload len==126/127) |
| |1|2|3| |K| | |
+-+-+-+-+-------+-+-------------+ - - - - - - - - - - - - - - - +
| Extended payload length continued, if payload len == 127 |
+ - - - - - - - - - - - - - - - +-------------------------------+
| |Masking-key, if MASK set to 1 |
+-------------------------------+-------------------------------+
| Masking-key (continued) | Payload Data |
+-------------------------------- - - - - - - - - - - - - - - - +
: Payload Data continued ... :
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
| Payload Data continued ... |
+---------------------------------------------------------------+
*/
And the server side method responsible for sending data to the client:
public void sendData(Socket socket, byte[] dataBytes){
System.out.println(java.util.Arrays.toString(dataBytes));
//[-127, 4, 116, 101, 115, 116]
for(byte b:dataBytes) System.out.println(Integer.toString((int)0xff&b,2));
/*
10000001
100
1110100
1100101
1110011
1110100
*/
try{
InputStream data = new ByteArrayInputStream(dataBytes);
OutputStream out = socket.getOutputStream();
//tested with ByteArrayOutputStream and written data == dataBytes
//out.write((byte)0x00); //tried with and without this
if ( data != null )
{
// tried also out.write(dataBytes) intstead of this
byte[] buff = new byte[2048];
while (true)
{
int read = data.read( buff, 0, 2048 );
if (read <= 0)
break;
out.write( buff, 0, read );
}
}
//out.write(-1);
//out.write((byte)0xFF);
out.flush();
//out.close();
if ( data != null )
data.close();
}catch(Exception e){
e.printStackTrace();
sockets.remove(socket);
}
}
Some questions:
Do you wait for the connection to open fully before sending from the server?
Can you capture the stream using wireshark and see what's actually on the wire?
In Chrome's Javascript console do you see any WebSocket related errors?
In your onclose handler for the Javascript websocket object, can you console.log the values of code and reason from the event?
Like this:
ws.onclose = function (e) {
console.log("closed - code " + e.code + ", reason " + reason);
}
Your issue was (probably) using the old protocol. Use the newer one...
#see
http://web-sockets.org
Has working source for a client and server (in Java).

Ruby's YAML only loads first Records from a large File, why?

Okay, I have the following YAML file that was generated by using yaml_db for Rails. So this is basically an autogenerated export of my Rails database:
---
admins:
columns:
- id
- username
- email
- encrypted_password
- password_salt
- sign_in_count
- current_sign_in_at
- last_sign_in_at
- current_sign_in_ip
- last_sign_in_ip
- failed_attempts
- unlock_token
- locked_at
- created_at
- updated_at
records:
- - 1
-
- lalala#lalala.at
- $2a$10$dZU50HD6paWS7EjKuWAruOFdwt9eqxiNTRh/D4sj8cqSzy5gjYd2i
- $2a$10$dZU50HD6paWS7EjKuWAruO
- 86
- 2011-01-27 07:37:45 Z
- 2011-01-26 13:27:13 Z
- 12.34.56.78
- 12.34.56.78
- 0
-
-
- 2010-12-23 09:20:46 Z
- 2011-01-27 07:37:45 Z
- - 2
- admin
- lalalalala#lalalala.com
- $2a$10$3DML64hdCCvG90bnhIpN/unEEm6C.a9FqGrAFlFHU0.2D54DSQ1Ni
- $2a$10$3DML64hdCCvG90bnhIpN/u
- 1
- 2011-01-21 09:52:14 Z
- 2011-01-21 09:52:14 Z
- 12.34.56.78
- 12.34.56.78
- 0
-
-
- 2011-01-05 14:29:49 Z
- 2011-01-21 09:52:14 Z
---
experiments:
columns:
- id
- description
- startdate
- enddate
- maps_base_URI
- maps_count
- queries_count
- proposals_count
- created_at
- updated_at
.......
Now when I try to load this YAML file in Ruby with:
file = YAML.load(File.open("data-2011-01-27.yml"))
It doesn't load more than the first admin, not even the experiments:
ruby-1.9.2-p0 > file.keys
=> ["admins"]
ruby-1.9.2-p0 > file["admins"]["records"].count
=> 1
Why is that? I would assume that the autogenerated .yml file is syntactically correct? When I run rake:db:dump and rake:db:load it works just fine.
Three hyphens (---) separate multiple documents. See YAML.load_stream to load them all:
documents = YAML.load_stream(open("data-2011-01-27.yml")).documents
documents.map(&:keys)
#=> [["admins"], ["experiments"]]

Resources