fix(JS): Rename CommonJS scripts to .cjs extension, keep type: module as the project default. Update and fix ESLint configuration.
- Renames JavaScript files in flux-build-scripts and api-docs/openapi/plugins to .cjs file extension to declare them as CommonJS module syntax.pull/6075/head
parent
f53eaf88d9
commit
1dce052e56
|
@ -31,10 +31,10 @@ jobs:
|
||||||
command: cd api-docs && bash generate-api-docs.sh
|
command: cd api-docs && bash generate-api-docs.sh
|
||||||
- run:
|
- run:
|
||||||
name: Inject Flux stdlib frontmatter
|
name: Inject Flux stdlib frontmatter
|
||||||
command: node ./flux-build-scripts/inject-flux-stdlib-frontmatter.js
|
command: node ./flux-build-scripts/inject-flux-stdlib-frontmatter.cjs
|
||||||
- run:
|
- run:
|
||||||
name: Update Flux/InfluxDB versions
|
name: Update Flux/InfluxDB versions
|
||||||
command: node ./flux-build-scripts/update-flux-versions.js
|
command: node ./flux-build-scripts/update-flux-versions.cjs
|
||||||
- save_cache:
|
- save_cache:
|
||||||
key: install-{{ .Environment.CACHE_VERSION }}-{{ checksum ".circleci/config.yml" }}
|
key: install-{{ .Environment.CACHE_VERSION }}-{{ checksum ".circleci/config.yml" }}
|
||||||
paths:
|
paths:
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
plugins:
|
plugins:
|
||||||
- './../openapi/plugins/docs-plugin.js'
|
- './../openapi/plugins/docs-plugin.cjs'
|
||||||
extends:
|
extends:
|
||||||
- recommended
|
- recommended
|
||||||
- docs/all
|
- docs/all
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
plugins:
|
plugins:
|
||||||
- '../../openapi/plugins/docs-plugin.js'
|
- '../../openapi/plugins/docs-plugin.cjs'
|
||||||
extends:
|
extends:
|
||||||
- recommended
|
- recommended
|
||||||
- docs/all
|
- docs/all
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
plugins:
|
plugins:
|
||||||
- '../../openapi/plugins/docs-plugin.js'
|
- '../../openapi/plugins/docs-plugin.cjs'
|
||||||
extends:
|
extends:
|
||||||
- recommended
|
- recommended
|
||||||
- docs/all
|
- docs/all
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
plugins:
|
plugins:
|
||||||
- '../../openapi/plugins/docs-plugin.js'
|
- '../../openapi/plugins/docs-plugin.cjs'
|
||||||
extends:
|
extends:
|
||||||
- recommended
|
- recommended
|
||||||
- docs/all
|
- docs/all
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
plugins:
|
plugins:
|
||||||
- '../../openapi/plugins/docs-plugin.js'
|
- '../../openapi/plugins/docs-plugin.cjs'
|
||||||
extends:
|
extends:
|
||||||
- recommended
|
- recommended
|
||||||
- docs/all
|
- docs/all
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
plugins:
|
plugins:
|
||||||
- '../../openapi/plugins/docs-plugin.js'
|
- '../../openapi/plugins/docs-plugin.cjs'
|
||||||
extends:
|
extends:
|
||||||
- recommended
|
- recommended
|
||||||
- docs/all
|
- docs/all
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
plugins:
|
plugins:
|
||||||
- '../../openapi/plugins/docs-plugin.js'
|
- '../../openapi/plugins/docs-plugin.cjs'
|
||||||
extends:
|
extends:
|
||||||
- recommended
|
- recommended
|
||||||
- docs/all
|
- docs/all
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
plugins:
|
plugins:
|
||||||
- '../../openapi/plugins/docs-plugin.js'
|
- '../../openapi/plugins/docs-plugin.cjs'
|
||||||
extends:
|
extends:
|
||||||
- recommended
|
- recommended
|
||||||
- docs/all
|
- docs/all
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
module.exports = SetTagGroups;
|
module.exports = SetTagGroups;
|
||||||
|
|
||||||
const { collect, getName, sortName, isPresent } = require('../../helpers/content-helper.js')
|
const { collect, getName, sortName, isPresent } = require('../../helpers/content-helper.cjs')
|
||||||
/**
|
/**
|
||||||
* Returns an object that defines handler functions for:
|
* Returns an object that defines handler functions for:
|
||||||
* - Operation nodes
|
* - Operation nodes
|
|
@ -1,25 +0,0 @@
|
||||||
module.exports = SetTags;
|
|
||||||
|
|
||||||
const { tags } = require('../../../content/content')
|
|
||||||
/**
|
|
||||||
* Returns an object that defines handler functions for:
|
|
||||||
* - DefinitionRoot (the root openapi) node
|
|
||||||
* The DefinitionRoot handler, executed when
|
|
||||||
* the parser is leaving the root node,
|
|
||||||
* sets the root `tags` list to the provided `data`.
|
|
||||||
*/
|
|
||||||
/** @type {import('@redocly/openapi-cli').OasDecorator} */
|
|
||||||
function SetTags() {
|
|
||||||
const data = tags();
|
|
||||||
|
|
||||||
return {
|
|
||||||
DefinitionRoot: {
|
|
||||||
/** Set tags from custom tags when visitor enters root. */
|
|
||||||
enter(root) {
|
|
||||||
if(data) {
|
|
||||||
root.tags = data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
|
@ -1,5 +1,5 @@
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const { toJSON } = require('./helpers/content-helper');
|
const { toJSON } = require('./helpers/content-helper.cjs');
|
||||||
|
|
||||||
function getVersioned(filename) {
|
function getVersioned(filename) {
|
||||||
const apiDocsRoot=path.resolve(process.env.API_DOCS_ROOT_PATH || process.cwd());
|
const apiDocsRoot=path.resolve(process.env.API_DOCS_ROOT_PATH || process.cwd());
|
|
@ -1,14 +1,14 @@
|
||||||
const {info, servers, tagGroups} = require('./docs-content');
|
const {info, servers, tagGroups} = require('./docs-content.cjs');
|
||||||
const ReportTags = require('./rules/report-tags');
|
const ReportTags = require('./rules/report-tags.cjs');
|
||||||
const ValidateServersUrl = require('./rules/validate-servers-url');
|
const ValidateServersUrl = require('./rules/validate-servers-url.cjs');
|
||||||
const RemovePrivatePaths = require('./decorators/paths/remove-private-paths');
|
const RemovePrivatePaths = require('./decorators/paths/remove-private-paths.cjs');
|
||||||
const ReplaceShortcodes = require('./decorators/replace-shortcodes');
|
const ReplaceShortcodes = require('./decorators/replace-shortcodes.cjs');
|
||||||
const SetInfo = require('./decorators/set-info');
|
const SetInfo = require('./decorators/set-info.cjs');
|
||||||
const DeleteServers = require('./decorators/servers/delete-servers');
|
const DeleteServers = require('./decorators/servers/delete-servers.cjs');
|
||||||
const SetServers = require('./decorators/servers/set-servers');
|
const SetServers = require('./decorators/servers/set-servers.cjs');
|
||||||
const SetTagGroups = require('./decorators/tags/set-tag-groups');
|
const SetTagGroups = require('./decorators/tags/set-tag-groups.cjs');
|
||||||
const StripVersionPrefix = require('./decorators/paths/strip-version-prefix');
|
const StripVersionPrefix = require('./decorators/paths/strip-version-prefix.cjs');
|
||||||
const StripTrailingSlash = require('./decorators/paths/strip-trailing-slash');
|
const StripTrailingSlash = require('./decorators/paths/strip-trailing-slash.cjs');
|
||||||
|
|
||||||
const id = 'docs';
|
const id = 'docs';
|
||||||
|
|
|
@ -0,0 +1,126 @@
|
||||||
|
import globals from 'globals';
|
||||||
|
import jsdocPlugin from 'eslint-plugin-jsdoc';
|
||||||
|
import pluginJs from '@eslint/js';
|
||||||
|
import tseslint from 'typescript-eslint';
|
||||||
|
import importPlugin from 'eslint-plugin-import';
|
||||||
|
import a11yPlugin from 'eslint-plugin-jsx-a11y';
|
||||||
|
import prettierConfig from 'eslint-config-prettier';
|
||||||
|
|
||||||
|
/** @type {import('eslint').Linter.Config[]} */
|
||||||
|
export default [
|
||||||
|
// Base configurations
|
||||||
|
{
|
||||||
|
languageOptions: {
|
||||||
|
globals: {
|
||||||
|
...globals.browser,
|
||||||
|
// Hugo-specific globals
|
||||||
|
hugo: 'readonly',
|
||||||
|
params: 'readonly',
|
||||||
|
// Common libraries used in docs
|
||||||
|
Alpine: 'readonly',
|
||||||
|
CodeMirror: 'readonly',
|
||||||
|
d3: 'readonly',
|
||||||
|
},
|
||||||
|
ecmaVersion: 2022,
|
||||||
|
sourceType: 'module',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
// JavaScript config (extract rules only)
|
||||||
|
{
|
||||||
|
rules: { ...pluginJs.configs.recommended.rules },
|
||||||
|
},
|
||||||
|
|
||||||
|
// TypeScript configurations with proper plugin format
|
||||||
|
{
|
||||||
|
plugins: {
|
||||||
|
'@typescript-eslint': tseslint.plugin,
|
||||||
|
},
|
||||||
|
rules: { ...tseslint.configs.recommended.rules },
|
||||||
|
},
|
||||||
|
|
||||||
|
// Import plugin with proper plugin format
|
||||||
|
{
|
||||||
|
plugins: {
|
||||||
|
import: importPlugin,
|
||||||
|
},
|
||||||
|
rules: { ...importPlugin.configs.recommended.rules },
|
||||||
|
},
|
||||||
|
|
||||||
|
// Accessibility rules with proper plugin format
|
||||||
|
{
|
||||||
|
plugins: {
|
||||||
|
'jsx-a11y': a11yPlugin,
|
||||||
|
},
|
||||||
|
rules: { ...a11yPlugin.configs.recommended.rules },
|
||||||
|
},
|
||||||
|
|
||||||
|
// Add to your config array:
|
||||||
|
{
|
||||||
|
plugins: {
|
||||||
|
jsdoc: jsdocPlugin,
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
'jsdoc/require-description': 'warn',
|
||||||
|
'jsdoc/require-param-description': 'warn',
|
||||||
|
'jsdoc/require-returns-description': 'warn',
|
||||||
|
// Add more JSDoc rules as needed
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
// Prettier compatibility (extract rules only)
|
||||||
|
{
|
||||||
|
rules: { ...prettierConfig.rules },
|
||||||
|
},
|
||||||
|
|
||||||
|
// Custom rules for documentation project
|
||||||
|
{
|
||||||
|
rules: {
|
||||||
|
// Documentation projects often need to use console for examples
|
||||||
|
'no-console': 'off',
|
||||||
|
|
||||||
|
// Module imports
|
||||||
|
'import/extensions': ['error', 'ignorePackages'],
|
||||||
|
'import/no-unresolved': 'off', // Hugo handles module resolution differently
|
||||||
|
|
||||||
|
// Code formatting
|
||||||
|
'max-len': ['warn', { code: 80, ignoreUrls: true, ignoreStrings: true }],
|
||||||
|
quotes: ['error', 'single', { avoidEscape: true }],
|
||||||
|
|
||||||
|
// Hugo template string linting (custom rule)
|
||||||
|
'no-template-curly-in-string': 'off', // Allow ${} in strings for Hugo templates
|
||||||
|
|
||||||
|
// Accessibility
|
||||||
|
'jsx-a11y/anchor-is-valid': 'warn',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
// Configuration for specific file patterns
|
||||||
|
{
|
||||||
|
files: ['**/*.js'],
|
||||||
|
rules: {
|
||||||
|
// Rules specific to JavaScript files
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: ['assets/js/**/*.js'],
|
||||||
|
rules: {
|
||||||
|
// Rules specific to JavaScript in Hugo assets
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: ['**/*.ts'],
|
||||||
|
rules: {
|
||||||
|
// Rules specific to TypeScript files
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// Ignore rules for build files and external dependencies
|
||||||
|
ignores: [
|
||||||
|
'**/node_modules/**',
|
||||||
|
'**/public/**',
|
||||||
|
'**/resources/**',
|
||||||
|
'**/.hugo_build.lock',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
|
@ -1,98 +0,0 @@
|
||||||
import globals from "globals";
|
|
||||||
import pluginJs from "@eslint/js";
|
|
||||||
import tseslint from "typescript-eslint";
|
|
||||||
import importPlugin from "eslint-plugin-import";
|
|
||||||
import a11yPlugin from "eslint-plugin-jsx-a11y";
|
|
||||||
import prettierConfig from "eslint-config-prettier";
|
|
||||||
|
|
||||||
/** @type {import('eslint').Linter.Config[]} */
|
|
||||||
export default [
|
|
||||||
// Base configurations
|
|
||||||
{
|
|
||||||
languageOptions: {
|
|
||||||
globals: {
|
|
||||||
...globals.browser,
|
|
||||||
// Hugo-specific globals
|
|
||||||
hugo: "readonly",
|
|
||||||
params: "readonly",
|
|
||||||
// Common libraries used in docs
|
|
||||||
Alpine: "readonly",
|
|
||||||
CodeMirror: "readonly",
|
|
||||||
d3: "readonly"
|
|
||||||
},
|
|
||||||
ecmaVersion: 2022,
|
|
||||||
sourceType: "module",
|
|
||||||
}
|
|
||||||
},
|
|
||||||
pluginJs.configs.recommended,
|
|
||||||
|
|
||||||
// TypeScript configurations (for .ts files)
|
|
||||||
...tseslint.configs.recommended,
|
|
||||||
|
|
||||||
// Import plugin for better import/export handling
|
|
||||||
importPlugin.configs.recommended,
|
|
||||||
|
|
||||||
// Accessibility rules (helpful for docs site)
|
|
||||||
a11yPlugin.configs.recommended,
|
|
||||||
|
|
||||||
// Prettier compatibility
|
|
||||||
prettierConfig,
|
|
||||||
|
|
||||||
// Custom rules for documentation project
|
|
||||||
{
|
|
||||||
rules: {
|
|
||||||
// Documentation projects often need to use console for examples
|
|
||||||
"no-console": "off",
|
|
||||||
|
|
||||||
// Module imports
|
|
||||||
"import/extensions": ["error", "ignorePackages"],
|
|
||||||
"import/no-unresolved": "off", // Hugo handles module resolution differently
|
|
||||||
|
|
||||||
// Code formatting
|
|
||||||
"max-len": ["warn", { "code": 80, "ignoreUrls": true, "ignoreStrings": true }],
|
|
||||||
"quotes": ["error", "single", { "avoidEscape": true }],
|
|
||||||
|
|
||||||
// Documentation-specific
|
|
||||||
"valid-jsdoc": ["warn", {
|
|
||||||
"requireReturn": false,
|
|
||||||
"requireReturnType": false,
|
|
||||||
"requireParamType": false
|
|
||||||
}],
|
|
||||||
|
|
||||||
// Hugo template string linting (custom rule)
|
|
||||||
"no-template-curly-in-string": "off", // Allow ${} in strings for Hugo templates
|
|
||||||
|
|
||||||
// Accessibility
|
|
||||||
"jsx-a11y/anchor-is-valid": "warn",
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// Configuration for specific file patterns
|
|
||||||
{
|
|
||||||
files: ["**/*.js"],
|
|
||||||
rules: {
|
|
||||||
// Rules specific to JavaScript files
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
files: ["assets/js/**/*.js"],
|
|
||||||
rules: {
|
|
||||||
// Rules specific to JavaScript in Hugo assets
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
files: ["**/*.ts"],
|
|
||||||
rules: {
|
|
||||||
// Rules specific to TypeScript files
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
// Ignore rules for build files and external dependencies
|
|
||||||
ignores: [
|
|
||||||
"**/node_modules/**",
|
|
||||||
"**/public/**",
|
|
||||||
"**/resources/**",
|
|
||||||
"**/.hugo_build.lock"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
];
|
|
14
package.json
14
package.json
|
@ -14,12 +14,18 @@
|
||||||
"autoprefixer": ">=10.2.5",
|
"autoprefixer": ">=10.2.5",
|
||||||
"cypress": "^14.0.1",
|
"cypress": "^14.0.1",
|
||||||
"eslint": "^9.18.0",
|
"eslint": "^9.18.0",
|
||||||
|
"eslint-config-prettier": "^10.1.5",
|
||||||
|
"eslint-plugin-import": "^2.31.0",
|
||||||
|
"eslint-plugin-jsdoc": "^50.6.17",
|
||||||
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
||||||
"globals": "^15.14.0",
|
"globals": "^15.14.0",
|
||||||
"hugo-extended": ">=0.101.0",
|
"hugo-extended": ">=0.101.0",
|
||||||
"postcss": ">=8.4.31",
|
"postcss": ">=8.4.31",
|
||||||
"postcss-cli": ">=9.1.0",
|
"postcss-cli": ">=9.1.0",
|
||||||
"prettier": "^3.2.5",
|
"prettier": "^3.2.5",
|
||||||
"prettier-plugin-sql": "^0.18.0",
|
"prettier-plugin-sql": "^0.18.0",
|
||||||
|
"typescript": "^5.8.3",
|
||||||
|
"typescript-eslint": "^8.32.1",
|
||||||
"winston": "^3.16.0"
|
"winston": "^3.16.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -34,7 +40,7 @@
|
||||||
"vanillajs-datepicker": "^1.3.4"
|
"vanillajs-datepicker": "^1.3.4"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build:pytest:image":"docker build -t influxdata/docs-pytest:latest -f Dockerfile.pytest .",
|
"build:pytest:image": "docker build -t influxdata/docs-pytest:latest -f Dockerfile.pytest .",
|
||||||
"lint": "LEFTHOOK_EXCLUDE=test lefthook run pre-commit && lefthook run pre-push",
|
"lint": "LEFTHOOK_EXCLUDE=test lefthook run pre-commit && lefthook run pre-push",
|
||||||
"pre-commit": "lefthook run pre-commit",
|
"pre-commit": "lefthook run pre-commit",
|
||||||
"test": "echo \"Run 'yarn test:e2e', 'yarn test:links', 'yarn test:codeblocks:all' or a specific test command. e2e and links test commands can take a glob of file paths to test. Some commands run automatically during the git pre-commit and pre-push hooks.\" && exit 0",
|
"test": "echo \"Run 'yarn test:e2e', 'yarn test:links', 'yarn test:codeblocks:all' or a specific test command. e2e and links test commands can take a glob of file paths to test. Some commands run automatically during the git pre-commit and pre-push hooks.\" && exit 0",
|
||||||
|
@ -61,12 +67,6 @@
|
||||||
},
|
},
|
||||||
"main": "assets/js/main.js",
|
"main": "assets/js/main.js",
|
||||||
"module": "assets/js/main.js",
|
"module": "assets/js/main.js",
|
||||||
"exports": {
|
|
||||||
".": {
|
|
||||||
"import": "./assets/js/main.js",
|
|
||||||
"require": "./assets/js/main.js"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"browserslist": [
|
"browserslist": [
|
||||||
"last 2 versions",
|
"last 2 versions",
|
||||||
|
|
Loading…
Reference in New Issue