├── .gitattributes ├── .gitignore ├── LICENSE.markdown ├── README.md ├── lib ├── linter-swiftc.coffee └── provider.coffee ├── package-lock.json └── package.json /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text eol=lf 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | npm-debug.log 3 | node_modules 4 | -------------------------------------------------------------------------------- /LICENSE.markdown: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Kepler B. Sticka-Jones 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | linter-swiftc 2 | ========================= 3 | 4 | This linter plugin for [Linter](https://github.com/AtomLinter/Linter) provides an interface to Swift's builtin syntax analysis. It will be used with files that have the `Swift` syntax. 5 | 6 | ## Installation 7 | Linter package must be installed in order to use this plugin. If Linter is not installed, please follow the instructions [here](https://github.com/AtomLinter/Linter). 8 | 9 | ### Plugin installation 10 | ``` 11 | $ apm install linter-swiftc 12 | ``` 13 | 14 | ## Contributing 15 | If you would like to contribute enhancements or fixes, please do the following: 16 | 17 | 1. Fork the plugin repository. 18 | 1. Hack on a separate topic branch created from the latest `master`. 19 | 1. Commit and push the topic branch. 20 | 1. Make a pull request. 21 | 1. welcome to the club 22 | 23 | Please note that modifications should follow these coding guidelines: 24 | 25 | - Indent is 2 spaces. 26 | - Code should pass coffeelint linter. 27 | - Vertical whitespace helps readability, don’t be afraid to use it. 28 | 29 | Thank you for helping out! 30 | -------------------------------------------------------------------------------- /lib/linter-swiftc.coffee: -------------------------------------------------------------------------------- 1 | module.exports = LinterSwiftc = 2 | activate: -> 3 | # Show the user an error if they do not have the appropriate 4 | # Swift Language package from Atom Package Manager installed. 5 | atom.notification.addError( 6 | 'Swift Language Package not found.', 7 | { 8 | detail: 'Please install the `language-swift` package in your 9 | Settings view.' 10 | } 11 | ) unless atom.packages.getLoadedPackages 'language-swift' 12 | 13 | # Show the user an error if they do not have an appropriate linter based 14 | # package installed from Atom Package Manager. This will not be an issue 15 | # after a base linter package is integrated into Atom, in the coming 16 | # months. 17 | # TODO: Remove when Linter Base is integrated into Atom. 18 | atom.notifications.addError( 19 | 'Linter package not found.', 20 | { 21 | detail: 'Please install the `linter` package in your Settings view' 22 | } 23 | ) unless atom.packages.getLoadedPackages 'linter' 24 | 25 | provideLinter: -> 26 | LinterProvider = require './provider' 27 | provider = new LinterProvider() 28 | return { 29 | name: 'swiftc' 30 | grammarScopes: ['source.swift'] 31 | scope: 'file' 32 | lint: provider.lint 33 | lintsOnChange: false 34 | } 35 | -------------------------------------------------------------------------------- /lib/provider.coffee: -------------------------------------------------------------------------------- 1 | path = require 'path' 2 | helpers = require 'atom-linter' 3 | child_process = require 'child_process' 4 | 5 | VALID_SEVERITY = ['error', 'warning', 'info'] 6 | 7 | getSeverity = (givenSeverity) -> 8 | severity = givenSeverity.toLowerCase() 9 | return if severity not in VALID_SEVERITY then 'warning' else severity 10 | 11 | module.exports = class LinterProvider 12 | regex = /// 13 | (\S+): #The file with issue. 14 | (\d+): #The line number with issue. 15 | (\d+): #The column where the issue begins. 16 | \s+ #A space. 17 | (\w+): #The type of issue being reported. 18 | \s+ #A space. 19 | (.*) #A message explaining the issue at hand. 20 | /// 21 | 22 | getCommand = -> "#{atom.config.get 'linter-swiftc.compilerExecPath'} -parse" 23 | 24 | getCommandWithFile = (file) -> "#{getCommand()} #{file}" 25 | 26 | # This is based on code taken right from the linter-plus rewrite 27 | # of `linter-crystal`. 28 | lint: (textEditor) -> 29 | new Promise (Resolve) -> 30 | file = path.basename textEditor.getPath() 31 | cwd = path.dirname textEditor.getPath() 32 | data = [] 33 | command = getCommandWithFile file 34 | console.log "Swift Linter Command: #{command}" if atom.inDevMode() 35 | process = child_process.exec command, {cwd: cwd} 36 | process.stderr.on 'data', (d) -> data.push d.toString() 37 | process.on 'close', -> 38 | toReturn = [] 39 | for line in data 40 | console.log "Swift Linter Provider: #{line}" if atom.inDevMode() 41 | if line.match regex 42 | [file, line, column, severity, excerpt] = line.match(regex)[1..5] 43 | line = Number.parseInt(line, 10) - 1 44 | column = Number.parseInt(column, 10) - 1 45 | toReturn.push 46 | severity: getSeverity(severity) 47 | excerpt: excerpt 48 | location: 49 | file: path.join(cwd, file).normalize() 50 | position: helpers.generateRange(textEditor, line, column) 51 | Resolve toReturn 52 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "linter-swiftc", 3 | "version": "2.1.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "atom-linter": { 8 | "version": "10.0.0", 9 | "resolved": "https://registry.npmjs.org/atom-linter/-/atom-linter-10.0.0.tgz", 10 | "integrity": "sha1-0nu3Tl+PCKdKQL6ynuGlDZdUPIk=", 11 | "requires": { 12 | "named-js-regexp": "^1.3.1", 13 | "sb-exec": "^4.0.0", 14 | "sb-promisify": "^2.0.1", 15 | "tmp": "~0.0.28" 16 | } 17 | }, 18 | "balanced-match": { 19 | "version": "1.0.0", 20 | "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", 21 | "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", 22 | "dev": true 23 | }, 24 | "brace-expansion": { 25 | "version": "1.1.11", 26 | "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", 27 | "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", 28 | "dev": true, 29 | "requires": { 30 | "balanced-match": "^1.0.0", 31 | "concat-map": "0.0.1" 32 | } 33 | }, 34 | "coffeelint": { 35 | "version": "2.1.0", 36 | "resolved": "https://registry.npmjs.org/coffeelint/-/coffeelint-2.1.0.tgz", 37 | "integrity": "sha1-r2XfNjTpmdmsAUgHNsNtPNL12tg=", 38 | "dev": true, 39 | "requires": { 40 | "coffeescript": "^2.1.0", 41 | "glob": "^7.0.6", 42 | "ignore": "^3.0.9", 43 | "optimist": "^0.6.1", 44 | "resolve": "^0.6.3", 45 | "strip-json-comments": "^1.0.2" 46 | } 47 | }, 48 | "coffeescript": { 49 | "version": "2.3.2", 50 | "resolved": "https://registry.npmjs.org/coffeescript/-/coffeescript-2.3.2.tgz", 51 | "integrity": "sha512-YObiFDoukx7qPBi/K0kUKyntEZDfBQiqs/DbrR1xzASKOBjGT7auD85/DiPeRr9k++lRj7l3uA9TNMLfyfcD/Q==", 52 | "dev": true 53 | }, 54 | "concat-map": { 55 | "version": "0.0.1", 56 | "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", 57 | "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", 58 | "dev": true 59 | }, 60 | "consistent-env": { 61 | "version": "1.3.1", 62 | "resolved": "https://registry.npmjs.org/consistent-env/-/consistent-env-1.3.1.tgz", 63 | "integrity": "sha1-9oI018afxt2WVviuI0Kc4EmbZfs=", 64 | "requires": { 65 | "lodash.uniq": "^4.5.0" 66 | } 67 | }, 68 | "fs.realpath": { 69 | "version": "1.0.0", 70 | "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", 71 | "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", 72 | "dev": true 73 | }, 74 | "glob": { 75 | "version": "7.1.3", 76 | "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", 77 | "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", 78 | "dev": true, 79 | "requires": { 80 | "fs.realpath": "^1.0.0", 81 | "inflight": "^1.0.4", 82 | "inherits": "2", 83 | "minimatch": "^3.0.4", 84 | "once": "^1.3.0", 85 | "path-is-absolute": "^1.0.0" 86 | } 87 | }, 88 | "ignore": { 89 | "version": "3.3.10", 90 | "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.10.tgz", 91 | "integrity": "sha512-Pgs951kaMm5GXP7MOvxERINe3gsaVjUWFm+UZPSq9xYriQAksyhg0csnS0KXSNRD5NmNdapXEpjxG49+AKh/ug==", 92 | "dev": true 93 | }, 94 | "inflight": { 95 | "version": "1.0.6", 96 | "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", 97 | "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", 98 | "dev": true, 99 | "requires": { 100 | "once": "^1.3.0", 101 | "wrappy": "1" 102 | } 103 | }, 104 | "inherits": { 105 | "version": "2.0.3", 106 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", 107 | "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", 108 | "dev": true 109 | }, 110 | "lodash.uniq": { 111 | "version": "4.5.0", 112 | "resolved": "https://registry.npmjs.org/lodash.uniq/-/lodash.uniq-4.5.0.tgz", 113 | "integrity": "sha1-0CJTc662Uq3BvILklFM5qEJ1R3M=" 114 | }, 115 | "minimatch": { 116 | "version": "3.0.4", 117 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", 118 | "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", 119 | "dev": true, 120 | "requires": { 121 | "brace-expansion": "^1.1.7" 122 | } 123 | }, 124 | "minimist": { 125 | "version": "0.0.10", 126 | "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz", 127 | "integrity": "sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8=", 128 | "dev": true 129 | }, 130 | "named-js-regexp": { 131 | "version": "1.3.4", 132 | "resolved": "https://registry.npmjs.org/named-js-regexp/-/named-js-regexp-1.3.4.tgz", 133 | "integrity": "sha512-wvbB+afegWlmc3/bXd+S1DDLPGcyARWVvYCOntQwBRhKgwSZewk8zolExzyLrXT70xhFkmRYQGigXFaTgtHqjA==" 134 | }, 135 | "once": { 136 | "version": "1.4.0", 137 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", 138 | "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", 139 | "dev": true, 140 | "requires": { 141 | "wrappy": "1" 142 | } 143 | }, 144 | "optimist": { 145 | "version": "0.6.1", 146 | "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", 147 | "integrity": "sha1-2j6nRob6IaGaERwybpDrFaAZZoY=", 148 | "dev": true, 149 | "requires": { 150 | "minimist": "~0.0.1", 151 | "wordwrap": "~0.0.2" 152 | } 153 | }, 154 | "os-tmpdir": { 155 | "version": "1.0.2", 156 | "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", 157 | "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=" 158 | }, 159 | "path-is-absolute": { 160 | "version": "1.0.1", 161 | "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", 162 | "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", 163 | "dev": true 164 | }, 165 | "resolve": { 166 | "version": "0.6.3", 167 | "resolved": "https://registry.npmjs.org/resolve/-/resolve-0.6.3.tgz", 168 | "integrity": "sha1-3ZV5gufnNt699TtYpN2RdUV13UY=", 169 | "dev": true 170 | }, 171 | "sb-exec": { 172 | "version": "4.0.0", 173 | "resolved": "https://registry.npmjs.org/sb-exec/-/sb-exec-4.0.0.tgz", 174 | "integrity": "sha1-RnR/DfFiYmwW6/D+pCJFrRqoWco=", 175 | "requires": { 176 | "consistent-env": "^1.2.0", 177 | "lodash.uniq": "^4.5.0", 178 | "sb-npm-path": "^2.0.0" 179 | } 180 | }, 181 | "sb-memoize": { 182 | "version": "1.0.2", 183 | "resolved": "https://registry.npmjs.org/sb-memoize/-/sb-memoize-1.0.2.tgz", 184 | "integrity": "sha1-EoN1xi3bnMT/qQXQxaWXwZuurY4=" 185 | }, 186 | "sb-npm-path": { 187 | "version": "2.0.0", 188 | "resolved": "https://registry.npmjs.org/sb-npm-path/-/sb-npm-path-2.0.0.tgz", 189 | "integrity": "sha1-D2zCzzcd68p9k27Xa31MPMHrPVg=", 190 | "requires": { 191 | "sb-memoize": "^1.0.2", 192 | "sb-promisify": "^2.0.1" 193 | } 194 | }, 195 | "sb-promisify": { 196 | "version": "2.0.2", 197 | "resolved": "https://registry.npmjs.org/sb-promisify/-/sb-promisify-2.0.2.tgz", 198 | "integrity": "sha1-QnelR1RIiqlnXYhuNU24lMm9yYE=" 199 | }, 200 | "strip-json-comments": { 201 | "version": "1.0.4", 202 | "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz", 203 | "integrity": "sha1-HhX7ysl9Pumb8tc7TGVrCCu6+5E=", 204 | "dev": true 205 | }, 206 | "tmp": { 207 | "version": "0.0.33", 208 | "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", 209 | "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", 210 | "requires": { 211 | "os-tmpdir": "~1.0.2" 212 | } 213 | }, 214 | "wordwrap": { 215 | "version": "0.0.3", 216 | "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", 217 | "integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc=", 218 | "dev": true 219 | }, 220 | "wrappy": { 221 | "version": "1.0.2", 222 | "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", 223 | "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", 224 | "dev": true 225 | } 226 | } 227 | } 228 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "linter-swiftc", 3 | "main": "./lib/linter-swiftc", 4 | "version": "2.1.0", 5 | "private": true, 6 | "description": "Lint Swift using swiftc", 7 | "repository": "https://github.com/AtomLinter/linter-swiftc", 8 | "license": "MIT", 9 | "engines": { 10 | "atom": ">0.50.0 <2.0.0" 11 | }, 12 | "configSchema": { 13 | "compilerExecPath": { 14 | "default": "swiftc", 15 | "description": "The path of the compiler executable, with binary name. By default will use `swiftc` from your path.", 16 | "type": "string" 17 | } 18 | }, 19 | "dependencies": { 20 | "atom-linter": "10.0.0" 21 | }, 22 | "devDependencies": { 23 | "coffeelint": "2.1.0" 24 | }, 25 | "scripts": { 26 | "lint": "coffeelint ." 27 | }, 28 | "package-deps": [ 29 | "linter:2.0.0" 30 | ], 31 | "providedServices": { 32 | "linter": { 33 | "versions": { 34 | "2.0.0": "provideLinter" 35 | } 36 | } 37 | }, 38 | "renovate": { 39 | "extends": [ 40 | "config:base" 41 | ], 42 | "semanticCommits": true, 43 | "rangeStrategy": "pin", 44 | "packageRules": [ 45 | { 46 | "packagePatterns": [ 47 | "^eslint" 48 | ], 49 | "groupName": "ESLint packages" 50 | } 51 | ] 52 | }, 53 | "coffeelintConfig": { 54 | "max_line_length": { 55 | "value": 120, 56 | "level": "warn" 57 | }, 58 | "no_empty_param_list": { 59 | "level": "error" 60 | }, 61 | "arrow_spacing": { 62 | "level": "error" 63 | }, 64 | "no_interpolation_in_single_quotes": { 65 | "level": "error" 66 | }, 67 | "no_debugger": { 68 | "level": "error" 69 | }, 70 | "prefer_english_operator": { 71 | "level": "error" 72 | }, 73 | "colon_assignment_spacing": { 74 | "spacing": { 75 | "left": 0, 76 | "right": 1 77 | }, 78 | "level": "error" 79 | }, 80 | "braces_spacing": { 81 | "spaces": 0, 82 | "level": "error" 83 | }, 84 | "spacing_after_comma": { 85 | "level": "error" 86 | }, 87 | "no_stand_alone_at": { 88 | "level": "error" 89 | } 90 | } 91 | } 92 | --------------------------------------------------------------------------------