Skip to content

Commit

Permalink
chore(deps): update external major (major) (#99)
Browse files Browse the repository at this point in the history
* chore(deps): update external major

* chore(deps): use eslint v9

* chore(deps): remove eslint-plugin-header

* chore(lint): move eslint to separate directory

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Dominique Pfister <[email protected]>
  • Loading branch information
renovate[bot] and dominique-pfister authored Jun 5, 2024
1 parent fc17d2c commit f8cc847
Show file tree
Hide file tree
Showing 16 changed files with 2,464 additions and 1,524 deletions.
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

22 changes: 22 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright 2019 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
import config from './eslint/index.js';

export default [
...config,
{
ignores: [
'.vscode/**',
'coverage/**',
],
},
];
84 changes: 66 additions & 18 deletions .eslintrc.cjs → eslint/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022 Adobe. All rights reserved.
* Copyright 2019 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
Expand All @@ -9,26 +9,43 @@
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
module.exports = {
root: true,
extends: [
'eslint-config-airbnb-base',
].map(require.resolve),

env: {
node: true,
es6: true,
},
parserOptions: {
import globals from 'globals';
import header from './plugins/header/index.cjs';

import bestPractices from './rules/best-practices.js';
import errors from './rules/errors.js';
import es6 from './rules/es6.js';
import node from './rules/node.js';
import strict from './rules/strict.js';
import style from './rules/style.js';
import variables from './rules/variables.js';

const common = {
languageOptions: {
ecmaVersion: 2022,
sourceType: 'module',
ecmaVersion: 2020,
globals: {
...globals.node,
...globals.es6,
'__rootdir': true,
},
},
plugins: {
header,
},
plugins: [
'header',
],
rules: {
...bestPractices.rules,
...errors.rules,
...es6.rules,
...node.rules,
...strict.rules,
...style.rules,
...variables.rules,

strict: 0,

'import/prefer-default-export': 0,

// Forbid multiple statements in one line
'max-statements-per-line': ['error', { max: 1 }],

Expand All @@ -46,18 +63,19 @@ module.exports = {
// allow '_' as a throw-away variable
'no-unused-vars': ['error', {
argsIgnorePattern: '^_$',
varsIgnorePattern: '^_$',
}],

'no-shadow': ['error', {
allow: ['_'],
}],

// don't enforce extension rules
'import/extensions': 0,
// 'import/extensions': [2, 'ignorePackages'],

// enforce license header
'header/header': [2, 'block', ['',
{ pattern: ' * Copyright \\d{4} Adobe\\. All rights reserved\\.', template: ' * Copyright 2022 Adobe. All rights reserved.' },
{ pattern: ' * Copyright \\d{4} Adobe\\. All rights reserved\\.', template: ' * Copyright 2024 Adobe. All rights reserved.' },
' * This file is licensed to you under the Apache License, Version 2.0 (the "License");',
' * you may not use this file except in compliance with the License. You may obtain a copy',
' * of the License at http://www.apache.org/licenses/LICENSE-2.0',
Expand All @@ -73,4 +91,34 @@ module.exports = {
properties: true,
}],
},
files: ['*.js'],
linterOptions: {
reportUnusedDisableDirectives: 'off',
},
};

const source = {
...common,
files: ['src/*.js', 'src/**/*.js', 'test/dev/*.mjs'],
};

const test = {
...common,
languageOptions: {
globals: {
...common.languageOptions.globals,
...globals.mocha,
'__testdir': true,
},
},
files: ['test/*.js', 'test/**/*.js'],
};

export default [
{
...source,
},
{
...test,
}
];
24 changes: 24 additions & 0 deletions eslint/plugins/header/comment-parser.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"use strict";

// This is a really simple and dumb parser, that looks just for a
// single kind of comment. It won't detect multiple block comments.

module.exports = function commentParser(text) {
text = text.trim();

if (text.substr(0, 2) === "//") {
return [
"line",
text.split(/\r?\n/).map(function(line) {
return line.substr(2);
})
];
} else if (
text.substr(0, 2) === "/*" &&
text.substr(-2) === "*/"
) {
return ["block", text.substring(2, text.length - 2)];
} else {
throw new Error("Could not parse comment file: the file must contain either just line comments (//) or a single block comment (/* ... */)");
}
};
Loading

0 comments on commit f8cc847

Please sign in to comment.