How to use the jsonc-parser.ScanError function in jsonc-parser

To help you get started, we’ve selected a few jsonc-parser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github codesandbox / codesandbox-client / standalone-packages / vscode-extensions / out / extensions / jpoissonnier.vscode-styled-components-0.0.26 / node_modules / vscode-emmet-helper / out / emmetHelper.js View on Github external
fs.readFile(snippetsPath, (err, snippetsData) => {
            if (err) {
                return reject(`Error while fetching the file ${snippetsPath}`);
            }
            try {
                let errors = [];
                let snippetsJson = JSONC.parse(snippetsData.toString(), errors);
                if (errors.length > 0) {
                    return reject(`Found error ${JSONC.ScanError[errors[0].error]} while parsing the file ${snippetsPath} at offset ${errors[0].offset}`);
                }
                variablesFromFile = snippetsJson['variables'];
                customSnippetRegistry = {};
                snippetKeyCache.clear();
                Object.keys(snippetsJson).forEach(syntax => {
                    if (!snippetsJson[syntax]['snippets']) {
                        return;
                    }
                    let baseSyntax = isStyleSheet(syntax) ? 'css' : 'html';
                    let customSnippets = snippetsJson[syntax]['snippets'];
                    if (snippetsJson[baseSyntax] && snippetsJson[baseSyntax]['snippets'] && baseSyntax !== syntax) {
                        customSnippets = Object.assign({}, snippetsJson[baseSyntax]['snippets'], snippetsJson[syntax]['snippets']);
                    }
                    if (!isStyleSheet(syntax)) {
                        // In Emmet 2.0 all snippets should be valid abbreviations
                        // Convert old snippets that do not follow this format to new format
github microsoft / vscode-emmet-helper / src / emmetHelper.ts View on Github external
fs.readFile(snippetsPath, (err, snippetsData) => {
			if (err) {
				return reject(`Error while fetching the file ${snippetsPath}`);
			}
			try {
				let errors = [];
				let snippetsJson = JSONC.parse(snippetsData.toString(), errors);
				if (errors.length > 0) {
					return reject(`Found error ${JSONC.ScanError[errors[0].error]} while parsing the file ${snippetsPath} at offset ${errors[0].offset}`);
				}
				variablesFromFile = snippetsJson['variables'];
				customSnippetRegistry = {};
				snippetKeyCache.clear();
				Object.keys(snippetsJson).forEach(syntax => {
					if (!snippetsJson[syntax]['snippets']) {
						return;
					}
					let baseSyntax = isStyleSheet(syntax) ? 'css' : 'html';
					let customSnippets = snippetsJson[syntax]['snippets'];
					if (snippetsJson[baseSyntax] && snippetsJson[baseSyntax]['snippets'] && baseSyntax !== syntax) {
						customSnippets = Object.assign({}, snippetsJson[baseSyntax]['snippets'], snippetsJson[syntax]['snippets'])
					}
					if (!isStyleSheet(syntax)) {
						// In Emmet 2.0 all snippets should be valid abbreviations
						// Convert old snippets that do not follow this format to new format