├── .circleci └── config.yml ├── .gitattributes ├── .gitignore ├── .travis.yml ├── CHANGELOG.md ├── CONTRIBUTING.md ├── README.md ├── appveyor.yml ├── lib └── main.js ├── package-lock.json ├── package.json └── spec ├── .eslintrc.js ├── fixtures ├── bad.rb └── good.rb └── linter-ruby-spec.js /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | 3 | defaults: &defaults 4 | working_directory: /tmp/project 5 | docker: 6 | - image: arcanemagus/atom-docker-ci:stable 7 | steps: 8 | # Restore project state 9 | - attach_workspace: 10 | at: /tmp 11 | - run: 12 | name: Install Ruby 13 | command: | 14 | sudo apt-get update && 15 | sudo apt-get install --assume-yes --quiet --no-install-suggests \ 16 | --no-install-recommends ruby 17 | - run: 18 | name: Ruby version 19 | command: ruby --version 20 | - run: 21 | name: Create VFB for Atom to run in 22 | command: /usr/local/bin/xvfb_start 23 | - run: 24 | name: Atom version 25 | command: ${ATOM_SCRIPT_PATH} --version 26 | - run: 27 | name: APM version 28 | command: ${APM_SCRIPT_PATH} --version 29 | - run: 30 | name: Package APM package dependencies 31 | command: | 32 | if [ -n "${APM_TEST_PACKAGES}" ]; then 33 | for pack in ${APM_TEST_PACKAGES}; do 34 | ${APM_SCRIPT_PATH} install "${pack}" 35 | done 36 | fi; 37 | - run: 38 | name: Package dependencies 39 | command: ${APM_SCRIPT_PATH} install 40 | - run: 41 | name: Cleaning package 42 | command: ${APM_SCRIPT_PATH} clean 43 | - run: 44 | name: Package specs 45 | command: ${ATOM_SCRIPT_PATH} --test spec 46 | # Cache node_modules 47 | - save_cache: 48 | paths: 49 | - node_modules 50 | key: v2-dependencies-{{ .Branch }}-{{ checksum "package.json" }}-{{ checksum "package-lock.json"}} 51 | 52 | jobs: 53 | checkout_code: 54 | <<: *defaults 55 | docker: 56 | - image: circleci/node:latest 57 | steps: 58 | - checkout 59 | # Restore node_modules from the last build 60 | - restore_cache: 61 | keys: 62 | # Get latest cache for this package.json and package-lock.json 63 | - v2-dependencies-{{ .Branch }}-{{ checksum "package.json" }}-{{ checksum "package-lock.json"}} 64 | # Fallback to the current package.json 65 | - v2-dependencies-{{ .Branch }}-{{ checksum "package.json" }}- 66 | # Fallback to the last build for this branch 67 | - v2-dependencies-{{ .Branch }}- 68 | # Fallback to the last available master branch cache 69 | - v2-dependencies-master- 70 | # Don't go further down to prevent dependency issues from other branches 71 | # Save project state for next steps 72 | - persist_to_workspace: 73 | root: /tmp 74 | paths: 75 | - project 76 | lint: 77 | <<: *defaults 78 | docker: 79 | - image: circleci/node:latest 80 | steps: 81 | # Restore project state 82 | - attach_workspace: 83 | at: /tmp 84 | - run: 85 | name: Node.js Version 86 | command: node --version 87 | - run: 88 | name: NPM Version 89 | command: npm --version 90 | - run: 91 | name: Install any remaining dependencies 92 | command: npm install 93 | - run: 94 | name: Lint code 95 | command: npm run lint 96 | stable: 97 | <<: *defaults 98 | beta: 99 | <<: *defaults 100 | docker: 101 | - image: arcanemagus/atom-docker-ci:beta 102 | 103 | workflows: 104 | version: 2 105 | test_package: 106 | jobs: 107 | - checkout_code 108 | - lint: 109 | requires: 110 | - checkout_code 111 | - stable: 112 | requires: 113 | - lint 114 | - beta: 115 | requires: 116 | - lint 117 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text eol=lf 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | 5 | # Runtime data 6 | pids 7 | *.pid 8 | *.seed 9 | 10 | # Directory for instrumented libs generated by jscoverage/JSCover 11 | lib-cov 12 | 13 | # Coverage directory used by tools like istanbul 14 | coverage 15 | 16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 17 | .grunt 18 | 19 | # node-waf configuration 20 | .lock-wscript 21 | 22 | # Compiled binary addons (http://nodejs.org/api/addons.html) 23 | build/Release 24 | 25 | # Dependency directory 26 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git 27 | node_modules 28 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | ### Project specific config ### 2 | language: ruby 3 | rvm: 2.4 4 | os: linux 5 | script: skip 6 | env: ATOM_CHANNEL=stable 7 | 8 | jobs: 9 | include: 10 | # Test Atom versions 11 | - stage: test 12 | env: ATOM_CHANNEL=stable 13 | - stage: test 14 | env: ATOM_CHANNEL=beta 15 | 16 | # There are enough issues with OS X that this actually should be tested here 17 | - stage: test 18 | os: osx 19 | env: ATOM_CHANNEL=beta 20 | 21 | # Check the commit messages and run the extra lint script 22 | - stage: test 23 | language: node_js 24 | node_js: lts/* 25 | install: 26 | - npm install 27 | script: 28 | - commitlint-travis 29 | 30 | - stage: release 31 | # Since the deploy needs APM, currently the simplest method is to run 32 | # build-package.sh, which requires the specs to pass, so this must run in 33 | # the main language instead of Node.js. 34 | before_deploy: 35 | - export PATH=${PATH}:${HOME}/atom/usr/bin/ 36 | # Update to the current LTS version of Node.js 37 | - nvm install lts/* 38 | - node --version 39 | - npm --version 40 | - npx --version 41 | deploy: 42 | provider: script 43 | skip_cleanup: true 44 | script: 45 | - npx semantic-release 46 | 47 | ### Generic setup follows ### 48 | install: 49 | - curl -s -O https://raw.githubusercontent.com/atom/ci/master/build-package.sh 50 | - chmod u+x build-package.sh 51 | - "./build-package.sh" 52 | 53 | notifications: 54 | email: 55 | on_success: never 56 | on_failure: change 57 | 58 | branches: 59 | only: 60 | - master 61 | 62 | git: 63 | depth: 10 64 | 65 | sudo: false 66 | 67 | dist: trusty 68 | 69 | addons: 70 | apt: 71 | packages: 72 | - build-essential 73 | - git 74 | - libgnome-keyring-dev 75 | - fakeroot 76 | 77 | stages: 78 | - test 79 | - name: release 80 | if: (NOT type = pull_request) AND branch = master 81 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## [1.3.1](https://github.com/AtomLinter/linter-ruby/compare/v1.3.0...v1.3.1) (2019-04-22) 2 | 3 | 4 | ### Bug Fixes 5 | 6 | * **deps:** update dependency atom-package-deps to v5.1.0 ([982b391](https://github.com/AtomLinter/linter-ruby/commit/982b391)) 7 | 8 | # [1.3.0](https://github.com/AtomLinter/linter-ruby/compare/v1.2.6...v1.3.0) (2019-01-23) 9 | 10 | 11 | ### Bug Fixes 12 | 13 | * **package:** update atom-package-deps to version 5.0.0 ([737948a](https://github.com/AtomLinter/linter-ruby/commit/737948a)) 14 | 15 | 16 | ### Features 17 | 18 | * update linter v2 ([e6aab97](https://github.com/AtomLinter/linter-ruby/commit/e6aab97)) 19 | 20 | # Change Log 21 | 22 | ## [v1.2.6](https://github.com/AtomLinter/linter-ruby/tree/v1.2.6) (2017-08-28) 23 | 24 | [Full Changelog](https://github.com/AtomLinter/linter-ruby/compare/v1.2.5...v1.2.6) 25 | 26 | **Implemented enhancements:** 27 | 28 | - Update Travis CI configuration [\#121](https://github.com/AtomLinter/linter-ruby/pull/121) ([Arcanemagus](https://github.com/Arcanemagus)) 29 | - Update eslint to version 4.5.0 🚀 [\#120](https://github.com/AtomLinter/linter-ruby/pull/120) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) 30 | - Update atom-linter to version 10.0.0 🚀 [\#115](https://github.com/AtomLinter/linter-ruby/pull/115) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) 31 | 32 | **Fixed bugs:** 33 | 34 | - path.extname is deprecated. [\#119](https://github.com/AtomLinter/linter-ruby/issues/119) 35 | - Guard against pathless TextEditor [\#122](https://github.com/AtomLinter/linter-ruby/pull/122) ([Arcanemagus](https://github.com/Arcanemagus)) 36 | - Change how encoding is specified [\#113](https://github.com/AtomLinter/linter-ruby/pull/113) ([Arcanemagus](https://github.com/Arcanemagus)) 37 | 38 | ## [v1.2.5](https://github.com/AtomLinter/linter-ruby/tree/v1.2.5) (2017-02-23) 39 | 40 | [Full Changelog](https://github.com/AtomLinter/linter-ruby/compare/v1.2.4...v1.2.5) 41 | 42 | **Implemented enhancements:** 43 | 44 | - Remove macOS Testing [\#110](https://github.com/AtomLinter/linter-ruby/pull/110) ([Arcanemagus](https://github.com/Arcanemagus)) 45 | - Update dependencies to enable Greenkeeper 🌴 [\#105](https://github.com/AtomLinter/linter-ruby/pull/105) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) 46 | 47 | ## [v1.2.4](https://github.com/AtomLinter/linter-ruby/tree/v1.2.4) (2016-12-02) 48 | 49 | [Full Changelog](https://github.com/AtomLinter/linter-ruby/compare/v1.2.3...v1.2.4) 50 | 51 | **Implemented enhancements:** 52 | 53 | - Implement specs [\#60](https://github.com/AtomLinter/linter-ruby/issues/60) 54 | - Add CI configurations [\#101](https://github.com/AtomLinter/linter-ruby/pull/101) ([Arcanemagus](https://github.com/Arcanemagus)) 55 | - Add basic specs [\#100](https://github.com/AtomLinter/linter-ruby/pull/100) ([Arcanemagus](https://github.com/Arcanemagus)) 56 | - Configure ESLint and cleanup code [\#98](https://github.com/AtomLinter/linter-ruby/pull/98) ([Arcanemagus](https://github.com/Arcanemagus)) 57 | 58 | **Fixed bugs:** 59 | 60 | - Linter Not Activating [\#96](https://github.com/AtomLinter/linter-ruby/issues/96) 61 | - Improve visibility of syntax errors [\#94](https://github.com/AtomLinter/linter-ruby/issues/94) 62 | - Fix styling of syntax errors [\#102](https://github.com/AtomLinter/linter-ruby/pull/102) ([Arcanemagus](https://github.com/Arcanemagus)) 63 | - Cleanup and bugfixes [\#99](https://github.com/AtomLinter/linter-ruby/pull/99) ([Arcanemagus](https://github.com/Arcanemagus)) 64 | - Add language-ruby-on-rails to activation list [\#97](https://github.com/AtomLinter/linter-ruby/pull/97) ([Arcanemagus](https://github.com/Arcanemagus)) 65 | 66 | ## [v1.2.3](https://github.com/AtomLinter/linter-ruby/tree/v1.2.3) (2016-11-28) 67 | 68 | [Full Changelog](https://github.com/AtomLinter/linter-ruby/compare/v1.2.2...v1.2.3) 69 | 70 | **Implemented enhancements:** 71 | 72 | - Improve Atom startup time [\#95](https://github.com/AtomLinter/linter-ruby/pull/95) ([walles](https://github.com/walles)) 73 | - Update atom-linter to version 8.0.0 🚀 [\#91](https://github.com/AtomLinter/linter-ruby/pull/91) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) 74 | - atom-linter@4.6.1 untested ⚠️ [\#76](https://github.com/AtomLinter/linter-ruby/pull/76) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) 75 | 76 | **Fixed bugs:** 77 | 78 | - false positives due to utf-8/german umlauts [\#69](https://github.com/AtomLinter/linter-ruby/issues/69) 79 | - replace -Ku to -E utf-8 [\#78](https://github.com/AtomLinter/linter-ruby/pull/78) ([ananevam](https://github.com/ananevam)) 80 | 81 | ## [v1.2.2](https://github.com/AtomLinter/linter-ruby/tree/v1.2.2) (2016-02-22) 82 | 83 | [Full Changelog](https://github.com/AtomLinter/linter-ruby/compare/v1.2.1...v1.2.2) 84 | 85 | **Implemented enhancements:** 86 | 87 | - changelog use [\#41](https://github.com/AtomLinter/linter-ruby/issues/41) 88 | - Update atom-package-deps to version 4.0.1 🚀 [\#68](https://github.com/AtomLinter/linter-ruby/pull/68) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) 89 | - atom-linter@4.5.0 untested ⚠️ [\#66](https://github.com/AtomLinter/linter-ruby/pull/66) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) 90 | - atom-package-deps@3.0.8 untested ⚠️ [\#64](https://github.com/AtomLinter/linter-ruby/pull/64) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) 91 | - atom-linter@4.4.0 untested ⚠️ [\#63](https://github.com/AtomLinter/linter-ruby/pull/63) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) 92 | - chore\(package\): update atom-linter to version 4.3.1 [\#57](https://github.com/AtomLinter/linter-ruby/pull/57) ([Arcanemagus](https://github.com/Arcanemagus)) 93 | - atom-linter@4.3.0 untested ⚠️ [\#55](https://github.com/AtomLinter/linter-ruby/pull/55) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) 94 | - atom-package-deps@3.0.7 untested ⚠️ [\#54](https://github.com/AtomLinter/linter-ruby/pull/54) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) 95 | 96 | **Fixed bugs:** 97 | 98 | - All issue markers are offset down by one line [\#36](https://github.com/AtomLinter/linter-ruby/issues/36) 99 | - set utf8 encoding for check [\#72](https://github.com/AtomLinter/linter-ruby/pull/72) ([ananevam](https://github.com/ananevam)) 100 | 101 | ## [v1.2.1](https://github.com/AtomLinter/linter-ruby/tree/v1.2.1) (2015-12-30) 102 | 103 | [Full Changelog](https://github.com/AtomLinter/linter-ruby/compare/v1.2.0...v1.2.1) 104 | 105 | **Implemented enhancements:** 106 | 107 | - Update dependencies [\#53](https://github.com/AtomLinter/linter-ruby/pull/53) ([Arcanemagus](https://github.com/Arcanemagus)) 108 | - Add a .gitattributes [\#52](https://github.com/AtomLinter/linter-ruby/pull/52) ([Arcanemagus](https://github.com/Arcanemagus)) 109 | - atom-linter@4.2.0 untested ⚠️ [\#51](https://github.com/AtomLinter/linter-ruby/pull/51) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) 110 | - Update atom-linter to version 4.1.1 🚀 [\#50](https://github.com/AtomLinter/linter-ruby/pull/50) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) 111 | 112 | **Fixed bugs:** 113 | 114 | - Failed to catch the syntax errors by regex [\#42](https://github.com/AtomLinter/linter-ruby/issues/42) 115 | 116 | ## [v1.2.0](https://github.com/AtomLinter/linter-ruby/tree/v1.2.0) (2015-10-08) 117 | 118 | [Full Changelog](https://github.com/AtomLinter/linter-ruby/compare/v1.1.1...v1.2.0) 119 | 120 | **Implemented enhancements:** 121 | 122 | - Add linter name [\#45](https://github.com/AtomLinter/linter-ruby/pull/45) ([Arcanemagus](https://github.com/Arcanemagus)) 123 | - Syntax highlighting for `Settings` section in the readme [\#44](https://github.com/AtomLinter/linter-ruby/pull/44) ([buo](https://github.com/buo)) 124 | 125 | **Fixed bugs:** 126 | 127 | - TypeError: Cannot read property 'match' of undefined [\#31](https://github.com/AtomLinter/linter-ruby/issues/31) 128 | - Fix the regex to catch the syntax errors [\#43](https://github.com/AtomLinter/linter-ruby/pull/43) ([buo](https://github.com/buo)) 129 | 130 | ## [v1.1.1](https://github.com/AtomLinter/linter-ruby/tree/v1.1.1) (2015-09-06) 131 | 132 | [Full Changelog](https://github.com/AtomLinter/linter-ruby/compare/v1.1.0...v1.1.1) 133 | 134 | **Implemented enhancements:** 135 | 136 | - Upgrade installer [\#39](https://github.com/AtomLinter/linter-ruby/pull/39) ([steelbrain](https://github.com/steelbrain)) 137 | 138 | ## [v1.1.0](https://github.com/AtomLinter/linter-ruby/tree/v1.1.0) (2015-09-06) 139 | 140 | [Full Changelog](https://github.com/AtomLinter/linter-ruby/compare/v1.0.3...v1.1.0) 141 | 142 | **Implemented enhancements:** 143 | 144 | - Convert to independant package. [\#38](https://github.com/AtomLinter/linter-ruby/pull/38) ([keplersj](https://github.com/keplersj)) 145 | 146 | ## [v1.0.3](https://github.com/AtomLinter/linter-ruby/tree/v1.0.3) (2015-09-05) 147 | 148 | [Full Changelog](https://github.com/AtomLinter/linter-ruby/compare/v1.0.2...v1.0.3) 149 | 150 | **Implemented enhancements:** 151 | 152 | - Ignore extensions [\#37](https://github.com/AtomLinter/linter-ruby/pull/37) ([goddamnhippie](https://github.com/goddamnhippie)) 153 | - fix lintOnFly and wrong range\(line\) report [\#30](https://github.com/AtomLinter/linter-ruby/pull/30) ([Project0](https://github.com/Project0)) 154 | 155 | **Fixed bugs:** 156 | 157 | - No warnings and line numbers are offset [\#33](https://github.com/AtomLinter/linter-ruby/issues/33) 158 | - linter-ruby does not support Lint on the fly [\#27](https://github.com/AtomLinter/linter-ruby/issues/27) 159 | - catch error type by regex [\#35](https://github.com/AtomLinter/linter-ruby/pull/35) ([Project0](https://github.com/Project0)) 160 | 161 | ## [v1.0.2](https://github.com/AtomLinter/linter-ruby/tree/v1.0.2) (2015-08-19) 162 | 163 | [Full Changelog](https://github.com/AtomLinter/linter-ruby/compare/v1.0.1...v1.0.2) 164 | 165 | **Fixed bugs:** 166 | 167 | - Uncaught Error: spawn ENOTDIR [\#23](https://github.com/AtomLinter/linter-ruby/issues/23) 168 | - Move to a broader regex [\#28](https://github.com/AtomLinter/linter-ruby/pull/28) ([Arcanemagus](https://github.com/Arcanemagus)) 169 | 170 | ## [v1.0.1](https://github.com/AtomLinter/linter-ruby/tree/v1.0.1) (2015-08-11) 171 | 172 | [Full Changelog](https://github.com/AtomLinter/linter-ruby/compare/v1.0.0...v1.0.1) 173 | 174 | **Fixed bugs:** 175 | 176 | - Resolve the cwd and return the result from the parse method [\#24](https://github.com/AtomLinter/linter-ruby/pull/24) ([mupkoo](https://github.com/mupkoo)) 177 | 178 | ## [v1.0.0](https://github.com/AtomLinter/linter-ruby/tree/v1.0.0) (2015-08-07) 179 | 180 | [Full Changelog](https://github.com/AtomLinter/linter-ruby/compare/v0.1.6...v1.0.0) 181 | 182 | **Implemented enhancements:** 183 | 184 | - Update to Linter v1.0.0 [\#21](https://github.com/AtomLinter/linter-ruby/pull/21) ([keplersj](https://github.com/keplersj)) 185 | 186 | **Fixed bugs:** 187 | 188 | - Object.activate is deprecated. [\#19](https://github.com/AtomLinter/linter-ruby/issues/19) 189 | - Upcoming linter changes [\#17](https://github.com/AtomLinter/linter-ruby/issues/17) 190 | - Config.unobserve is deprecated. [\#8](https://github.com/AtomLinter/linter-ruby/issues/8) 191 | 192 | ## [v0.1.6](https://github.com/AtomLinter/linter-ruby/tree/v0.1.6) (2015-05-21) 193 | 194 | [Full Changelog](https://github.com/AtomLinter/linter-ruby/compare/v0.1.5...v0.1.6) 195 | 196 | **Fixed bugs:** 197 | 198 | - Package.activateConfig is deprecated. [\#11](https://github.com/AtomLinter/linter-ruby/issues/11) 199 | 200 | ## [v0.1.5](https://github.com/AtomLinter/linter-ruby/tree/v0.1.5) (2015-05-16) 201 | 202 | [Full Changelog](https://github.com/AtomLinter/linter-ruby/compare/v0.1.4...v0.1.5) 203 | 204 | **Fixed bugs:** 205 | 206 | - Package.getActivationCommands is deprecated. [\#12](https://github.com/AtomLinter/linter-ruby/issues/12) 207 | - Uncaught TypeError: undefined is not a function [\#10](https://github.com/AtomLinter/linter-ruby/issues/10) 208 | - Update linter-ruby to support --one and remove deprecation notices. [\#15](https://github.com/AtomLinter/linter-ruby/pull/15) ([envygeeks](https://github.com/envygeeks)) 209 | 210 | ## [v0.1.4](https://github.com/AtomLinter/linter-ruby/tree/v0.1.4) (2014-08-08) 211 | 212 | [Full Changelog](https://github.com/AtomLinter/linter-ruby/compare/v0.1.3...v0.1.4) 213 | 214 | **Implemented enhancements:** 215 | 216 | - Added rails and rspec syntaxes. [\#4](https://github.com/AtomLinter/linter-ruby/pull/4) ([lordjavac](https://github.com/lordjavac)) 217 | 218 | ## [v0.1.3](https://github.com/AtomLinter/linter-ruby/tree/v0.1.3) (2014-07-11) 219 | 220 | [Full Changelog](https://github.com/AtomLinter/linter-ruby/compare/9cba5e07492526f6944c3cacba250acab63c3b26...v0.1.3) 221 | 222 | **Implemented enhancements:** 223 | 224 | - Update README [\#2](https://github.com/AtomLinter/linter-ruby/pull/2) ([lucasmazza](https://github.com/lucasmazza)) 225 | - WIP: Implementing the ruby linter [\#1](https://github.com/AtomLinter/linter-ruby/pull/1) ([lucasmazza](https://github.com/lucasmazza)) 226 | 227 | **Fixed bugs:** 228 | 229 | - fix package.json reporting wrong lang [\#3](https://github.com/AtomLinter/linter-ruby/pull/3) ([ddavison](https://github.com/ddavison)) 230 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | If you would like to contribute enhancements or fixes, please do the following: 4 | 5 | 1. Fork the plugin repository. 6 | 2. Hack on a separate topic branch created from the latest `master`. 7 | 3. Commit and push the topic branch. 8 | 4. Make a pull request. 9 | 5. Welcome to the club! 10 | 11 | Please note that modifications should follow these coding guidelines: 12 | 13 | - Indent is 2 spaces. 14 | - Code should pass ESLint linter (`npm run lint`). 15 | - Vertical whitespace helps readability, don’t be afraid to use it. 16 | 17 | Thank you for helping out! 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # linter-ruby 2 | 3 | This linter plugin for [Linter](https://github.com/AtomLinter/Linter) provides 4 | an interface to Ruby's builtin syntax analysis. It will be used with files that 5 | have the `Ruby` syntax. 6 | 7 | ## Installation 8 | 9 | On first activation the plugin will install all dependencies automatically, you 10 | no longer have to worry about installing Linter. 11 | 12 | Just install this package and you'll be good to go. 13 | 14 | ## Settings 15 | 16 | You can configure linter-ruby by editing `~/.atom/config.cson` (choose Open 17 | Your Config in Atom menu): 18 | 19 | ```coffeescript 20 | 'linter-ruby': 21 | # ruby path. run `which ruby` to find the path. 22 | 'rubyExecutablePath': null 23 | 24 | # ignored extensions, ERB and markdown files by default. 25 | 'ignoredExtensions': 'erb, md' 26 | ``` 27 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | ### Project specific config ### 2 | install: 3 | - set PATH=C:\Ruby23-x64\bin;%PATH% 4 | - ruby --version 5 | 6 | environment: 7 | matrix: 8 | - ATOM_CHANNEL: stable 9 | - ATOM_CHANNEL: beta 10 | 11 | ### Generic setup follows ### 12 | build_script: 13 | - ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/atom/ci/master/build-package.ps1')) 14 | 15 | branches: 16 | only: 17 | - master 18 | 19 | version: "{build}" 20 | platform: x64 21 | clone_depth: 10 22 | skip_tags: true 23 | test: off 24 | deploy: off 25 | -------------------------------------------------------------------------------- /lib/main.js: -------------------------------------------------------------------------------- 1 | 'use babel'; 2 | 3 | import * as helpers from 'atom-linter'; 4 | import { extname } from 'path'; 5 | // eslint-disable-next-line import/extensions, import/no-extraneous-dependencies 6 | import { CompositeDisposable } from 'atom'; 7 | 8 | export default { 9 | activate() { 10 | require('atom-package-deps').install('linter-ruby'); 11 | 12 | this.subscriptions = new CompositeDisposable(); 13 | this.subscriptions.add( 14 | atom.config.observe('linter-ruby.rubyExecutablePath', (value) => { 15 | this.executablePath = value; 16 | }), 17 | atom.config.observe('linter-ruby.ignoredExtensions', (value) => { 18 | this.ignoredExtensions = value; 19 | }), 20 | ); 21 | }, 22 | 23 | deactivate() { 24 | this.subscriptions.dispose(); 25 | }, 26 | 27 | provideLinter() { 28 | const regex = /.+:(\d+):\s*(.+?)[,:]\s(.+)/g; 29 | return { 30 | name: 'Ruby', 31 | grammarScopes: ['source.ruby', 'source.ruby.rails', 'source.ruby.rspec'], 32 | scope: 'file', 33 | lintsOnChange: true, 34 | lint: async (textEditor) => { 35 | const filePath = textEditor.getPath(); 36 | if (!filePath) { 37 | // We somehow got called without a file path 38 | return null; 39 | } 40 | const fileText = textEditor.getText(); 41 | const fileExtension = extname(filePath).substr(1); 42 | 43 | if (this.ignoredExtensions.includes(fileExtension)) { 44 | return []; 45 | } 46 | 47 | const execArgs = [ 48 | '-c', // Check syntax only, no execution 49 | '-w', // Turns on warnings 50 | // Set the encoding to UTF-8 51 | '--external-encoding=utf-8', 52 | '--internal-encoding=utf-8', 53 | ]; 54 | const execOpts = { 55 | stdin: fileText, 56 | stream: 'stderr', 57 | allowEmptyStderr: true, 58 | }; 59 | const output = await helpers.exec(this.executablePath, execArgs, execOpts); 60 | if (textEditor.getText() !== fileText) { 61 | // File contents have changed, just tell Linter not to update messages 62 | return null; 63 | } 64 | const toReturn = []; 65 | let match = regex.exec(output); 66 | while (match !== null) { 67 | const msgLine = Number.parseInt(match[1] - 1, 10); 68 | const severity = match[2] === 'warning' ? 'warning' : 'error'; 69 | toReturn.push({ 70 | severity, 71 | location: { 72 | file: filePath, 73 | position: helpers.generateRange(textEditor, msgLine), 74 | }, 75 | excerpt: match[3], 76 | }); 77 | match = regex.exec(output); 78 | } 79 | return toReturn; 80 | }, 81 | }; 82 | }, 83 | }; 84 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "linter-ruby", 3 | "main": "./lib/main", 4 | "version": "1.3.1", 5 | "description": "Lint Ruby on the fly, using ruby -wc", 6 | "repository": { 7 | "type": "git", 8 | "url": "https://github.com/AtomLinter/linter-ruby.git" 9 | }, 10 | "license": "MIT", 11 | "engines": { 12 | "atom": ">=1.4.0 <2.0.0" 13 | }, 14 | "activationHooks": [ 15 | "language-ruby:grammar-used", 16 | "language-ruby-on-rails:grammar-used" 17 | ], 18 | "configSchema": { 19 | "rubyExecutablePath": { 20 | "type": "string", 21 | "default": "ruby" 22 | }, 23 | "ignoredExtensions": { 24 | "type": "array", 25 | "default": [ 26 | "erb", 27 | "md" 28 | ], 29 | "items": { 30 | "type": "string" 31 | } 32 | } 33 | }, 34 | "providedServices": { 35 | "linter": { 36 | "versions": { 37 | "2.0.0": "provideLinter" 38 | } 39 | } 40 | }, 41 | "dependencies": { 42 | "atom-linter": "10.0.0", 43 | "atom-package-deps": "5.1.0" 44 | }, 45 | "devDependencies": { 46 | "@commitlint/cli": "8.3.5", 47 | "@commitlint/config-conventional": "8.3.4", 48 | "@commitlint/travis-cli": "8.3.5", 49 | "@semantic-release/apm-config": "8.0.0", 50 | "eslint": "6.8.0", 51 | "eslint-config-airbnb-base": "14.0.0", 52 | "eslint-plugin-import": "2.20.1", 53 | "husky": "4.2.3", 54 | "jasmine-fix": "1.3.1", 55 | "semantic-release": "17.0.4" 56 | }, 57 | "package-deps": [ 58 | "linter:2.0.0" 59 | ], 60 | "scripts": { 61 | "lint": "eslint .", 62 | "test": "apm test" 63 | }, 64 | "eslintConfig": { 65 | "extends": "airbnb-base", 66 | "rules": { 67 | "global-require": "off", 68 | "import/no-unresolved": [ 69 | "error", 70 | { 71 | "ignore": [ 72 | "atom" 73 | ] 74 | } 75 | ] 76 | }, 77 | "env": { 78 | "browser": true, 79 | "node": true 80 | }, 81 | "globals": { 82 | "atom": true 83 | } 84 | }, 85 | "husky": { 86 | "hooks": { 87 | "commit-msg": "commitlint -E HUSKY_GIT_PARAMS" 88 | } 89 | }, 90 | "renovate": { 91 | "extends": [ 92 | "config:base" 93 | ] 94 | }, 95 | "release": { 96 | "extends": "@semantic-release/apm-config" 97 | }, 98 | "commitlint": { 99 | "extends": [ 100 | "@commitlint/config-conventional" 101 | ] 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /spec/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | env: { 3 | atomtest: true, 4 | jasmine: true, 5 | }, 6 | rules: { 7 | "import/no-extraneous-dependencies": [ 8 | "error", 9 | { 10 | "devDependencies": true 11 | } 12 | ] 13 | } 14 | }; 15 | -------------------------------------------------------------------------------- /spec/fixtures/bad.rb: -------------------------------------------------------------------------------- 1 | def example 2 | payload = { 3 | :meta => { 4 | :envelope => { 5 | :token => session.token, 6 | } 7 | } 8 | } 9 | end 10 | 11 | fruit = ["mango", "apple", "orange"] 12 | 13 | fruit.each end |e| 14 | puts e 15 | end 16 | -------------------------------------------------------------------------------- /spec/fixtures/good.rb: -------------------------------------------------------------------------------- 1 | puts 'foo' 2 | -------------------------------------------------------------------------------- /spec/linter-ruby-spec.js: -------------------------------------------------------------------------------- 1 | 'use babel'; 2 | 3 | import { join } from 'path'; 4 | import { 5 | // eslint-disable-next-line no-unused-vars 6 | it, fit, wait, beforeEach, afterEach, 7 | } from 'jasmine-fix'; 8 | 9 | const goodPath = join(__dirname, 'fixtures', 'good.rb'); 10 | const badPath = join(__dirname, 'fixtures', 'bad.rb'); 11 | const { lint } = require('../lib/main.js').provideLinter(); 12 | 13 | describe('The Ruby provider for Linter', () => { 14 | beforeEach(async () => { 15 | // Info about this beforeEach() implementation: 16 | // https://github.com/AtomLinter/Meta/issues/15 17 | const activationPromise = atom.packages.activatePackage('linter-ruby'); 18 | 19 | await atom.packages.activatePackage('language-ruby'); 20 | await atom.workspace.open(goodPath); 21 | 22 | atom.packages.triggerDeferredActivationHooks(); 23 | await activationPromise; 24 | }); 25 | 26 | it('should be in the packages list', () => { 27 | expect(atom.packages.isPackageLoaded('linter-ruby')).toBe(true); 28 | }); 29 | 30 | it('should be an active package', () => { 31 | expect(atom.packages.isPackageActive('linter-ruby')).toBe(true); 32 | }); 33 | 34 | it('checks bad.rb and verifies the messages are correct', async () => { 35 | const editor = await atom.workspace.open(badPath); 36 | const messages = await lint(editor); 37 | 38 | expect(messages.length).toBe(2); 39 | 40 | expect(messages[0].severity).toBe('warning'); 41 | expect(messages[0].excerpt).toBe('assigned but unused variable - payload'); 42 | expect(messages[0].location.file).toBe(badPath); 43 | expect(messages[0].location.position).toEqual([[1, 2], [1, 13]]); 44 | 45 | expect(messages[1].severity).toBe('error'); 46 | expect(messages[1].excerpt).toBe('unexpected keyword_end, expecting end-of-input'); 47 | expect(messages[1].location.file).toBe(badPath); 48 | expect(messages[1].location.position).toEqual([[12, 0], [12, 18]]); 49 | }); 50 | 51 | it('checks good.rb and reports nothing wrong', async () => { 52 | const editor = await atom.workspace.open(goodPath); 53 | const messages = await lint(editor); 54 | expect(messages.length).toBe(0); 55 | }); 56 | }); 57 | --------------------------------------------------------------------------------