Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(chore) add .js extension to import statements #2601

Merged
merged 6 commits into from
Jun 11, 2020
Merged
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
10 changes: 10 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,22 @@ module.exports = {
"indent": ["error", 2, {"VariableDeclarator":2}],
// seems like a good idea not to use explicit undefined
"no-undefined": "error",
// ensure import specifier contains file extension
"import/extensions": ["error", "always"],

// TODO maybe
"camelcase": "off", // TODO: turn on later
"init-declarations": ["error","always"]
},
"overrides": [
{
"files": ["src/**/*.js"],
"rules": {
// make sure there is no Node.js specific API slipping into the source files
"import/no-nodejs-modules": "error",
"import/no-commonjs": "error",
}
},
{
"files": ["src/languages/*.js"],
"rules": {
Expand Down
14 changes: 7 additions & 7 deletions src/highlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ Syntax highlighting with language autodetection.
https://highlightjs.org/
*/

import deepFreeze from './vendor/deep_freeze';
import Response from './lib/response';
import TokenTreeEmitter from './lib/token_tree';
import * as regex from './lib/regex';
import * as utils from './lib/utils';
import * as MODES from './lib/modes';
import { compileLanguage } from './lib/mode_compiler';
import deepFreeze from './vendor/deep_freeze.js';
import Response from './lib/response.js';
import TokenTreeEmitter from './lib/token_tree.js';
import * as regex from './lib/regex.js';
import * as utils from './lib/utils.js';
import * as MODES from './lib/modes.js';
import { compileLanguage } from './lib/mode_compiler.js';
import * as packageJSON from '../package.json';

const escape = utils.escapeHTML;
Expand Down
2 changes: 1 addition & 1 deletion src/languages/coffeescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Category: common, scripting
Website: https://coffeescript.org
*/

import * as ECMAScript from "./lib/ecmascript";
import * as ECMAScript from './lib/ecmascript.js';

/** @type LanguageFn */
export default function(hljs) {
Expand Down
2 changes: 1 addition & 1 deletion src/languages/groovy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Website: https://groovy-lang.org
*/

import * as regex from "../lib/regex";
import * as regex from '../lib/regex.js';

function variants(variants, obj = {}) {
obj.variants = variants;
Expand Down
2 changes: 1 addition & 1 deletion src/languages/handlebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Website: https://handlebarsjs.com
Category: template
*/

import * as regex from '../lib/regex'
import * as regex from '../lib/regex.js'

export default function(hljs) {
const BUILT_INS = {
Expand Down
2 changes: 1 addition & 1 deletion src/languages/htmlbars.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ TODO: Remove in version 11.0.
*/

// compile time dependency on handlebars
import handlebars from "./handlebars"
import handlebars from "./handlebars.js"

export default function(hljs) {
const definition = handlebars(hljs)
Expand Down
2 changes: 1 addition & 1 deletion src/languages/ini.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as regex from '../lib/regex';
import * as regex from '../lib/regex.js';

/*
Language: TOML, also INI
Expand Down
2 changes: 1 addition & 1 deletion src/languages/java.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Category: common, enterprise
Website: https://www.java.com/
*/

import * as regex from "../lib/regex";
import * as regex from '../lib/regex.js';

export default function(hljs) {
var JAVA_IDENT_RE = '[\u00C0-\u02B8a-zA-Z_$][\u00C0-\u02B8a-zA-Z_$0-9]*';
Expand Down
4 changes: 2 additions & 2 deletions src/languages/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Category: common, scripting
Website: https://developer.mozilla.org/en-US/docs/Web/JavaScript
*/

import * as ECMAScript from "./lib/ecmascript";
import * as regex from "../lib/regex";
import * as ECMAScript from './lib/ecmascript.js';
import * as regex from '../lib/regex.js';

export default function(hljs) {
var IDENT_RE = ECMAScript.IDENT_RE;
Expand Down
2 changes: 1 addition & 1 deletion src/languages/livescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Website: https://livescript.net
Category: scripting
*/

import * as ECMAScript from "./lib/ecmascript";
import * as ECMAScript from './lib/ecmascript.js';

export default function(hljs) {
var LIVESCRIPT_BUILT_INS = [
Expand Down
2 changes: 1 addition & 1 deletion src/languages/typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Website: https://www.typescriptlang.org
Category: common, scripting
*/

import * as ECMAScript from "./lib/ecmascript";
import * as ECMAScript from './lib/ecmascript.js';

export default function(hljs) {
var IDENT_RE = ECMAScript.IDENT_RE;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/html_renderer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { escapeHTML } from './utils';
import { escapeHTML } from './utils.js';

/**
* @typedef {object} Renderer
Expand Down
4 changes: 2 additions & 2 deletions src/lib/mode_compiler.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as regex from './regex';
import { inherit } from './utils';
import * as regex from './regex.js';
import { inherit } from './utils.js';

// keywords that should have no default relevance value
var COMMON_KEYWORDS = 'of and for in not or if then'.split(' ');
Expand Down
4 changes: 2 additions & 2 deletions src/lib/modes.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { inherit } from './utils';
import * as regex from './regex';
import { inherit } from './utils.js';
import * as regex from './regex.js';

// Common regexps
export const IDENT_RE = '[a-zA-Z]\\w*';
Expand Down
2 changes: 1 addition & 1 deletion src/lib/token_tree.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import HTMLRenderer from './html_renderer';
import HTMLRenderer from './html_renderer.js';

/** @typedef {{kind?: string, sublanguage?: boolean, children: Node[]} | string} Node */
/** @typedef {{kind?: string, sublanguage?: boolean, children: Node[]} } DataNode */
Expand Down