Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 43 additions & 1 deletion eslint.flat.config.js → eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,26 @@

// MODULES //

var path = require( 'path' );
var globals = require( 'globals' );
var tsParser = require( '@typescript-eslint/parser' );
var tsPlugin = require( '@typescript-eslint/eslint-plugin' );
var stylisticTs = require( '@stylistic/eslint-plugin-ts' );
var pluginN = require( 'eslint-plugin-n' );
var pluginCspell = require( '@cspell/eslint-plugin' );
var pluginJsdoc = require( 'eslint-plugin-jsdoc' );
var pluginImport = require( 'eslint-plugin-import' );
var pluginExpectType = require( 'eslint-plugin-expect-type' );
var assign = require( './lib/node_modules/@stdlib/object/assign' );
var stdlibPlugin = require( './lib/node_modules/@stdlib/_tools/eslint/rules/scripts/plugin.js' );
var restrictedSyntaxConfig = require( './etc/eslint/overrides/restricted_syntax.js' );
var rules = require( './etc/eslint/rules' );
var tsRules = require( './etc/eslint/rules/typescript.js' );


// VARIABLES //

var tsGlobalVars;
var globalVars;
var config;

Expand All @@ -42,6 +50,7 @@ var config;

globalVars = assign( {}, globals.browser, globals.node );
globalVars = assign( globalVars, globals.commonjs, globals.worker );
tsGlobalVars = assign( {}, globals.browser, globals.node );

config = [
// Global ignores:
Expand All @@ -50,7 +59,10 @@ config = [
'**/build/',
'**/reports/',
'dist/',
'.git*'
'.git*',

// Un-ignore stdlib source (nested `node_modules` directories remain ignored by ESLint's defaults):
'!lib/node_modules/'
]
},

Expand Down Expand Up @@ -122,6 +134,36 @@ config = [
}],
'no-restricted-syntax': restrictedSyntaxConfig
}
},

// TypeScript declarations:
{
'files': [ '**/*.d.ts' ],
'languageOptions': {
'parser': tsParser,
'sourceType': 'module',
'parserOptions': {
'project': path.join( __dirname, 'tsconfig.json' )
},
'globals': tsGlobalVars
},
'plugins': {
'@typescript-eslint': tsPlugin,
'@stylistic/ts': stylisticTs,
'jsdoc': pluginJsdoc,
'import': pluginImport,
'expect-type': pluginExpectType,
'stdlib': stdlibPlugin
},
'rules': tsRules
},

// TypeScript test files:
{
'files': [ '**/test/**/*.ts' ],
'rules': {
'jsdoc/require-jsdoc': 'off'
}
}
];

