From 6327885325e223a76f79625d5d64981f70ae53fa Mon Sep 17 00:00:00 2001 From: Jon Schlinkert Date: Tue, 21 May 2024 04:44:43 -0400 Subject: [PATCH] update eslint. lint. --- .github/contributing.md | 58 ++++++++++++++++++++++++++++++++++++ .github/workflows/codeql.yml | 28 +++++++++++++++++ .github/workflows/test.yml | 41 +++++++++++++++++++++++++ .gitignore | 3 +- .travis.yml | 11 ------- bench/index.js | 2 +- package.json | 9 ++++-- test/custom-expand.js | 2 -- test/errors.js | 1 - test/invalid.js | 1 - test/matching.js | 2 -- test/options.js | 2 -- test/padding.js | 20 ++++++------- test/ranges.js | 6 ++-- test/special.js | 4 +-- test/steps.js | 8 ++--- test/support/exact.js | 2 +- test/verify-matches.js | 2 -- 18 files changed, 153 insertions(+), 49 deletions(-) create mode 100644 .github/contributing.md create mode 100644 .github/workflows/codeql.yml create mode 100644 .github/workflows/test.yml delete mode 100644 .travis.yml diff --git a/.github/contributing.md b/.github/contributing.md new file mode 100644 index 0000000..6e44636 --- /dev/null +++ b/.github/contributing.md @@ -0,0 +1,58 @@ +# Contributing to fill-range + +First and foremost, thank you! We appreciate that you want to contribute to fill-range, your time is valuable, and your contributions mean a lot to us. + +**What does "contributing" mean?** + +Creating an issue is the simplest form of contributing to a project. But there are many ways to contribute, including the following: + +- Updating or correcting documentation +- Feature requests +- Bug reports + +If you'd like to learn more about contributing in general, the [Guide to Idiomatic Contributing](https://github.com/jonschlinkert/idiomatic-contributing) has a lot of useful information. + +**Showing support for fill-range** + +Please keep in mind that open source software is built by people like you, who spend their free time creating things the rest the community can use. + +Don't have time to contribute? No worries, here are some other ways to show your support for fill-range: + +- star the [project](https://github.com/jonschlinkert/fill-range) +- tweet your support for fill-range + +## Issues + +### Before creating an issue + +Please try to determine if the issue is caused by an underlying library, and if so, create the issue there. Sometimes this is difficult to know. We only ask that you attempt to give a reasonable attempt to find out. Oftentimes the readme will have advice about where to go to create issues. + +Try to follow these guidelines + +- **Investigate the issue**: +- **Check the readme** - oftentimes you will find notes about creating issues, and where to go depending on the type of issue. +- Create the issue in the appropriate repository. + +### Creating an issue + +Please be as descriptive as possible when creating an issue. Give us the information we need to successfully answer your question or address your issue by answering the following in your issue: + +- **version**: please note the version of fill-range are you using +- **extensions, plugins, helpers, etc** (if applicable): please list any extensions you're using +- **error messages**: please paste any error messages into the issue, or a [gist](https://gist.github.com/) + +## Above and beyond + +Here are some tips for creating idiomatic issues. Taking just a little bit extra time will make your issue easier to read, easier to resolve, more likely to be found by others who have the same or similar issue in the future. + +- read the [Guide to Idiomatic Contributing](https://github.com/jonschlinkert/idiomatic-contributing) +- take some time to learn basic markdown. This [markdown cheatsheet](https://gist.github.com/jonschlinkert/5854601) is super helpful, as is the GitHub guide to [basic markdown](https://help.github.com/articles/markdown-basics/). +- Learn about [GitHub Flavored Markdown](https://help.github.com/articles/github-flavored-markdown/). And if you want to really go above and beyond, read [mastering markdown](https://guides.github.com/features/mastering-markdown/). +- use backticks to wrap code. This ensures that code will retain its format, making it much more readable to others +- use syntax highlighting by adding the correct language name after the first "code fence" + + +[node-glob]: https://github.com/isaacs/node-glob +[picomatch]: https://github.com/jonschlinkert/picomatch +[micromatch]: https://github.com/jonschlinkert/micromatch +[so]: http://stackoverflow.com/questions/tagged/fill-range diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..31696b7 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,28 @@ +name: "CodeQL" + +on: + push: + pull_request: + schedule: + - cron: "0 0 * * 0" + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: "javascript" + + - name: Autobuild + uses: github/codeql-action/autobuild@v1 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..4569606 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,41 @@ +name: CI +on: + - push + - pull_request + +env: + CI: true + FORCE_COLOR: 2 + +jobs: + run: + name: Node.js ${{ matrix.node }} @ ${{ matrix.os }} + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + node: [8, 10, 12, 14, 16, 18, 20, 22] + os: [ubuntu-latest, windows-latest, macOS-latest] + + steps: + - name: Clone repository + uses: actions/checkout@v2 + + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node }} + + - name: Install npm dependencies + run: npm install + + - name: Run tests + run: npm run test:ci + + - name: Run Coveralls + # `master` should be a tag but they don't have one + uses: coverallsapp/github-action@master + if: startsWith(matrix.os, 'ubuntu') && matrix.node == 14 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.gitignore b/.gitignore index f969a2c..df4f97a 100644 --- a/.gitignore +++ b/.gitignore @@ -27,4 +27,5 @@ vendor temp tmp TODO.md -package-lock.json \ No newline at end of file +package-lock.json +*.code-* diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 83fc9fb..0000000 --- a/.travis.yml +++ /dev/null @@ -1,11 +0,0 @@ -sudo: false -os: - - linux - - osx - - windows -language: node_js -node_js: - - node - - '10' - - '9' - - '8' diff --git a/bench/index.js b/bench/index.js index d8d9dbe..b15d2d2 100644 --- a/bench/index.js +++ b/bench/index.js @@ -11,7 +11,7 @@ const fill70 = require('..'); */ const cycle = (e, newline) => { - process.stdout.write(`\u001b[G ${e.target}${newline ? `\n` : ''}`); + process.stdout.write(`\u001b[G ${e.target}${newline ? '\n' : ''}`); }; const bench = (name, options) => { diff --git a/package.json b/package.json index 07d3076..d048f64 100644 --- a/package.json +++ b/package.json @@ -24,14 +24,19 @@ "node": ">=8" }, "scripts": { - "test": "mocha" + "lint": "eslint --cache --cache-location node_modules/.cache/.eslintcache --report-unused-disable-directives --ignore-path .gitignore .", + "mocha": "mocha --reporter dot", + "test": "npm run lint && npm run mocha", + "test:ci": "npm run test:cover", + "test:cover": "nyc npm run mocha" }, "dependencies": { "to-regex-range": "^5.0.1" }, "devDependencies": { "gulp-format-md": "^2.0.0", - "mocha": "^6.1.1" + "mocha": "^6.1.1", + "nyc": "^15.1.0" }, "keywords": [ "alpha", diff --git a/test/custom-expand.js b/test/custom-expand.js index dd7454e..b771568 100644 --- a/test/custom-expand.js +++ b/test/custom-expand.js @@ -1,7 +1,5 @@ 'use strict'; -require('mocha'); -const assert = require('assert'); const exact = require('./support/exact'); const fill = require('..'); diff --git a/test/errors.js b/test/errors.js index 976a468..1a689b5 100644 --- a/test/errors.js +++ b/test/errors.js @@ -1,6 +1,5 @@ 'use strict'; -require('mocha'); const assert = require('assert'); const fill = require('..'); diff --git a/test/invalid.js b/test/invalid.js index 07f2721..bc2f3bc 100644 --- a/test/invalid.js +++ b/test/invalid.js @@ -1,6 +1,5 @@ 'use strict'; -require('mocha'); const assert = require('assert'); const fill = require('..'); diff --git a/test/matching.js b/test/matching.js index f5d5e2b..b8283bb 100644 --- a/test/matching.js +++ b/test/matching.js @@ -1,8 +1,6 @@ 'use strict'; -require('mocha'); const assert = require('assert'); -const exact = require('./support/exact'); const fill = require('..'); const toRegex = (...args) => new RegExp(`^(${fill(...args)})$`); diff --git a/test/options.js b/test/options.js index 15849f7..2c7ea62 100644 --- a/test/options.js +++ b/test/options.js @@ -1,7 +1,5 @@ 'use strict'; -require('mocha'); -const util = require('util'); const assert = require('assert'); const exact = require('./support/exact'); const fill = require('..'); diff --git a/test/padding.js b/test/padding.js index a416c74..c763b49 100644 --- a/test/padding.js +++ b/test/padding.js @@ -1,7 +1,5 @@ 'use strict'; -require('mocha'); -const util = require('util'); const assert = require('assert').strict; const fill = require('..'); @@ -12,8 +10,8 @@ describe('padding: numbers', () => { assert.deepEqual(fill('1', '03'), ['01', '02', '03']); assert.deepEqual(fill('0001', '0003'), ['0001', '0002', '0003']); assert.deepEqual(fill('-10', '00'), ['-10', '-09', '-08', '-07', '-06', '-05', '-04', '-03', '-02', '-01', '000']); - assert.deepEqual(fill('05', '010'), ['005','006','007','008','009','010']); - assert.deepEqual(fill('05', '100'), ['005','006','007','008','009','010','011','012','013','014','015','016','017','018','019','020','021','022','023','024','025','026','027','028','029','030','031','032','033','034','035','036','037','038','039','040','041','042','043','044','045','046','047','048','049','050','051','052','053','054','055','056','057','058','059','060','061','062','063','064','065','066','067','068','069','070','071','072','073','074','075','076','077','078','079','080','081','082','083','084','085','086','087','088','089','090','091','092','093','094','095','096','097','098','099','100']); + assert.deepEqual(fill('05', '010'), ['005', '006', '007', '008', '009', '010']); + assert.deepEqual(fill('05', '100'), ['005', '006', '007', '008', '009', '010', '011', '012', '013', '014', '015', '016', '017', '018', '019', '020', '021', '022', '023', '024', '025', '026', '027', '028', '029', '030', '031', '032', '033', '034', '035', '036', '037', '038', '039', '040', '041', '042', '043', '044', '045', '046', '047', '048', '049', '050', '051', '052', '053', '054', '055', '056', '057', '058', '059', '060', '061', '062', '063', '064', '065', '066', '067', '068', '069', '070', '071', '072', '073', '074', '075', '076', '077', '078', '079', '080', '081', '082', '083', '084', '085', '086', '087', '088', '089', '090', '091', '092', '093', '094', '095', '096', '097', '098', '099', '100']); }); it('should pad decremented numbers:', () => { @@ -46,13 +44,13 @@ describe('padding: numbers', () => { }); it('should pad stepped numbers', () => { - assert.deepEqual(fill('1', '05', '3'), ['01','04']); - assert.deepEqual(fill('1', '5', '03'), ['01','04']); - assert.deepEqual(fill('1', '5', '0003'), ['0001','0004']); - assert.deepEqual(fill('1', '005', '3'), ['001','004']); - assert.deepEqual(fill('00', '1000', '200'), ['0000','0200', '0400', '0600', '0800', '1000']); - assert.deepEqual(fill('0', '01000', '200'), ['00000','00200', '00400', '00600', '00800', '01000']); - assert.deepEqual(fill('001', '5', '3'), ['001','004']); + assert.deepEqual(fill('1', '05', '3'), ['01', '04']); + assert.deepEqual(fill('1', '5', '03'), ['01', '04']); + assert.deepEqual(fill('1', '5', '0003'), ['0001', '0004']); + assert.deepEqual(fill('1', '005', '3'), ['001', '004']); + assert.deepEqual(fill('00', '1000', '200'), ['0000', '0200', '0400', '0600', '0800', '1000']); + assert.deepEqual(fill('0', '01000', '200'), ['00000', '00200', '00400', '00600', '00800', '01000']); + assert.deepEqual(fill('001', '5', '3'), ['001', '004']); assert.deepEqual(fill('02', '10', 2), ['02', '04', '06', '08', '10']); assert.deepEqual(fill('002', '10', 2), ['002', '004', '006', '008', '010']); assert.deepEqual(fill('002', '010', 2), ['002', '004', '006', '008', '010']); diff --git a/test/ranges.js b/test/ranges.js index 7122860..e146046 100644 --- a/test/ranges.js +++ b/test/ranges.js @@ -1,7 +1,5 @@ 'use strict'; -require('mocha'); -const assert = require('assert'); const exact = require('./support/exact'); const fill = require('..'); @@ -17,7 +15,7 @@ describe('ranges', () => { it('should decrement alphabetical ranges', () => { exact(fill('E', 'A'), ['E', 'D', 'C', 'B', 'A']); - exact(fill('a', 'C'), ['a','`','_','^',']',"\\",'[','Z','Y','X','W','V','U','T','S','R','Q','P','O','N','M','L','K','J','I','H','G','F','E','D','C']); + exact(fill('a', 'C'), ['a', '`', '_', '^', ']', '\\', '[', 'Z', 'Y', 'X', 'W', 'V', 'U', 'T', 'S', 'R', 'Q', 'P', 'O', 'N', 'M', 'L', 'K', 'J', 'I', 'H', 'G', 'F', 'E', 'D', 'C']); exact(fill('z', 'm'), ['z', 'y', 'x', 'w', 'v', 'u', 't', 's', 'r', 'q', 'p', 'o', 'n', 'm']); }); }); @@ -49,7 +47,7 @@ describe('ranges', () => { it('should decrement alphabetical ranges', () => { exact(fill('E', 'A'), ['E', 'D', 'C', 'B', 'A']); - exact(fill('a', 'C'), ['a','`','_','^',']',"\\",'[','Z','Y','X','W','V','U','T','S','R','Q','P','O','N','M','L','K','J','I','H','G','F','E','D','C']); + exact(fill('a', 'C'), ['a', '`', '_', '^', ']', '\\', '[', 'Z', 'Y', 'X', 'W', 'V', 'U', 'T', 'S', 'R', 'Q', 'P', 'O', 'N', 'M', 'L', 'K', 'J', 'I', 'H', 'G', 'F', 'E', 'D', 'C']); exact(fill('z', 'm'), ['z', 'y', 'x', 'w', 'v', 'u', 't', 's', 'r', 'q', 'p', 'o', 'n', 'm']); }); }); diff --git a/test/special.js b/test/special.js index 61b6460..4f55a2b 100644 --- a/test/special.js +++ b/test/special.js @@ -1,7 +1,5 @@ 'use strict'; -require('mocha'); -const assert = require('assert'); const exact = require('./support/exact'); const fill = require('..'); @@ -23,7 +21,7 @@ describe('special cases', () => { }); it('should adjust padding for negative numbers:', () => { - exact(fill('-01', '5'), ['-01','000','001','002','003','004','005']); + exact(fill('-01', '5'), ['-01', '000', '001', '002', '003', '004', '005']); }); }); }); diff --git a/test/steps.js b/test/steps.js index 606bee9..5abdfa8 100644 --- a/test/steps.js +++ b/test/steps.js @@ -1,7 +1,5 @@ 'use strict'; -require('mocha'); -const assert = require('assert'); const exact = require('./support/exact'); const fill = require('..'); @@ -10,7 +8,7 @@ describe('steps', () => { it('should increment ranges using the given step', () => { exact(fill('1', '10', '1'), ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']); exact(fill('1', '10', '2'), ['1', '3', '5', '7', '9']); - exact(fill('0', '1000', '200'), ['0','200', '400', '600', '800', '1000']); + exact(fill('0', '1000', '200'), ['0', '200', '400', '600', '800', '1000']); exact(fill('1', '10', 2), ['1', '3', '5', '7', '9']); exact(fill('1', '20', '2'), ['1', '3', '5', '7', '9', '11', '13', '15', '17', '19']); exact(fill('1', '20', '20'), ['1']); @@ -65,7 +63,7 @@ describe('steps', () => { describe('steps: letters', () => { it('should use increments with alphabetical ranges', () => { exact(fill('z', 'a', -2), ['z', 'x', 'v', 't', 'r', 'p', 'n', 'l', 'j', 'h', 'f', 'd', 'b']); - exact(fill('a', 'e', 2), ['a','c', 'e']); + exact(fill('a', 'e', 2), ['a', 'c', 'e']); exact(fill('E', 'A', 2), ['E', 'C', 'A']); }); }); @@ -73,7 +71,7 @@ describe('steps', () => { describe('options: step', () => { it('should use the step defined on the options:', () => { let options = { step: 2 }; - exact(fill('a', 'e', options), ['a','c', 'e']); + exact(fill('a', 'e', options), ['a', 'c', 'e']); exact(fill('E', 'A', options), ['E', 'C', 'A']); }); }); diff --git a/test/support/exact.js b/test/support/exact.js index f205f03..012add6 100644 --- a/test/support/exact.js +++ b/test/support/exact.js @@ -1,7 +1,7 @@ 'use strict'; -const util = require('util'); const assert = require('assert'); +const util = require('util'); module.exports = (actual, expected) => { assert(Array.isArray(actual)); diff --git a/test/verify-matches.js b/test/verify-matches.js index 08644cf..f0fb671 100644 --- a/test/verify-matches.js +++ b/test/verify-matches.js @@ -7,10 +7,8 @@ 'use strict'; -require('mocha'); const assert = require('assert'); const expand = require('./support/expand'); -const exact = require('./support/exact'); const fill = require('..'); let count = 0;