From 254002b43199745968646ea409037760e0b80d1c Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Sat, 18 Jun 2022 17:14:31 +0200 Subject: [PATCH] Deprecate --- .editorconfig | 9 -- .github/workflows/main.yml | 22 --- .gitignore | 4 - .npmrc | 1 - .prettierignore | 2 - index.js | 140 -------------------- license | 22 --- package.json | 66 +-------- readme.md | 221 +------------------------------ test/engine-example/index.js | 21 --- test/engine-example/package.json | 19 --- test/fixtures/invalid.md | 6 - test/index.js | 54 -------- 13 files changed, 5 insertions(+), 582 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .github/workflows/main.yml delete mode 100644 .gitignore delete mode 100644 .npmrc delete mode 100644 .prettierignore delete mode 100644 index.js delete mode 100644 license delete mode 100644 test/engine-example/index.js delete mode 100644 test/engine-example/package.json delete mode 100644 test/fixtures/invalid.md delete mode 100644 test/index.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index c6c8b36..0000000 --- a/.editorconfig +++ /dev/null @@ -1,9 +0,0 @@ -root = true - -[*] -indent_style = space -indent_size = 2 -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index c45058d..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: main -on: - - pull_request - - push -jobs: - main: - name: ${{matrix.node}} - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: dcodeIO/setup-node-nvm@master - with: - node-version: ${{matrix.node}} - - uses: UziTech/action-setup-atom@v1 - - run: npm install - - run: npm test - - uses: codecov/codecov-action@v1 - strategy: - matrix: - node: - - lts/dubnium - - node diff --git a/.gitignore b/.gitignore deleted file mode 100644 index fad2638..0000000 --- a/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -.DS_Store -*.log -node_modules/ -yarn.lock diff --git a/.npmrc b/.npmrc deleted file mode 100644 index 43c97e7..0000000 --- a/.npmrc +++ /dev/null @@ -1 +0,0 @@ -package-lock=false diff --git a/.prettierignore b/.prettierignore deleted file mode 100644 index 3790a0d..0000000 --- a/.prettierignore +++ /dev/null @@ -1,2 +0,0 @@ -*.json -*.md diff --git a/index.js b/index.js deleted file mode 100644 index 6615d48..0000000 --- a/index.js +++ /dev/null @@ -1,140 +0,0 @@ -'use strict' - -/* global atom */ - -var path = require('path') -var PassThrough = require('stream').PassThrough -var findRoot = require('find-root') -var vfile = require('to-vfile') -var engine = require('unified-engine') - -var root = process.cwd() - -var running = 0 - -var severities = { - true: 'error', - false: 'warning', - null: 'info', - undefined: 'info' -} - -module.exports = atomEngine - -// `lint`. -function atomEngine(options) { - return lint - - // Handle on-the-fly or on-save (depending on the global atom-linter settings) - // events. - // See: - function lint(editor) { - var filePath = editor.getPath() - var projects = atom.project.getPaths() - var file = vfile(filePath) - var matches - var cwd - - if (!filePath) { - return Promise.resolve([]) - } - - running++ - - // Set a logical CWD. - matches = projects - // Keep projects with `file.path` inside. - .filter(function (project) { - return filePath.slice(0, project.length + 1) === project + path.sep - }) - // Sort the longest first. - .sort(function (left, right) { - return right.length - left.length - }) - - cwd = matches[0] || path.dirname(filePath) - - try { - cwd = findRoot(cwd) - } catch (_) {} - - return new Promise(executor) - - function executor(resolve, reject) { - file.contents = editor.getText() - - try { - process.chdir(cwd) - } catch (_) {} - - engine( - Object.assign({}, options, { - output: false, - out: false, - streamError: new PassThrough(), - streamOut: new PassThrough(), - files: [file] - }), - onrun - ) - - function onrun(err) { - running-- - - if (running === 0) { - process.chdir(root) - } - - if (err) { - reject(err) - } else { - resolve(file.messages.map(transform, editor)) - } - } - } - } -} - -// Transform VFile messages nested-tuple. -function transform(message) { - var editor = this - var origin = [message.source, message.ruleId].filter(Boolean) - var excerpt = message.stack || undefined - - if (origin[0] && origin[0] === origin[1]) { - origin.pop() - } - - origin = origin.join(':') - - if (!excerpt) { - excerpt = message.reason.replace(/“([^”]+)”/g, '`$1`') - } - - if (origin) { - excerpt += ' (' + origin + ')' - } - - return { - severity: severities[message.fatal], - location: {file: editor.getPath(), position: toRange(message.location)}, - url: message.url || undefined, - excerpt: excerpt, - description: message.note - } -} - -// Transform a (stringified) vfile range to a linter nested-tuple. -function toRange(location) { - var startLine = Number(location.start.line) - 1 - var startColumn = Number(location.start.column) - 1 - var endLine = location.end.line ? Number(location.end.line) - 1 : startLine - var endColumn = location.end.column - ? Number(location.end.column) - 1 - : startColumn - - return [ - [startLine, startColumn], - [endLine, endColumn] - ] -} diff --git a/license b/license deleted file mode 100644 index 8d8660d..0000000 --- a/license +++ /dev/null @@ -1,22 +0,0 @@ -(The MIT License) - -Copyright (c) 2016 Titus Wormer - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/package.json b/package.json index 6882b80..96c8150 100644 --- a/package.json +++ b/package.json @@ -1,68 +1,6 @@ { "name": "unified-engine-atom", - "version": "9.0.0", - "description": "unified engine to create an Atom Linters for a processor", - "license": "MIT", - "keywords": [ - "unified", - "engine", - "atom", - "linter", - "processor" - ], + "version": "10.0.0", "repository": "unifiedjs/unified-engine-atom", - "bugs": "https://github.com/unifiedjs/unified-engine-atom/issues", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - }, - "author": "Titus Wormer (https://wooorm.com)", - "contributors": [ - "Titus Wormer (https://wooorm.com)", - "Jonathan Haines " - ], - "files": [ - "index.js" - ], - "dependencies": { - "find-root": "^1.0.0", - "to-vfile": "^6.0.0", - "unified-engine": "^8.0.0" - }, - "devDependencies": { - "atom-tap-test-runner": "^7.0.0", - "prettier": "^2.0.0", - "remark": "^13.0.0", - "remark-cli": "^9.0.0", - "remark-preset-wooorm": "^8.0.0", - "tape": "^5.0.0", - "xo": "^0.36.0" - }, - "scripts": { - "format": "remark . -qfo --ignore-pattern \"test/\" && prettier . -w --loglevel warn && xo --fix", - "test-api": "atom --test test", - "test": "npm run format && npm run test-api" - }, - "atomTestRunner": "atom-tap-test-runner", - "prettier": { - "tabWidth": 2, - "useTabs": false, - "singleQuote": true, - "bracketSpacing": false, - "semi": false, - "trailingComma": "none" - }, - "xo": { - "prettier": true, - "esnext": false, - "rules": { - "unicorn/no-fn-reference-in-iterator": "off", - "unicorn/prefer-optional-catch-binding": "off" - } - }, - "remarkConfig": { - "plugins": [ - "preset-wooorm" - ] - } + "bugs": "https://github.com/unifiedjs/unified-engine-atom/issues" } diff --git a/readme.md b/readme.md index bd1e9fa..f0241ba 100644 --- a/readme.md +++ b/readme.md @@ -1,221 +1,6 @@ # unified-engine-atom -[![Build][build-badge]][build] -[![Downloads][downloads-badge]][downloads] -[![Sponsors][sponsors-badge]][collective] -[![Backers][backers-badge]][collective] -[![Chat][chat-badge]][chat] +Deprecated. +[Atom is archived](https://github.blog/2022-06-08-sunsetting-atom/). -[**unified**][unified] engine to create an [Atom Linter][linter]s for a -[processor][unified-processor]. -Wrapper around the [`unifiedjs/unified-engine`][engine] to run it from Atom. - -## Install - -[npm][]: - -```sh -npm install unified-engine-atom -``` - -## Use - -```js -var engine = require('unified-engine-atom') - -module.exports.provideLinter = linter - -function linter() { - return { - grammarScopes: ['source.gfm', 'source.pfm', 'text.md'], - name: 'remark', - scope: 'file', - lintsOnChange: true, - lint: engine({ - processor: require('remark'), - rcName: '.remarkrc', - packageField: 'remarkConfig', - ignoreName: '.remarkignore', - pluginPrefix: 'remark' - }) - } -} -``` - -## API - -### `engine(options)` - -Create a `lint` function for use in an AtomLinter package. -Read more about linters in the [Linter Docs][docs]. - -##### `options` - -###### [`options.processor`][processor] - -unified processor to transform files ([`Processor`][unified-processor], -required). - -###### [`options.rcName`][rc-name] - -Name of configuration files to load (`string`, optional). - -###### [`options.packageField`][package-field] - -Property at which configuration can be found in `package.json` files (`string`, -optional). - -###### [`options.detectConfig`][detect-config] - -Whether to search for configuration files (`boolean`, default: whether `rcName` -or `packageField` is given). - -###### [`options.rcPath`][rc-path] - -File-path to a configuration file to load (`string`, optional). - -###### [`options.settings`][settings] - -Configuration for the parser and compiler of the processor (`Object`, optional). - -###### [`options.ignoreName`][ignore-name] - -Name of ignore files to load (`string`, optional). - -###### [`options.detectIgnore`][detect-ignore] - -Whether to search for ignore files (`boolean`, default: whether -`ignoreName` is given). - -###### [`options.ignorePath`][ignore-path] - -File-path to an ignore file to load (`string`, optional). - -###### [`options.ignorePathResolveFrom`][ignore-path-resolve-from] - -Whether to resolve patterns in `ignorePath` relative to its directory or the -current working directory (`'dir'` or `'cwd'`, default: `'dir'`). - -###### [`options.ignorePatterns`][ignore-patterns] - -Extra patterns to ignore in combination with `ignorePath` or found ignores -(`Array.`, optional). - -###### [`options.silentlyIgnore`][silently-ignore] - -Skip given files if they are ignored (`boolean`, default: `false`). - -###### [`options.plugins`][plugins] - -Map of plugin names or paths and options to use (`Object`, optional). - -###### [`options.pluginPrefix`][plugin-prefix] - -When given, optional prefix to use when searching for plugins (`string`, -optional). - -###### [`options.configTransform`][config-transform] - -Transform config files from a different schema (`Function`, optional). - -##### Returns - -`Function` — Can be used as `provider.lint`, where `provider` is the returned -value of `provideLinter`. -This function takes an Atom `Editor` instance, resolves an array of -[`LinterMessages`][messages], or rejects a fatal `Error`. - -## Todo - -* [ ] If anyone knows how to add coverage to Atom tests, I’d love to - hear about it. - -## Contribute - -See [`contributing.md`][contributing] in [`unifiedjs/.github`][health] for ways -to get started. -See [`support.md`][support] for ways to get help. - -This project has a [code of conduct][coc]. -By interacting with this repository, organization, or community you agree to -abide by its terms. - -## License - -[MIT][license] © [Titus Wormer][author] - - - -[build-badge]: https://github.com/unifiedjs/unified-engine-atom/workflows/main/badge.svg - -[build]: https://github.com/unifiedjs/unified-engine-atom/actions - -[downloads-badge]: https://img.shields.io/npm/dm/unified-engine-atom.svg - -[downloads]: https://www.npmjs.com/package/unified-engine-atom - -[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg - -[backers-badge]: https://opencollective.com/unified/backers/badge.svg - -[collective]: https://opencollective.com/unified - -[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg - -[chat]: https://github.com/unifiedjs/unified/discussions - -[npm]: https://docs.npmjs.com/cli/install - -[health]: https://github.com/unifiedjs/.github - -[contributing]: https://github.com/unifiedjs/.github/blob/HEAD/contributing.md - -[support]: https://github.com/unifiedjs/.github/blob/HEAD/support.md - -[coc]: https://github.com/unifiedjs/.github/blob/HEAD/code-of-conduct.md - -[license]: license - -[author]: https://wooorm.com - -[unified]: https://github.com/unifiedjs/unified - -[engine]: https://github.com/unifiedjs/unified-engine - -[linter]: https://github.com/steelbrain/linter - -[docs]: https://github.com/steelbrain/linter/tree/HEAD/docs - -[messages]: https://github.com/steelbrain/linter/blob/HEAD/docs/types/linter-message-v2.md - -[unified-processor]: https://github.com/unifiedjs/unified#processor - -[processor]: https://github.com/unifiedjs/unified-engine/blob/HEAD/doc/options.md#optionsprocessor - -[detect-config]: https://github.com/unifiedjs/unified-engine/blob/HEAD/doc/options.md#optionsdetectconfig - -[rc-name]: https://github.com/unifiedjs/unified-engine/blob/HEAD/doc/options.md#optionsrcname - -[package-field]: https://github.com/unifiedjs/unified-engine/blob/HEAD/doc/options.md#optionspackagefield - -[rc-path]: https://github.com/unifiedjs/unified-engine/blob/HEAD/doc/options.md#optionsrcpath - -[settings]: https://github.com/unifiedjs/unified-engine/blob/HEAD/doc/options.md#optionssettings - -[detect-ignore]: https://github.com/unifiedjs/unified-engine/blob/HEAD/doc/options.md#optionsdetectignore - -[ignore-name]: https://github.com/unifiedjs/unified-engine/blob/HEAD/doc/options.md#optionsignorename - -[ignore-path]: https://github.com/unifiedjs/unified-engine/blob/HEAD/doc/options.md#optionsignorepath - -[ignore-path-resolve-from]: https://github.com/unifiedjs/unified-engine/blob/HEAD/doc/options.md#optionsignorepathresolvefrom - -[ignore-patterns]: https://github.com/unifiedjs/unified-engine/blob/HEAD/doc/options.md#optionsignorepatterns - -[silently-ignore]: https://github.com/unifiedjs/unified-engine/blob/HEAD/doc/options.md#optionssilentlyignore - -[plugin-prefix]: https://github.com/unifiedjs/unified-engine/blob/HEAD/doc/options.md#optionspluginprefix - -[plugins]: https://github.com/unifiedjs/unified-engine/blob/HEAD/doc/options.md#optionsplugins - -[config-transform]: https://github.com/unifiedjs/unified-engine/blob/HEAD/doc/options.md#optionsconfigtransform +[Git is still intact](https://github.com/unifiedjs/unified-engine-atom/tree/605326d). diff --git a/test/engine-example/index.js b/test/engine-example/index.js deleted file mode 100644 index a31a4a5..0000000 --- a/test/engine-example/index.js +++ /dev/null @@ -1,21 +0,0 @@ -'use strict' - -var engine = require('../..') - -module.exports.provideLinter = linter - -function linter() { - return { - grammarScopes: ['source.gfm', 'source.pfm', 'text.md'], - name: 'remark', - scope: 'file', - lintsOnChange: true, - lint: engine({ - processor: require('../../node_modules/remark'), - rcName: '.remarkrc', - packageField: 'remarkConfig', - ignoreName: '.remarkignore', - pluginPrefix: 'remark' - }) - } -} diff --git a/test/engine-example/package.json b/test/engine-example/package.json deleted file mode 100644 index 7695e7e..0000000 --- a/test/engine-example/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "engine-example", - "private": true, - "version": "0.0.0", - "description": "", - "scripts": {}, - "keywords": [], - "license": "MIT", - "engines": {}, - "dependencies": {}, - "devDependencies": {}, - "providedServices": { - "linter": { - "versions": { - "2.0.0": "provideLinter" - } - } - } -} diff --git a/test/fixtures/invalid.md b/test/fixtures/invalid.md deleted file mode 100644 index 90b88da..0000000 --- a/test/fixtures/invalid.md +++ /dev/null @@ -1,6 +0,0 @@ -This is... - - -...invalid. - -And here’s a link to an invalid [heading](#heading) diff --git a/test/index.js b/test/index.js deleted file mode 100644 index c048204..0000000 --- a/test/index.js +++ /dev/null @@ -1,54 +0,0 @@ -'use strict' - -/* global atom */ - -var path = require('path') -var test = require('tape') -var lint = require('./engine-example') - -var join = path.join - -test('unified-engine-atom', function (t) { - t.plan(2) - - atom.workspace.destroyActivePaneItem() - - Promise.resolve() - .then(function () { - return atom.packages.activatePackage(join(__dirname, 'engine-example')) - }) - .then(function () { - return atom.packages.activatePackage('language-gfm') - }) - .then(function () { - return atom.workspace.open( - join(path.resolve(__dirname, '..'), 'readme.md') - ) - }) - .then(function (editor) { - return lint.provideLinter().lint(editor) - }) - .then(function (messages) { - t.equal(messages.length, 0, 'should start out without messages') - }) - .then(function () { - return atom.workspace.open(join(__dirname, 'fixtures', 'invalid.md')) - }) - .then(function (editor) { - return lint.provideLinter().lint(editor) - }) - .then(function (messages) { - t.deepEqual( - messages.map(flatten), - [ - 'Remove 1 line before node (remark-lint:no-consecutive-blank-lines)', - 'Link to unknown heading: `heading` (remark-validate-links:missing-heading)' - ], - 'should emit messages' - ) - }) -}) - -function flatten(message) { - return message.description || message.excerpt -}