Skip to content

Commit

Permalink
Switch to flat config
Browse files Browse the repository at this point in the history
  • Loading branch information
fasttime committed Dec 30, 2023
1 parent 93a4746 commit 5dc9f2d
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 40 deletions.
29 changes: 0 additions & 29 deletions .eslintrc.js

This file was deleted.

43 changes: 43 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
'use strict';

const { createFlatConfig } = require('@origin-1/eslint-config');
const eslintPluginEslintComments = require('eslint-plugin-eslint-comments');
const eslintPluginTsdoc = require('eslint-plugin-tsdoc');
const globals = require('globals');

module.exports =
createFlatConfig
(
{
ignores: ['**/.*', 'coverage', 'example/demo'],
},
{
files: ['**/*.js'],
jsVersion: 2020,
languageOptions: { sourceType: 'script' },
},
{
files: ['test/*.spec.js'],
languageOptions: { globals: globals.mocha },
},
{
files: ['**/*.ts'],
tsVersion: '4.2.0',
languageOptions: { parserOptions: { project: 'tsconfig.json' } },
plugins: { 'tsdoc': eslintPluginTsdoc },
rules: { 'tsdoc/syntax': 'error' },
},
{
languageOptions: { globals: globals.node },
plugins: { 'eslint-comments': eslintPluginEslintComments },
rules:
{
'no-throw-literal': 'off',
'eslint-comments/disable-enable-pair': 'error',
'eslint-comments/no-aggregating-enable': 'error',
'eslint-comments/no-duplicate-disable': 'error',
'eslint-comments/no-unlimited-disable': 'error',
'eslint-comments/no-unused-enable': 'error',
},
},
);
4 changes: 2 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ task
const gulpESLintNew = require('gulp-eslint-new');

const stream =
src(['.eslintrc.js', '*.js', 'example/*.js', 'lib/*.{js,ts}', 'test/**/*.{js,ts}'])
.pipe(gulpESLintNew({ warnIgnored: true }))
src(['*.js', 'example/*.js', 'lib/*.{js,ts}', 'test/**/*.{js,ts}'])
.pipe(gulpESLintNew({ configType: 'flat', warnIgnored: true }))
.pipe(gulpESLintNew.format('compact'))
.pipe(gulpESLintNew.failAfterError());
return stream;
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
'use strict';

module.exports = { };
10 changes: 4 additions & 6 deletions test/linting.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const gulpESLintNew = require('gulp-eslint-new');
const { join, resolve } = require('path');
const { satisfies } = require('semver');
const { Readable } = require('stream');
const File = require('vinyl');
const VinylFile = require('vinyl');

async function testConfig(options)
{
Expand Down Expand Up @@ -788,13 +788,11 @@ describe
'should emit an error when it takes a stream content',
async () =>
{
const file =
new VinylFile({ path: resolve('stream.js'), contents: Readable.from([]) });
await assert.rejects
(
finished
(
gulpESLintNew({ useEslintrc: false })
.end(new File({ path: resolve('stream.js'), contents: Readable.from([]) })),
),
finished(gulpESLintNew({ useEslintrc: false }).end(file)),
{
message:
'gulp-eslint-new doesn\'t support Vinyl files with Stream contents.',
Expand Down
6 changes: 3 additions & 3 deletions test/test-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
const { resolve } = require('path');
const { finished } = require('stream');
const { promisify } = require('util');
const File = require('vinyl');
const VinylFile = require('vinyl');

exports.createVinylDirectory =
() =>
{
const directory = new File({ path: process.cwd(), contents: null, isDirectory: true });
const directory = new VinylFile({ path: process.cwd(), contents: null, isDirectory: true });
return directory;
};

exports.createVinylFile =
(path, contents) =>
{
const file = new File({ path: resolve(path), contents: Buffer.from(contents) });
const file = new VinylFile({ path: resolve(path), contents: Buffer.from(contents) });
return file;
};

Expand Down

0 comments on commit 5dc9f2d

Please sign in to comment.