Skip to content

Commit

Permalink
fix: add few more gremlins
Browse files Browse the repository at this point in the history
  • Loading branch information
sabhas committed Dec 27, 2022
1 parent f6ddfa8 commit 97e3490
Show file tree
Hide file tree
Showing 3 changed files with 316 additions and 70 deletions.
71 changes: 1 addition & 70 deletions src/rules/line/noGremlins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Diagnostic, LintConfig } from '../../types'
import { LineLintRule } from '../../types/LintRule'
import { LintRuleType } from '../../types/LintRuleType'
import { Severity } from '../../types/Severity'
import { gremlinCharacters } from '../../utils'

const name = 'noGremlins'
const description = 'Disallow characters specified in gremlins array'
Expand Down Expand Up @@ -56,73 +57,3 @@ export const noGremlins: LineLintRule = {
}

const charFromHex = (hexCode: string) => String.fromCodePoint(parseInt(hexCode))

const gremlinCharacters = {
'0x2013': {
description: 'en dash'
},
'0x2018': {
description: 'left single quotation mark'
},
'0x2019': {
description: 'right single quotation mark'
},
'0x2029': {
zeroWidth: true,
description: 'paragraph separator'
},
'0x2066': {
zeroWidth: true,
description: 'Left to right'
},
'0x2069': {
zeroWidth: true,
description: 'Pop directional'
},
'0x0003': {
description: 'end of text'
},
'0x000b': {
description: 'line tabulation'
},
'0x00a0': {
description: 'non breaking space'
},
'0x00ad': {
description: 'soft hyphen'
},
'0x200b': {
zeroWidth: true,
description: 'zero width space'
},
'0x200c': {
zeroWidth: true,
description: 'zero width non-joiner'
},
'0x200e': {
zeroWidth: true,
description: 'left-to-right mark'
},
'0x201c': {
description: 'left double quotation mark'
},
'0x201d': {
description: 'right double quotation mark'
},
'0x202c': {
zeroWidth: true,
description: 'pop directional formatting'
},
'0x202d': {
zeroWidth: true,
description: 'left-to-right override'
},
'0x202e': {
zeroWidth: true,
description: 'right-to-left override'
},
'0xfffc': {
zeroWidth: true,
description: 'object replacement character'
}
}
314 changes: 314 additions & 0 deletions src/utils/grimlinCharacters.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,314 @@
// Used https://compart.com/en/unicode to find the to find the description of each gremlin
// List of gremlins was deduced from https://github.com/redoPop/SublimeGremlins/blob/main/Gremlins.py#L13

