Skip to content

Commit

Permalink
chore: use eslint-config-ipfs (#3287)
Browse files Browse the repository at this point in the history
Uses shared eslint config `eslint-config-ipfs` by integrating ipfs/aegir#638. Shared config uses new jsdoc plugin enabling use to remove bunch of `eslint-disable-next-line valid-jsdoc` comments. On the flip side it adds bit more requirements for structuring jsdoc comments. Most changes are generated automatically by eslint with `--fix` flag.

This change also intentionally adds `.eslintrc` files to every package with content `{ "extends": "ipfs" }`, so that all the tools that support eslint pick up desired configuration.  `eslint-config-ipfs` package itself isn't added to dependencies, because it gets installed as `aegir` dependency.

Co-authored-by: achingbrain <[email protected]>
  • Loading branch information
Gozala and achingbrain authored Oct 6, 2020
1 parent 37c0cac commit 916fe40
Show file tree
Hide file tree
Showing 16 changed files with 13 additions and 22 deletions.
3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "ipfs"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"uint8arrays": "^1.1.0"
},
"devDependencies": {
"aegir": "^26.0.0",
"aegir": "^27.0.0",
"cross-env": "^7.0.0",
"go-ipfs": "^0.7.0",
"interface-ipfs-core": "^0.140.0",
Expand Down
2 changes: 1 addition & 1 deletion src/add-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const anySignal = require('any-signal')
const AbortController = require('abort-controller').default

module.exports = configure((api) => {
// eslint-disable-next-line valid-jsdoc
/**
* @type {import('../../ipfs/src/core/components/add-all').AddAll<import('.').HttpOptions>}
*/
Expand Down Expand Up @@ -51,6 +50,7 @@ module.exports = configure((api) => {
*/

/**
* @param {*} input
* @returns {UnixFSEntry}
*/
function toCoreInterface ({ name, hash, size, mode, mtime, mtimeNsecs }) {
Expand Down
2 changes: 0 additions & 2 deletions src/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ const configure = require('./lib/configure')
* @typedef {import("./lib/core").ClientOptions} ClientOptions
*/

// eslint-disable-next-line valid-jsdoc
/**
* @param {ClientOptions} options
*/
module.exports = (options) => {
const all = addAll(options)

return configure(() => {
// eslint-disable-next-line valid-jsdoc
/**
* @type {import('../../ipfs/src/core/components/add').Add<import('.').HttpOptions>}
*/
Expand Down
1 change: 0 additions & 1 deletion src/bitswap/stat.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const configure = require('../lib/configure')
const toUrlSearchParams = require('../lib/to-url-search-params')

module.exports = configure(api => {
// eslint-disable-next-line valid-jsdoc
/**
* @type {import('../../../ipfs/src/core/components/bitswap/stat').Stat<import('..').HttpOptions>}
*/
Expand Down
1 change: 0 additions & 1 deletion src/bitswap/unwant.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const configure = require('../lib/configure')
const toUrlSearchParams = require('../lib/to-url-search-params')

module.exports = configure(api => {
// eslint-disable-next-line valid-jsdoc
/**
* @type {import('../../../ipfs/src/core/components/bitswap/unwant').Unwant<import('..').HttpOptions>}
*/
Expand Down
1 change: 0 additions & 1 deletion src/bitswap/wantlist-for-peer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const configure = require('../lib/configure')
const toUrlSearchParams = require('../lib/to-url-search-params')

module.exports = configure(api => {
// eslint-disable-next-line valid-jsdoc
/**
* @type {import('../../../ipfs/src/core/components/bitswap/wantlist-for-peer').WantlistForPeer<import('..').HttpOptions>}
*/
Expand Down
1 change: 0 additions & 1 deletion src/bitswap/wantlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const configure = require('../lib/configure')
const toUrlSearchParams = require('../lib/to-url-search-params')

module.exports = configure(api => {
// eslint-disable-next-line valid-jsdoc
/**
* @type {import('../../../ipfs/src/core/components/bitswap/wantlist').WantlistFn<import('..').HttpOptions>}
*/
Expand Down
1 change: 0 additions & 1 deletion src/block/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const configure = require('../lib/configure')
const toUrlSearchParams = require('../lib/to-url-search-params')

module.exports = configure(api => {
// eslint-disable-next-line valid-jsdoc
/**
* @type {import('../../../ipfs/src/core/components/block/get').BlockGet<import('..').HttpOptions>}
*/
Expand Down
1 change: 0 additions & 1 deletion src/block/put.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const anySignal = require('any-signal')
const AbortController = require('abort-controller').default

module.exports = configure(api => {
// eslint-disable-next-line valid-jsdoc
/**
* @type {import('../../../ipfs/src/core/components/block/put').BlockPut<import('..').HttpOptions>}
*/
Expand Down
1 change: 0 additions & 1 deletion src/id.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const configure = require('./lib/configure')
const toUrlSearchParams = require('./lib/to-url-search-params')

module.exports = configure(api => {
// eslint-disable-next-line valid-jsdoc
/**
* @type {import('../../ipfs/src/core/components/id').Id<import('.').HttpOptions>}
*/
Expand Down
1 change: 0 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const urlSource = require('ipfs-utils/src/files/url-source')
* @property {(format: string) => Promise<any>} [ipld.loadFormat] - an async function that takes the name of an [IPLD format](https://github.com/ipld/interface-ipld-format) as a string and should return the implementation of that codec
*/

// eslint-disable-next-line valid-jsdoc
/**
* @param {ClientOptions} options
*/
Expand Down
14 changes: 7 additions & 7 deletions src/lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@ const parseTimeout = (value) => {

/**
* @typedef {Object} ClientOptions
* @prop {string} [host]
* @prop {number} [port]
* @prop {string} [protocol]
* @prop {Headers|Record<string, string>} [headers] - Request headers.
* @prop {number|string} [timeout] - Amount of time until request should timeout in ms or humand readable. https://www.npmjs.com/package/parse-duration for valid string values.
* @prop {string} [apiPath] - Path to the API.
* @prop {URL|string} [url] - Full API URL.
* @property {string} [host]
* @property {number} [port]
* @property {string} [protocol]
* @property {Headers|Record<string, string>} [headers] - Request headers.
* @property {number|string} [timeout] - Amount of time until request should timeout in ms or humand readable. https://www.npmjs.com/package/parse-duration for valid string values.
* @property {string} [apiPath] - Path to the API.
* @property {URL|string} [url] - Full API URL.
*/

class Client extends HTTP {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/to-url-search-params.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const modeToString = require('./mode-to-string')
const mtimeToObject = require('./mtime-to-object')

/**
* @param {object} params
* @param {*} params
* @returns {URLSearchParams}
*/
module.exports = ({ arg, searchParams, hashAlg, mtime, mode, ...options } = {}) => {
Expand Down
1 change: 0 additions & 1 deletion src/resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const configure = require('./lib/configure')
const toUrlSearchParams = require('./lib/to-url-search-params')

module.exports = configure(api => {
// eslint-disable-next-line valid-jsdoc
/**
* @type {import('../../ipfs/src/core/components/resolve').Resolve<import('.').HttpOptions>}
*/
Expand Down
1 change: 0 additions & 1 deletion src/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const configure = require('./lib/configure')
const toUrlSearchParams = require('./lib/to-url-search-params')

module.exports = configure(api => {
// eslint-disable-next-line valid-jsdoc
/**
* @type {import('../../ipfs/src/core/components/version').Version<import('.').HttpOptions>}
*/
Expand Down

0 comments on commit 916fe40

Please sign in to comment.