Skip to content

Commit 95c65f5

Browse files
authored
Merge pull request #54 from bingenito/eslint-plugin-license-header
Add license header eslint check and update dependencies
2 parents 24021fb + b1d5f36 commit 95c65f5

File tree

4 files changed

+1882
-809
lines changed

4 files changed

+1882
-809
lines changed

eslint.config.cjs

-42
This file was deleted.

eslint.config.mjs

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
import globals from "globals";
2+
import js from "@eslint/js";
3+
import { FlatCompat } from "@eslint/eslintrc";
4+
import path from "path";
5+
import { fileURLToPath } from "url";
6+
import licenseHeader from "eslint-plugin-license-header";
7+
8+
// Get the directory name equivalent to __dirname in CommonJS
9+
const __filename = fileURLToPath(import.meta.url);
10+
const __dirname = path.dirname(__filename);
11+
12+
// Define the license header as an array of strings
13+
const LICENSE_HEADER = [
14+
"/*",
15+
" * Morgan Stanley makes this available to you under the Apache License,",
16+
" * Version 2.0 (the \"License\"). You may obtain a copy of the License at",
17+
" *",
18+
" * http://www.apache.org/licenses/LICENSE-2.0.",
19+
" *",
20+
" * See the NOTICE file distributed with this work for additional information",
21+
" * regarding copyright ownership. Unless required by applicable law or agreed",
22+
" * to in writing, software distributed under the License is distributed on an",
23+
" * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express",
24+
" * or implied. See the License for the specific language governing permissions",
25+
" * and limitations under the License.",
26+
" */"
27+
];
28+
29+
const compat = new FlatCompat({
30+
baseDirectory: __dirname,
31+
recommendedConfig: js.configs.recommended,
32+
allConfig: js.configs.all
33+
});
34+
35+
// Get the ESLint configurations from plugins
36+
const eslintRecommended = compat.extends("eslint:recommended");
37+
const eslintPluginRecommended = compat.extends("plugin:eslint-plugin/recommended");
38+
const nRecommended = compat.extends("plugin:n/recommended");
39+
40+
// Create the flat config array
41+
export default [
42+
// Base configuration with ignores
43+
{
44+
ignores: ["node_modules/**"]
45+
},
46+
47+
// Include the plugin configurations
48+
...eslintRecommended,
49+
...eslintPluginRecommended,
50+
...nRecommended,
51+
52+
// Global configuration
53+
{
54+
files: ["**/*.js", "**/*.mjs", "**/*.cjs"],
55+
languageOptions: {
56+
globals: {
57+
...globals.browser,
58+
...globals.node,
59+
},
60+
ecmaVersion: "latest"
61+
},
62+
linterOptions: {
63+
reportUnusedDisableDirectives: true
64+
},
65+
rules: {
66+
"eslint-plugin/require-meta-docs-description": ["error", {
67+
pattern: "^(Enforce|Require|Disallow|Prefer).+\\.$",
68+
}],
69+
"n/no-extraneous-require": "off"
70+
}
71+
},
72+
73+
// Disable problematic rules for the config file itself
74+
{
75+
files: ["**/eslint.config.mjs"],
76+
rules: {
77+
"n/no-extraneous-import": "off",
78+
"n/no-unpublished-import": "off"
79+
}
80+
},
81+
82+
// Add license header check for all JavaScript files
83+
{
84+
files: ["**/*.js"],
85+
plugins: {
86+
"license-header": licenseHeader
87+
},
88+
rules: {
89+
"license-header/header": ["error", LICENSE_HEADER]
90+
}
91+
},
92+
93+
// Configuration for test files
94+
{
95+
files: ["**/tests/*.js"],
96+
languageOptions: {
97+
globals: {
98+
...globals.mocha,
99+
}
100+
}
101+
}
102+
];

0 commit comments

Comments
 (0)