export const gremlinCharacters = {
'0x0003': {
description: 'End of Text'
},
'0x000b': {
description: 'Line Tabulation'
},
'0x007f': {
description: 'Delete'
},
'0x0080': {
description: 'Padding'
},
'0x0081': {
description: 'High Octet Preset'
},
'0x0082': {
description: 'Break Permitted Here'
},
'0x0083': {
description: 'No Break Here'
},
'0x0084': {
description: 'Index'
},
'0x0085': {
description: 'Next Line'
},
'0x0086': {
description: 'Start of Selected Area'
},
'0x0087': {
description: 'End of Selected Area'
},
'0x0088': {
description: 'Character Tabulation Set'
},
'0x0089': {
description: 'Character Tabulation with Justification'
},
'0x008a': {
description: 'Line Tabulation Set'
},
'0x008b': {
description: 'Partial Line Down'
},
'0x008c': {
description: 'Partial Line Backward'
},
'0x008d': {
description: 'Reverse Index'
},
'0x008e': {
description: 'Single Shift Two'
},
'0x008f': {
description: 'Single Shift Three'
},
'0x0090': {
description: 'Device Control String'
},
'0x0091': {
description: 'Private Use One'
},
'0x0092': {
description: 'Private Use Two'
},
'0x0093': {
description: 'Set Transmit State'
},
'0x0094': {
description: 'Cancel Character'
},
'0x0095': {
description: 'Message Waiting'
},
'0x0096': {
description: 'Start of Guarded Area'
},
'0x0097': {
description: 'End of Guarded Area'
},
'0x0098': {
description: 'Start of String'
},
'0x0099': {
description: 'Single Graphic Character Introducer'
},
'0x009a': {
description: 'Single Character Introducer'
},
'0x009b': {
description: 'Control Sequence Introducer'
},
'0x009c': {
description: 'String Terminator'
},
'0x009d': {
description: 'Operating System Command'
},
'0x009e': {
description: 'Privacy Message'
},
'0x009f': {
description: 'Application Program Command'
},
'0x00a0': {
description: 'non breaking space'
},
'0x00ad': {
description: 'Soft Hyphen'
},
'0x2000': {
description: 'En Quad'
},
'0x2001': {
description: 'Em Quad'
},
'0x2002': {
description: 'En Space'
},
'0x2003': {
description: 'Em Space'
},
'0x2004': {
description: 'Three-Per-Em Space'
},
'0x2005': {
description: 'Four-Per-Em Space'
},
'0x2006': {
description: 'Six-Per-Em Space'
},
'0x2007': {
description: 'Figure Space'
},
'0x2008': {
description: 'Punctuation Space'
},
'0x2009': {
description: 'Thin Space'
},
'0x200a': {
description: 'Hair Space'
},
'0x200b': {
description: 'Zero Width Space'
},
'0x200c': {
description: 'Zero Width Non-Joiner'
},
'0x200d': {
description: 'Zero Width Joiner'
},
'0x200e': {
description: 'Left-to-Right Mark'
},
'0x200f': {
description: 'Right-to-Left Mark'
},
'0x2013': {
description: 'En Dash'
},
'0x2018': {
description: 'Left Single Quotation Mark'
},
'0x2019': {
description: 'Right Single Quotation Mark'
},
'0x201c': {
description: 'Left Double Quotation Mark'
},
'0x201d': {
description: 'Right Double Quotation Mark'
},
'0x2028': {
description: 'Line Separator'
},
'0x2029': {
description: 'Paragraph Separator'
},
'0x202a': {
description: 'Left-to-Right Embedding'
},
'0x202b': {
description: 'Right-to-Left Embedding'
},
'0x202c': {
description: 'Pop Directional Formatting'
},
'0x202d': {
description: 'Left-to-Right Override'
},
'0x202e': {
description: 'Right-to-Left Override'
},
'0x202f': {
description: 'Narrow No-Break Space'
},
'0x205f': {
description: 'Medium Mathematical Space'
},
'0x2060': {
description: 'Word Joiner'
},
'0x2061': {
description: 'Function Application'
},
'0x2062': {
description: 'Invisible Times'
},
'0x2063': {
description: 'Invisible Separator'
},
'0x2064': {
description: 'Invisible Plus'
},
'0x2066': {
description: 'Left-to-Right Isolate'
},
'0x2067': {
description: 'Right-to-Left Isolate'
},
'0x2068': {
description: 'First Strong Isolate '
},
'0x2069': {
description: 'Pop Directional Isolate'
},
'0x206a': {
description: 'Inhibit Symmetric Swapping'
},
'0x206b': {
description: 'Activate Symmetric Swapping'
},
'0x206c': {
description: 'Inhibit Arabic Form Shaping'
},
'0x206d': {
description: 'Activate Arabic Form Shaping'
},
'0x206e': {
description: 'National Digit Shapes'
},
'0x206f': {
description: 'Nominal Digit Shapes'
},
'0x2800': {
description: 'Braille Pattern Blank'
},
'0x3000': {
description: 'Ideographic Space'
},
'0x3164': {
description: 'Hangul Filler'
},
'0xfe00': {
description: 'Variation Selector-1'
},
'0xfe01': {
description: 'Variation Selector-2'
},
'0xfe02': {
description: 'Variation Selector-3'
},
'0xfe03': {
description: 'Variation Selector-4'
},
'0xfe04': {
description: 'Variation Selector-5'
},
'0xfe05': {
description: 'Variation Selector-6'
},
'0xfe06': {
description: 'Variation Selector-7'
},
'0xfe07': {
description: 'Variation Selector-8'
},
'0xfe08': {
description: 'Variation Selector-9'
},
'0xfe09': {
description: 'Variation Selector-10'
},
'0xfe0a': {
description: 'Variation Selector-11'
},
'0xfe0b': {
description: 'Variation Selector-12 '
},
'0xfe0c': {
description: 'Variation Selector-13'
},
'0xfe0d': {
description: 'Variation Selector-14'
},
'0xfe0e': {
description: 'Variation Selector-15'
},
'0xfe0f': {
description: 'Variation Selector-16'
},
'0xfeff': {
description: 'Zero Width No-Break Space'
},
'0xfffc': {
description: 'Object Replacement Character'
}
}
Loading

0 comments on commit 97e3490

Please sign in to comment.