Expand Down
2 changes: 1 addition & 1 deletion etc/npm/deps.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
acorn@"^8.1.0" acorn-loose@"^8.0.2" acorn-walk@"^8.0.2" d3-format@"^1.0.0" d3-scale@"^1.0.0" d3-shape@"^1.0.0" d3-time-format@"^2.0.0" debug@"^2.6.9" glob@"^7.0.5" minimist@"^1.2.0" readable-stream@"^2.1.4" resolve@"^1.1.7" vdom-to-html@"^2.3.0" virtual-dom@"^2.1.1" 0x@"^4.10.2" @cspell/eslint-plugin@"^8.8.0" @commitlint/cli@"^17.4.4" @commitlint/cz-commitlint@"^17.4.4" @conventional-commits/parser@"^0.4.1" @kaciras/deasync@"^1.0.1" @types/node@"^13.9.0" @typescript-eslint/parser@"^8.57.0" @typescript-eslint/eslint-plugin@"^8.57.0" ajv@"^5.2.2" browser-pack-flat@"^3.0.0" browserify@"^17.0.0" bundle-collapser@"^1.3.0" c8@"^7.12.0" chai@"^3.5.0" cheerio@"^1.0.0-rc.12" commitizen@"^4.3.0" common-shakeify@"^0.6.0" conventional-changelog-conventionalcommits@"^5.0.0" doctrine@"^3.0.0" editorconfig-checker@"^6.0.0" envify@"^4.0.0" @stylistic/eslint-plugin-ts@"^2.13.0" eslint@"^8.57.0" eslint-plugin-n@"^17.17.0" eslint-plugin-expect-type@"^0.2.3" eslint-plugin-import@"^2.29.0" eslint-plugin-jsdoc@"^46.8.2" eslint-plugin-stdlib@"file:./etc/eslint/plugin" globals@"^16.1.0" exorcist@"^2.0.0" factor-bundle@"^2.5.0" gh-pages@"git+https://github.com/Planeshifter/gh-pages.git#main" inquirer@"^8.0.0" jscodeshift@"^0.15.0" jsdoc@"^3.4.0" lunr@"^2.3.9" mathjax-node@"^2.0.1" mathjax-node-sre@"^3.0.0" mkdirp@"^0.5.1" mustache@"^4.0.0" parse-link-header@"^1.0.1" plato@"^1.5.0" process@"^0.11.10" proxyquire@"^2.0.0" proxyquire-universal@"^2.0.0" proxyquireify@"^3.1.1" read-installed@"^4.0.3" rehype@"^9.0.0" rehype-highlight@"^3.0.0" remark@"^11.0.1" remark-cli@"^7.0.0" remark-frontmatter@"^1.2.0" remark-html@"^10.0.0" remark-lint@"^6.0.0" remark-lint-blockquote-indentation@"^1.0.0" remark-lint-checkbox-character-style@"^1.0.0" remark-lint-checkbox-content-indent@"^1.0.0" remark-lint-code-block-style@"^1.0.0" remark-lint-definition-case@"^1.0.0" remark-lint-definition-spacing@"^1.0.0" remark-lint-emphasis-marker@"^1.0.0" remark-lint-fenced-code-flag@"^1.0.0" remark-lint-fenced-code-marker@"^1.0.0" remark-lint-file-extension@"^1.0.0" remark-lint-final-definition@"^1.0.0" remark-lint-final-newline@"^1.0.0" remark-lint-first-heading-level@"^1.1.0" remark-lint-hard-break-spaces@"^1.0.1" remark-lint-heading-increment@"^1.0.0" remark-lint-heading-style@"^1.0.0" remark-lint-linebreak-style@"^1.0.0" remark-lint-link-title-style@"^1.0.0" remark-lint-list-item-bullet-indent@"^1.0.0" remark-lint-list-item-content-indent@"^1.0.0" remark-lint-list-item-indent@"^1.0.0" remark-lint-list-item-spacing@"^1.1.0" remark-lint-maximum-heading-length@"^1.0.0" remark-lint-maximum-line-length@"^1.0.0" remark-lint-no-auto-link-without-protocol@"^1.0.0" remark-lint-no-blockquote-without-marker@"^2.0.0" remark-lint-no-consecutive-blank-lines@"^1.0.0" remark-lint-no-duplicate-definitions@"^1.0.0" remark-lint-no-duplicate-headings@"^1.0.0" remark-lint-no-duplicate-headings-in-section@"^1.0.0" remark-lint-no-emphasis-as-heading@"^1.0.0" remark-lint-no-empty-url@"^1.0.1" remark-lint-no-file-name-articles@"^1.0.0" remark-lint-no-file-name-consecutive-dashes@"^1.0.0" remark-lint-no-file-name-irregular-characters@"^1.0.0" remark-lint-no-file-name-mixed-case@"^1.0.0" remark-lint-no-file-name-outer-dashes@"^1.0.1" remark-lint-no-heading-content-indent@"^1.0.0" remark-lint-no-heading-indent@"^1.0.0" remark-lint-no-heading-like-paragraph@"^1.0.0" remark-lint-no-heading-punctuation@"^1.0.0" remark-lint-no-html@"^1.0.0" remark-lint-no-inline-padding@"^1.0.0" remark-lint-no-literal-urls@"^1.0.0" remark-lint-no-missing-blank-lines@"^1.0.0" remark-lint-no-multiple-toplevel-headings@"^1.0.0" remark-lint-no-paragraph-content-indent@"^1.0.1" remark-lint-no-reference-like-url@"^1.0.0" remark-lint-no-shell-dollars@"^1.0.0" remark-lint-no-shortcut-reference-image@"^1.0.0" remark-lint-no-shortcut-reference-link@"^1.0.1" remark-lint-no-table-indentation@"^1.0.0" remark-lint-no-tabs@"^1.0.0" remark-lint-no-trailing-spaces@"^3.0.2" remark-lint-no-undefined-references@"^1.0.0" remark-lint-no-unused-definitions@"^1.0.0" remark-lint-ordered-list-marker-style@"^1.0.0" remark-lint-ordered-list-marker-value@"^1.0.0" remark-lint-rule-style@"^1.0.0" remark-lint-strong-marker@"^1.0.0" remark-lint-table-cell-padding@"^1.0.0" remark-lint-table-pipe-alignment@"^1.0.0" remark-lint-table-pipes@"^1.0.0" remark-lint-unordered-list-marker-style@"^1.0.0" remark-slug@"^5.0.0" remark-unlink@"^2.0.0" remark-validate-links@"^9.0.1" remark-vdom@"^8.0.0" semver@"^6.0.0" source-map-explorer@"^2.5.3" spdx-license-ids@"^3.0.0" tap-min@"git+https://github.com/Planeshifter/tap-min.git" tap-spec@"5.x.x" tap-summary@"^4.0.0" tap-xunit@"^2.2.0" tape@"git+https://github.com/kgryte/tape.git#fix/globby" to-vfile@"^6.0.0" typedoc@"git+https://github.com/kgryte/typedoc.git#0.16.11-patch" typescript@"4.9.5" uglify-js@"^3.17.4" uglifyify@"^5.0.0" unified-lint-rule@"^1.0.1" unist-util-visit@"^2.0.0" unist-util-visit-parents@"^3.1.1" yaml@"^1.0.0" node-gyp@"^9.3.1"
acorn@"^8.1.0" acorn-loose@"^8.0.2" acorn-walk@"^8.0.2" d3-format@"^1.0.0" d3-scale@"^1.0.0" d3-shape@"^1.0.0" d3-time-format@"^2.0.0" debug@"^2.6.9" glob@"^7.0.5" minimist@"^1.2.0" readable-stream@"^2.1.4" resolve@"^1.1.7" vdom-to-html@"^2.3.0" virtual-dom@"^2.1.1" 0x@"^4.10.2" @cspell/eslint-plugin@"^8.8.0" @commitlint/cli@"^17.4.4" @commitlint/cz-commitlint@"^17.4.4" @conventional-commits/parser@"^0.4.1" @kaciras/deasync@"^1.0.1" @types/node@"^13.9.0" @typescript-eslint/parser@"^8.57.0" @typescript-eslint/eslint-plugin@"^8.57.0" ajv@"^5.2.2" browser-pack-flat@"^3.0.0" browserify@"^17.0.0" bundle-collapser@"^1.3.0" c8@"^7.12.0" chai@"^3.5.0" cheerio@"^1.0.0-rc.12" commitizen@"^4.3.0" common-shakeify@"^0.6.0" conventional-changelog-conventionalcommits@"^5.0.0" doctrine@"^3.0.0" editorconfig-checker@"^6.0.0" envify@"^4.0.0" @stylistic/eslint-plugin-ts@"^2.13.0" eslint@"^9.0.0" eslint-plugin-n@"^17.17.0" eslint-plugin-expect-type@"^0.6.2" eslint-plugin-import@"^2.29.0" eslint-plugin-jsdoc@"^46.8.2" eslint-plugin-stdlib@"file:./etc/eslint/plugin" globals@"^16.1.0" exorcist@"^2.0.0" factor-bundle@"^2.5.0" gh-pages@"git+https://github.com/Planeshifter/gh-pages.git#main" inquirer@"^8.0.0" jscodeshift@"^0.15.0" jsdoc@"^3.4.0" lunr@"^2.3.9" mathjax-node@"^2.0.1" mathjax-node-sre@"^3.0.0" mkdirp@"^0.5.1" mustache@"^4.0.0" parse-link-header@"^1.0.1" plato@"^1.5.0" process@"^0.11.10" proxyquire@"^2.0.0" proxyquire-universal@"^2.0.0" proxyquireify@"^3.1.1" read-installed@"^4.0.3" rehype@"^9.0.0" rehype-highlight@"^3.0.0" remark@"^11.0.1" remark-cli@"^7.0.0" remark-frontmatter@"^1.2.0" remark-html@"^10.0.0" remark-lint@"^6.0.0" remark-lint-blockquote-indentation@"^1.0.0" remark-lint-checkbox-character-style@"^1.0.0" remark-lint-checkbox-content-indent@"^1.0.0" remark-lint-code-block-style@"^1.0.0" remark-lint-definition-case@"^1.0.0" remark-lint-definition-spacing@"^1.0.0" remark-lint-emphasis-marker@"^1.0.0" remark-lint-fenced-code-flag@"^1.0.0" remark-lint-fenced-code-marker@"^1.0.0" remark-lint-file-extension@"^1.0.0" remark-lint-final-definition@"^1.0.0" remark-lint-final-newline@"^1.0.0" remark-lint-first-heading-level@"^1.1.0" remark-lint-hard-break-spaces@"^1.0.1" remark-lint-heading-increment@"^1.0.0" remark-lint-heading-style@"^1.0.0" remark-lint-linebreak-style@"^1.0.0" remark-lint-link-title-style@"^1.0.0" remark-lint-list-item-bullet-indent@"^1.0.0" remark-lint-list-item-content-indent@"^1.0.0" remark-lint-list-item-indent@"^1.0.0" remark-lint-list-item-spacing@"^1.1.0" remark-lint-maximum-heading-length@"^1.0.0" remark-lint-maximum-line-length@"^1.0.0" remark-lint-no-auto-link-without-protocol@"^1.0.0" remark-lint-no-blockquote-without-marker@"^2.0.0" remark-lint-no-consecutive-blank-lines@"^1.0.0" remark-lint-no-duplicate-definitions@"^1.0.0" remark-lint-no-duplicate-headings@"^1.0.0" remark-lint-no-duplicate-headings-in-section@"^1.0.0" remark-lint-no-emphasis-as-heading@"^1.0.0" remark-lint-no-empty-url@"^1.0.1" remark-lint-no-file-name-articles@"^1.0.0" remark-lint-no-file-name-consecutive-dashes@"^1.0.0" remark-lint-no-file-name-irregular-characters@"^1.0.0" remark-lint-no-file-name-mixed-case@"^1.0.0" remark-lint-no-file-name-outer-dashes@"^1.0.1" remark-lint-no-heading-content-indent@"^1.0.0" remark-lint-no-heading-indent@"^1.0.0" remark-lint-no-heading-like-paragraph@"^1.0.0" remark-lint-no-heading-punctuation@"^1.0.0" remark-lint-no-html@"^1.0.0" remark-lint-no-inline-padding@"^1.0.0" remark-lint-no-literal-urls@"^1.0.0" remark-lint-no-missing-blank-lines@"^1.0.0" remark-lint-no-multiple-toplevel-headings@"^1.0.0" remark-lint-no-paragraph-content-indent@"^1.0.1" remark-lint-no-reference-like-url@"^1.0.0" remark-lint-no-shell-dollars@"^1.0.0" remark-lint-no-shortcut-reference-image@"^1.0.0" remark-lint-no-shortcut-reference-link@"^1.0.1" remark-lint-no-table-indentation@"^1.0.0" remark-lint-no-tabs@"^1.0.0" remark-lint-no-trailing-spaces@"^3.0.2" remark-lint-no-undefined-references@"^1.0.0" remark-lint-no-unused-definitions@"^1.0.0" remark-lint-ordered-list-marker-style@"^1.0.0" remark-lint-ordered-list-marker-value@"^1.0.0" remark-lint-rule-style@"^1.0.0" remark-lint-strong-marker@"^1.0.0" remark-lint-table-cell-padding@"^1.0.0" remark-lint-table-pipe-alignment@"^1.0.0" remark-lint-table-pipes@"^1.0.0" remark-lint-unordered-list-marker-style@"^1.0.0" remark-slug@"^5.0.0" remark-unlink@"^2.0.0" remark-validate-links@"^9.0.1" remark-vdom@"^8.0.0" semver@"^6.0.0" source-map-explorer@"^2.5.3" spdx-license-ids@"^3.0.0" tap-min@"git+https://github.com/Planeshifter/tap-min.git" tap-spec@"5.x.x" tap-summary@"^4.0.0" tap-xunit@"^2.2.0" tape@"git+https://github.com/kgryte/tape.git#fix/globby" to-vfile@"^6.0.0" typedoc@"git+https://github.com/kgryte/typedoc.git#0.16.11-patch" typescript@"4.9.5" uglify-js@"^3.17.4" uglifyify@"^5.0.0" unified-lint-rule@"^1.0.1" unist-util-visit@"^2.0.0" unist-util-visit-parents@"^3.1.1" yaml@"^1.0.0" node-gyp@"^9.3.1"
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ function checkComment( source, comment ) {
if ( !token ) {
return 'Encountered an orphaned return annotation without a preceding node';
}
// Ignore annotations on the same line as the preceding token:
if ( comment.loc.start.line === token.loc.end.line ) {
return null;
}
// Check for orphaned annotation (preceding token is not on the same or previous line):
if ( comment.loc.start.line - token.loc.end.line > 1 ) {
return 'Encountered an orphaned return annotation without a preceding node';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,32 +47,6 @@ test = {
};
valid.push( test );

test = {
'code': [
' var value = [',
' {',
' \'a\': 1,',
' \'b\': true,',
' \'c\': [ 1, 2, 3 ]',
' }',
' ];',
' var out = copy( value );',
' /* returns',
' [',
' {',
' \'a\': 1,',
' \'b\': true,',
' \'c\': [ 1, 2, 3 ]',
' }',
' ]',
'*/',
'',
' var bool = ( value[0].c === out[0].c );',
' // returns false'
].join( '\n' )
};
valid.push( test );

test = {
'code': [
'var target = {',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ test = {
'var args = [ \'foo\' ];',
'var str = format( \'%s %s\', ...args );'
].join( '\n' ),
'parserOptions': {
'languageOptions': {
'ecmaVersion': 2018
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ tape( 'main export is an object', function test( t ) {

tape( 'the function positively validates format calls which are provided an expected number of arguments', function test( t ) {
var tester = new RuleTester({
'parserOptions': {
'languageOptions': {
'ecmaVersion': 2020
}
});
Expand All @@ -61,7 +61,7 @@ tape( 'the function positively validates format calls which are provided an expe

tape( 'the function negatively validates format calls which are provided an unexpected number of arguments', function test( t ) {
var tester = new RuleTester({
'parserOptions': {
'languageOptions': {
'ecmaVersion': 2020
}
});
Expand All @@ -80,7 +80,7 @@ tape( 'the function negatively validates format calls which are provided an unex

tape( 'the function does not validate code not containing checkable format calls', function test( t ) {
var tester = new RuleTester({
'parserOptions': {
'languageOptions': {
'ecmaVersion': 2020
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,25 +343,6 @@ test = {
};
valid.push( test );

test = {
'code': [
'/**',
'* Beep boop.',
'*',
'* - [ ] Item',
'* - [X] Item',
'*/',
'function beep() {',
' console.log( "boop" );',
'}'
].join( '\n' ),
'options': [{
'checked': 'X',
'unchecked': ' '
}]
};
valid.push( test );


// EXPORTS //

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,27 +369,6 @@ test = {
};
valid.push( test );

test = {
'code': [
'/**',
'* Beep boop.',
'*',
'* # Beep #',
'*',
'* boop',
'*',
'* ## Boop ##',
'*',
'* beep',
'*/',
'function beep() {',
' console.log( "boop" );',
'}'
].join( '\n' ),
'options': [ 'atx-closed' ]
};
valid.push( test );

test = {
'code': [
'/**',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

// MODULES //

var config = require( './config.js' );
var configPath = require.resolve( './config.js' );


// VARIABLES //
Expand Down Expand Up @@ -52,7 +52,7 @@ test = {
].join( '\n' ),
'options': [
{
'config': config
'configPath': configPath
}
]
};
Expand All @@ -77,7 +77,7 @@ test = {
].join( '\n' ),
'options': [
{
'config': config
'configPath': configPath
}
]
};
Expand All @@ -102,7 +102,7 @@ test = {
].join( '\n' ),
'options': [
{
'config': config
'configPath': configPath
}
]
};
Expand All @@ -127,7 +127,7 @@ test = {
].join( '\n' ),
'options': [
{
'config': config
'configPath': configPath
}
]
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

// MODULES //

var config = require( './config.js' );
var configPath = require.resolve( './config.js' );


// VARIABLES //
Expand Down Expand Up @@ -52,7 +52,7 @@ test = {
].join( '\n' ),
'options': [
{
'config': config
'configPath': configPath
}
]
};
Expand All @@ -75,7 +75,7 @@ test = {
].join( '\n' ),
'options': [
{
'config': config
'configPath': configPath
}
]
};
Expand Down Expand Up @@ -159,7 +159,7 @@ test = {
].join( '\n' ),
'options': [
{
'config': config
'configPath': configPath
}
]
};
Expand Down Expand Up @@ -199,7 +199,7 @@ test = {
].join( '\n' ),
'options': [
{
'config': config
'configPath': configPath
}
]
};
Expand All @@ -218,7 +218,7 @@ test = {
].join( '\n' ),
'options': [
{
'config': config
'configPath': configPath
}
]
};
Expand Down Expand Up @@ -269,7 +269,7 @@ test = {
].join( '\n' ),
'options': [
{
'config': config
'configPath': configPath
}
]
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

var tape = require( 'tape' );
var RuleTester = require( 'eslint' ).RuleTester;
var Linter = require( 'eslint' ).Linter;
var rule = require( './../lib' );


Expand All @@ -32,6 +33,33 @@ var invalid = require( './fixtures/invalid.js' );
var unvalidated = require( './fixtures/unvalidated.js' );


// FUNCTIONS //

/**
* Lints code using the legacy inline remark configuration.
*
* @private
* @param {string} code - code to lint
* @param {Array} options - rule options
* @returns {Array} lint messages
*/
function lintCode( code, options ) {
var linter;
var config;

linter = new Linter({
'configType': 'eslintrc'
});
linter.defineRule( 'jsdoc-markdown-remark', rule );
config = {
'rules': {
'jsdoc-markdown-remark': [ 'error' ].concat( options || [] )
}
};
return linter.verify( code, config );
}


// TESTS //

tape( 'main export is an object', function test( t ) {
Expand Down Expand Up @@ -61,7 +89,7 @@ tape( 'the function negatively validates code with JSDoc descriptions that conta
try {
tester.run( 'jsdoc-markdown-remark', rule, {
'valid': [],
'invalid': invalid
'invalid': invalid.slice( 1 )
});
t.pass( 'passed without errors' );
} catch ( err ) {
Expand All @@ -70,6 +98,14 @@ tape( 'the function negatively validates code with JSDoc descriptions that conta
t.end();
});

tape( 'the function supports an inline remark configuration', function test( t ) {
var messages;

messages = lintCode( invalid[ 0 ].code, invalid[ 0 ].options );
t.strictEqual( messages.length, invalid[ 0 ].errors.length, 'returns expected errors' );
t.end();
});

tape( 'the function does not validate non-JSDoc comments', function test( t ) {
var tester = new RuleTester();

Expand Down
Loading
Loading